A KiCad compiler test method based on EMI differential testing

Through the EMI differential testing method, the KiCad compiler is comprehensively tested, which solves the problem of lack of bug search in the existing technology, improves the stability and detection efficiency of the software, and reduces manpower and material costs.

CN116048992BActive Publication Date: 2025-07-11DALIAN MARITIME UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310059107.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-17
Publication Date
2025-07-11
Estimated Expiration
2043-01-17

AI Technical Summary

Technical Problem

The existing KiCad test methods mainly target the stability after compilation, rather than the specific test of KiCad itself. The lack of effective bug search methods makes it difficult to guarantee software stability.

Method used

Using the EMI differential testing method, the electronic circuit is compiled by selecting components that comply with the rules, pre-connection and depth-first search, and the electronic circuit is compiled in combination with acceleration mode and ordinary compilation mode, and the results are compared to detect bugs.

Benefits of technology

A comprehensive test of the KiCad compiler has been achieved, which improves the stability and coverage of the software, reduces manpower and material costs, and improves efficiency by using computer automation detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116048992B_ABST
    Figure CN116048992B_ABST
Patent Text Reader

Abstract

The present invention discloses a KiCad compiler test method based on EMI differential testing, including: selecting components that meet the rules from KiCad, GitHub, and component libraries; the obtained components receive data through input ports and output data through output ports, where the output ports are numbered starting from 1 and the input ports are numbered starting from 0, and the output port of one component is connected to the input port of the next component through connection rules; using a single graph traversal method to repair errors in inconsistent data types between components in linear time; performing compilation tests on the Eeschema class compilation component using two modes: an accelerated mode and a normal compilation mode. Analyze the obtained compilation results. If the results are different, it can be considered a bug in KiCad, and the test cases that generate the bug are sorted out.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software testing, and in particular to a KiCad compiler testing method based on EMI differential testing. Background Art

[0002] KiCad is an open-source software tool used to create electronic schematic diagrams and PCB graphics. KiCad is a GPL EDA (Electronic Design Automation) software package and can be regarded as an alternative version of Protel under Linux. KiCad includes a project manager and four main programs: the project manager (Kicad), the schematic editor (Eeschema), the component package association selector (Cvpcb), and the PCB routing program (Pcbnew). Its main function is to design circuit components, perform encapsulation and routing, and finally obtain circuit board drawings.

[0003] SLforge is a testing method for automatically finding bugs in the CPS development toolchain. The models generated by SLforge are similar to the collected common models. SLforge can generate models more effectively by consulting available (informal) Simulink specifications and provides the first method for equivalent mode input (EMI) testing in CPS development tool testing. SLforge creates EMI variants from the random models it generates and uses them in differential testing settings.

[0004] KiCad official provides a testing method, and the test is registered using the CTest component of CMake. However, this does not represent a test for KiCad. It only represents a test for the stability of the compiled KiCad. Specifically, the official testing method is not a specific test for KiCad, but more like a test for the stability of the compiler that compiles KiCad.

[0005] A PCB (Printed Circuit Board), also known as a printed wiring board, is an important electronic component, a support for electronic components, and a carrier for the electrical connection of electronic components. Since it is made using electronic printing technology, it is called a "printed" circuit board. After an electronic device adopts a printed circuit board, due to the consistency of the same type of printed circuit boards, human wiring errors are avoided, and automatic insertion or mounting of electronic components, automatic soldering, and automatic detection can be achieved, ensuring the quality of the electronic device, improving labor productivity, reducing costs, and facilitating maintenance. As a software for creating electronic schematic diagrams and PCB graphics, it is very necessary to test KiCad, which can greatly reduce the cost of human and material resources, and currently there is no method for finding bugs in KiCad. Summary of the Invention

[0006] In view of the problems existing in the prior art, the present invention discloses a KiCad compiler test method based on EMI differential testing, which specifically includes the following steps:

[0007] Select components that meet the rules. First, obtain a large number of components from KiCad, GitHub, and the component library, and then express the specifications collected from the official KiCad documentation as formulas or rules, and select components according to these rules.

[0008] Pre-connect the ports of the obtained valid components. Name the components that send output and receive data during the connection as targets. The output ports are numbered starting from 1, and the input ports are numbered starting from 0. Finally, add connections through the following two rules.

[0009]

[0010]

[0011] Adopt a single-graph traversal method to fix errors in data type mismatches between components. Place each component with a known output data type (including non-directly fed components and components from the component library) in a set. Starting from this set, perform a depth-first search on the graphical representation of the PCB, and use forward propagation to propagate data type information from components with known output data types along the connections to other components.

[0012] Compile and test the Eeschema class compilation component using different modes. Compile the same electronic circuit schematic or PCB using the accelerator mode and the normal compilation mode, and compare the compilation results of the two. If they are the same, it means there are no bugs in the compilation process; if they are different, it means there are bugs in the compilation process.

[0013] Output the detected bugs and organize the test cases that generate bugs.

[0014] Due to the adoption of the above technical solution, a KiCad compiler test method based on EMI differential test provided by the present invention can more thoroughly test KiCad compilation by using the EMI differential test method, ensuring the stability of development tools in the field of chip design and high-end manufacturing. Compared with previous test technologies, the technology we use has a wider coverage and a higher maturity level. It can maintain the stability of KiCad to a certain extent. By leveraging the powerful computing power of the computer and the reliability of the software itself to execute repeatedly, it becomes an inevitable choice to let the computer replace humans to do these labor-intensive, highly repetitive, and error-prone tedious tasks. The development of EDA software is one of the driving forces for the continuous development of the integrated circuit industry over the years, so the stability of EDA software becomes important. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0016] Figure 1 It is a flowchart of the method of the present invention DETAILED DESCRIPTION OF THE EMBODIMENTS

[0017] To make the technical solutions and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention:

[0018] As Figure 1 shown, a KiCad compiler test method based on EMI differential test specifically includes the following steps:

[0019] S1: Select effective components, and the specific steps are as follows:

[0020] a) A large number of components are collected from the main open-source project hosting services of KiCad, GitHub, and component libraries.

[0021] b) Use an easily designed parser to automatically collect specifications directly from the official KiCad documentation.

[0022] c) Express the KiCad specifications as formulas or rules.

[0023] d) Select components according to the obtained rules, and the rules are as follows.

[0024] First, the concept of a valid predicate needs to be clarified. A valid predicate can indicate whether a PCB type checker and a runtime system accept a given model as legal, that is, without compilation or runtime exceptions.

[0025] Given such a rule δ ∈ Δ, we use m ╞ δ to represent that the component m satisfies the rule. We observe that a valid component satisfies all the collected specification rules, that is:

[0026]

[0027] S2: Pre-connect the ports of the obtained valid components. The specific steps are as follows:

[0028] In an EDA development design tool (e.g., KiCad), the user designs the PCB as a set of data flow models. The models contain components. The components accept data through their input ports, usually perform certain operations on the data, and may transmit the data along the connection lines and through its output ports to other blocks. KiCad specifies which ports of the components support which data types.

[0029] a) Name the component that sends output in the connection and the component that receives data as the target

[0030] b) The output ports are numbered starting from 1

[0031] c) The input ports are numbered starting from 0

[0032] d) Add connections through the following two rules

[0033]

[0034]

[0035] Among them, the component b ∈ B and the connection c ∈ C can be part of the PCB diagram m ∈ M. Then, a PCB diagram can be represented by the tuple <B, C>, where m.B and m.C represent the components and the connections between the components in the PCB diagram respectively. The starting component of each connection is b s , the output port of the starting component is p s , the target component is b t , the input port of the target component is p t , then a connection can be represented by the tuple <b s , p s , b t , p t >.

[0036] In addition to this explicit connection, using some components, implicit (hidden) connections can also be defined. In the present invention, explicit connections are mainly adopted.

[0037] S3: Use the method of traversing a single graph to fix the error of data type mismatch between components. The specific steps are as follows:

[0038] a) Place each component with a known output data type (including non-directly fed components and components from the component library) in a set

[0039] b) Starting from them, perform a depth-first search on the graphical representation of the PCB

[0040] c) Use forward propagation to propagate the data type information from components with known output data types along the connections to other components

[0041] S4: Use different modes for EMI differential testing on the Eeschema class compilation component to detect bugs. The specific steps are as follows:

[0042] Equivalent-mode input (EMI) testing is the latest advancement in differential testing of programming language compilers. As a complement to ordinary differential testing, the idea is to systematically change the source program as long as its semantics remain equivalent under the given input data. Engineering basic mutators are relatively easy, and the overall scheme can effectively discover bugs when combined with a powerful random generator that can create and test inputs (e.g., Csmith). In the initial implementation, EMI mainly utilized Csmith, which generates random C programs that do not accept user input. Then, it can be expected that a given compiler in a given configuration will produce a program that gives the same result for all EMI mutants.

[0043] a) Compile the same electronic circuit schematic or PCB using the accelerator mode and the ordinary compilation mode

[0044] b) Compare the results of the two compilations

[0045] c) If they are the same, it indicates that there are no bugs in the compilation process

[0046] d) If they are different, it indicates that there are bugs in the compilation process

[0047] In simulation compilation, use the built-in solver to numerically solve the mathematical relationships of the model established by components and their connections, and calculate the outputs of various non-components according to the sampling time requested by the user and the inferred context-dependent time step. KiCad provides different simulation compilation modes, but the ordinary compilation mode also emits some code for components in the accelerator mode and the stand-alone executables in the accelerator mode.

[0048] S5: Output the obtained bugs and organize the test cases that generate the bugs.

[0049] The above are only the preferred specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution of the present invention and its inventive concept, making equivalent substitutions or changes, should be covered by the protection scope of the present invention.

Claims

1. A KiCad compiler test method based on EMI differential testing, characterized in that Including: S1: Select components that meet the rules; S2: The components receive data through the input ports and output data through the output ports, where the output ports are numbered starting from 1, the input ports are numbered starting from 0, and the output port of one component is connected to the input port of the next component according to the connection rules; S3: Use the method of single graph traversal to fix the error of inconsistent data types between components in linear time; S4: Compile and test the Eeschema class compilation component using the accelerated mode and the normal compilation mode; Multiple components are collected from the main open-source project hosting services of KiCad, GitHub, and the component library. The parser automatically collects specifications directly from the official KiCad documentation, expresses the KiCad specifications as connection rules, and selects components according to the connection rules. The connection rules are as follows: ∧|{c2∈m.C:c2.b s = c.b s ∧c2.p s = c.p s}| = 1 Among them, component b ∈ B and connection c ∈ C are part of PCB m ∈ M. A PCB diagram is represented by the tuple <B, C>, where m.B and m.C represent the components and the connections between components in the PCB diagram respectively. The starting component of each connection is b s , the output port of the starting component is p s , the target component is b t , the input port of the target component is p t , then a connection can be represented by the tuple <b s , p s , b t , p t >.

2. The KiCad compiler test method based on EMI differential testing according to claim 1, characterized in that: When fixing the error of inconsistent data types between components in linear time: Place each component with a known output data type in a set, perform a depth-first search on the graphical representation of the PCB in this set, use forward propagation, and propagate the data type information from the component with a known output data type along the connection to other components.

3. A KiCad compiler test method based on EMI differential testing according to claim 1, characterized in that: Compare the compilation results of the accelerated mode and the normal compilation mode. If they are the same, it means that there are no bugs in the compilation process. If they are different, it means that there are bugs in the compilation process.

Citation Information

Patent Citations

  • Terminal software test method, to-be-tested terminal and computer readable storage medium

    CN107463491A

  • Method and apparatus for software testing using a differential testing technique to test compilers

    US5754860A