Jenkins-based hardware testing methods, electronic devices and media

By building hardware test files and calling Jenkins API, the problem that Jenkins fixed task templates cannot flexibly control the hardware test process is solved, and the flexibility and efficiency of hardware testing is improved, reducing the learning cost of hardware engineers.

CN117555626BActive Publication Date: 2024-11-01METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311615401.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-29
Publication Date
2024-11-01
Estimated Expiration
2043-11-29

AI Technical Summary

Technical Problem

In the prior art, Jenkins is used for hardware testing and fixed task templates cannot flexibly control the hardware test process and test logic, which increases the learning cost of hardware engineers.

Method used

By building hardware test files, following preset syntax rules, generating Jenkins configuration information and execution scripts, calling the Jenkins API to generate target hardware test tasks, and achieving flexible control of hardware test processes and logic.

Benefits of technology

Without increasing learning costs, the efficiency of hardware testing is improved, allowing hardware engineers to customize test solutions and personalize processing, reducing their dependence on Jenkins.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117555626B_ABST
    Figure CN117555626B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and more particularly to a hardware testing method, electronic device and medium based on Jenkins, step S1, building a hardware test file; step S2, storing the hardware test file in a code version management system; step S3, obtaining a target hardware test file from the code version management system, parsing and translating the target hardware test file, generating Jenkins configuration information and a Jenkins execution script; step S4, calling Jenkins' API to save the Jenkins configuration information and the Jenkins execution script in a Jenkins system, generating a target Jenkins hardware test task for execution. The present invention can flexibly control hardware test processes and test logic based on Jenkins without increasing learning costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a hardware testing method, electronic equipment and medium based on Jenkins. Background Art

[0002] Jenkins is an open source tool for continuous integration (CI), which is mainly used for continuous and automatic construction, testing and deployment of software projects. In hardware projects, Jenkins can be used as a work platform for automated simulation and testing. However, Jenkins has its own set of rules, configuration and programming language, which has a high learning cost for hardware engineers. Therefore, some general Jenkins task (job) templates are provided in the prior art, and Jenkins tasks are generated based on general Jenkins task templates, but the Jenkins task template is fixed and the hardware test process and test logic cannot be flexibly controlled. It can be seen from this that how to flexibly control the hardware test process and test logic based on Jenkins without increasing the learning cost has become a technical problem to be solved urgently. Summary of the invention

[0003] The present invention aims to provide a hardware testing method, electronic device and medium based on Jenkins, which can flexibly control the hardware testing process and testing logic based on Jenkins without increasing the learning cost.

[0004] According to a first aspect of the present invention, a hardware testing method based on Jenkins is provided, comprising:

[0005] Step S1, constructing a hardware test file, wherein the hardware test file is used to describe the hardware test process and test logic, and the hardware test file follows a preset grammatical rule;

[0006] Step S2, storing the hardware test file in a code version management system;

[0007] Step S3: Obtain the target hardware test file from the code version management system, parse and translate the target hardware test file, and generate Jenkins configuration information and Jenkins execution script;

[0008] Step S4: Call the Jenkins API to save the Jenkins configuration information and the Jenkins execution script into the Jenkins system, and generate a target Jenkins hardware test task for execution.

[0009] According to a second aspect of the present invention, there is provided an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to execute the method described in the first aspect of the present invention.

[0010] According to a third aspect of the present invention, there is provided a computer-readable storage medium storing computer-executable instructions, wherein the computer instructions are used to execute the method described in the first aspect of the present invention.

[0011] Compared with the prior art, the present invention has obvious advantages and beneficial effects. By means of the above technical solution, the hardware testing method, electronic device and medium based on Jenkins provided by the present invention can achieve considerable technical advancement and practicality, and have wide industrial utilization value, and at least have the following beneficial effects:

[0012] The present invention constructs a hardware test file based on preset grammatical rules, generates Jenkins configuration information and a Jenkins execution script by parsing and translating the target hardware test file, and then calls the Jenkins API to generate a target Jenkins hardware test task for execution. The present invention is not limited to the Jenkins task template, and can flexibly control the hardware test process and test logic based on Jenkins without increasing the learning cost, thereby improving the efficiency of hardware testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0014] Figure 1 A flowchart of a hardware testing method based on Jenkins provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0015] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0016] The embodiment of the present invention provides a hardware testing method based on Jenkins, such as Figure 1 As shown, including:

[0017] Step S1, constructing a hardware test file, wherein the hardware test file is used to describe the hardware test process and test logic, and the hardware test file follows preset grammatical rules.

[0018] As an embodiment, the hardware test file can be generated by directly inputting statements that describe the hardware test process and test logic in accordance with preset grammatical rules based on the preset first display interface. This method has greater flexibility. Users can control the test process and test logic by themselves according to specific application requirements and formulate personalized test plans. The user can specifically be a hardware engineer. As another embodiment, the hardware test file can also be generated by rewriting the generated historical hardware test files based on the preset second display interface. This method is more efficient and simple, but less flexible than the direct input method based on the preset first display interface. The corresponding method of constructing the hardware test file can be selected according to the specific application requirements.

[0019] Step S2: storing the hardware test file in a code version management system.

[0020] The code version management system may specifically be a code version tool such as perforce, git, svn, cvs, etc. Perforce, git, svn, cvs are all existing code version tools and will not be described in detail here. The code version management system is used to store one or more versions of hardware test files.

[0021] Step S3: Obtain the target hardware test file from the code version management system, parse and translate the target hardware test file, and generate Jenkins configuration information and Jenkins execution script.

[0022] It should be noted that when a new version of the hardware test file is stored in the code version management tool, Jenkins will be notified. Jenkins can automatically obtain the target hardware test file from the code version management tool according to specific application requirements. The target hardware test file can be a newer version of the hardware test file or a historical version of the hardware test file. Specifically, the pre-set Jenkins task creation tool can be called to parse and translate the target hardware test file.

[0023] Step S4, calling the Jenkins application program interface (API) to save the Jenkins configuration information and the Jenkins execution script into the Jenkins system, and generating a target Jenkins hardware test task for execution.

[0024] Among them, the Jenkins system can directly identify the Jenkins configuration information and the Jenkins execution script. Therefore, based on the Jenkins configuration information and the Jenkins execution script, the Jenkins system can generate a target Jenkins hardware test task for execution.

[0025] It should be noted that in the embodiment of the present invention, the hardware test file is constructed mainly with reference to the syntax of python and shell, but unlike the syntax of python and shell, the present invention does not execute and calculate immediately when parsing the language script, but performs semantic parsing and translation on the script, converting it into a set of configuration parameters of Jenkins and an execution script that conforms to the syntax rules of Jenkins. Through the API interface provided by Jenkins, the configuration and execution scripts are input into the Jenkins system, and when the triggering conditions are met, Jenkins automatically calls and executes them.

[0026] As an embodiment, the step S1 includes:

[0027] Step S111, based on preset keywords, preset data types, preset operators, preset operation priority, preset logic control symbols, and according to preset grammatical rules, generate the hardware test file.

[0028] Among them, preset keywords, preset data types, preset operators, preset operation priority, preset logic control symbols, and preset grammar rules are all pre-constructed information, and the above information is well known to hardware engineers, without the need for additional large amounts of learning costs.

[0029] As an embodiment, the preset keywords include at least one of true, false, not, if, else, elif, for, while, def, or, and, continue, break, return and the like. The true, false, not, if, else, elif, for, while, def, or, and, continue, break, return are mainly set with reference to the python language and have the same functions as the corresponding keywords in the python language, which will not be repeated here.

[0030] As an embodiment, the preset data type includes at least one of integer, floating point, string, Boolean type, Test type, Case type, etc. Among them, integer, floating point, string, Boolean type are commonly used types, Test type and Case type are built-in types created according to hardware test instructions, symbols and hardware test instruction creation rules.

[0031] As an embodiment, the preset operator includes at least one of an arithmetic operator, a comparison operator, an assignment operator and a logical operator.

[0032] Among them, the arithmetic operators specifically include: +, -, *, / , %, / / .

[0033] Comparison operators specifically include: ==, !=, >, <, >=, <=.

[0034] The specific assignment operators include: =.

[0035] Logical operators include: and, or, and not.

[0036] As an example, the operator precedence, from high to low, is as follows:

[0037] First level: *, / , %, / / .

[0038] Second level: +, -.

[0039] Level 3: <, >, <=, >=.

[0040] Level 4: ==,!=.

[0041] Level 5: =.

[0042] Level 6: and, or, not.

[0043] As an embodiment, the preset logic control symbol includes at least one of the logic controls such as conditional judgment, for loop, while loop, etc. Among them, the conditional judgment includes if conditional judgment, elif conditional judgment, and else conditional judgment. The preset logic control symbol follows the usage rules of the logic control symbol in Python syntax.

[0044] As an embodiment, the preset grammar rules refer to the grammar rules of Python and shell, and the preset grammar rules include at least one of the following grammar rules: the file header is marked with #! / usr / bin / env ht_creator to facilitate operating system recognition; a line contains only one statement or expression, and no terminator is set at the end of the statement or expression; indentation is used to represent a code block; variables must be defined before use, and variables are weakly typed variables; the use of blank lines is not limited; the use of spaces before and after operators is not limited; the script execution entry is the main() function; the def keyword is used to define custom data types and functions; the statement after "#" is a comment.

[0045] As an embodiment, in step S3, parsing and translating the target hardware test file includes:

[0046] Step S31, read the target hardware test file and check whether it complies with the preset grammatical rules. If it does, execute step S32, otherwise, report an error and exit execution.

[0047] Before processing the target hardware test file, first check whether it complies with the preset grammatical rules to avoid subsequent useless operations.

[0048] Step S32: pre-process the checked target hardware test file to generate a data structure in the memory.

[0049] Step S33: Translate the data structure in the memory to generate Jenkins configuration information and a Jenkins execution script.

[0050] As an embodiment, the step S31 includes:

[0051] Step S311, check whether the file header conforms to the preset grammatical rules, if it does, execute step S312, otherwise, execute step S316.

[0052] Step S312, check whether the keywords and operators conform to the preset grammatical rules, if yes, execute step S313, otherwise, execute step S316.

[0053] Step S313, check whether the indentation complies with the preset grammatical rules, if yes, execute step S314, otherwise, execute step S316.

[0054] Step S314, check whether the variable definition complies with the preset grammatical rules, if yes, execute step S315, otherwise, execute step S316.

[0055] Step S315, check whether there is a main() entry, if so, execute step S32, otherwise, execute step S316;

[0056] Step S316: Report an error and exit execution.

[0057] Through steps S311 to S316, the target hardware test file is checked item by item to see whether it complies with the preset grammatical rules.

[0058] As an embodiment, step S32 includes:

[0059] Step S321, extract variable definition, function definition and Jenkins configuration parameter part from the checked target hardware test file, and store them in a data structure in memory, wherein the variable definition includes a variable name and a variable value, and the function definition includes a function name, a function interface and a function body.

[0060] The function interface includes the input parameters and output return values ​​of the function. The function body is the set of statements executed by the function.

[0061] Step S322: For variables that can calculate results, directly calculate and replace the variables with actual calculation result values, and store them in the data structure in the memory.

[0062] Step S323: Replace the function name variable with the defined function body and store it in the data structure in the memory.

[0063] It should be noted that, in the compilation process, in some cases, the content of the function body is directly replaced where the function name appears, and in some cases, the function body is stored in a certain address of the memory, and when the function name is executed, it jumps to the corresponding memory address for execution. In step S323, the function name variable is directly replaced with the defined function body and stored in the data structure in the memory, which can simplify the execution process of the function and improve the efficiency of function execution.

[0064] Step S324: Divide the code logic part into an expansion part and an overall translation replacement part, and store them in a data structure in the memory.

[0065] Step S325: If a variable or function name that has not been defined in advance is detected, an error is reported and the process exits.

[0066] It is understandable that the detection process runs through the entire processing flow. If any problem occurs, the error will be reported and exited in time to reduce useless operations.

[0067] As an embodiment, step S33 includes:

[0068] Step S331: Translate the variables in the data structure in the memory into global variables of Jenkins to obtain Jenkins configuration information.

[0069] It should be noted that the variables in the data structure in memory are all string information, which can be directly translated into the corresponding Jenkins global variables to obtain the Jenkins configuration information.

[0070] Step S332: logically expand the expanded part of the code logic of the data structure in the memory, translate and generate multiple Jenkins code blocks, directly translate the overall translation replacement part of the code logic into a Jenkins code block, and generate a Jenkins execution script.

[0071] The expanded part of the code logic can be a loop of n times, which is expanded and translated into n code blocks on Jenkins. The overall translation replacement part of the code logic is directly translated into a Jenkins code block, which can be a statement or a code block with the same logical structure.

[0072] Step S333: If a logical error that cannot be translated is detected, an error message is given and the program exits.

[0073] The embodiment of the present invention refers to the syntax rules of shell and python, and directly uses hardware test instructions, so that hardware engineers can quickly start writing their own test scripts after reading the instruction documents. With the provided compilation tool, the syntax and logic errors in the script can be quickly checked, and the corresponding Jenkins tasks can be generated. Hardware engineers do not need to understand the working principle and working details of Jenkins, and do not need to learn the syntax rules of Jenkins, which greatly saves learning costs. In addition to the low learning cost, compared with the method of generating Jenkins tasks through a general Jenkins task template used in the prior art, the method of using the hardware test description language also has the following advantages: (1) There is no need to forcibly apply the test process to several test templates, which can more accurately reflect the test ideas of hardware engineers. (2) Hardware engineers can control the test process and test logic by themselves and formulate personalized test plans. (3) Hardware engineers can perform personalized follow-up processing based on the test results.

[0074] It should be noted that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.

[0075] An embodiment of the present invention also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are configured to execute the method described in the embodiment of the present invention.

[0076] The embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer instructions are used to execute the method described in the embodiment of the present invention.

[0077] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.

Claims

1. A hardware testing method based on Jenkins, It is characterized in that include: Step S1, constructing a hardware test file, wherein the hardware test file is used to describe the hardware test process and test logic, and the hardware test file follows a preset grammatical rule; Step S2, storing the hardware test file in a code version management system; Step S3: Obtain the target hardware test file from the code version management system, parse and translate the target hardware test file, and generate Jenkins configuration information and Jenkins execution script; Step S4, calling the Jenkins API to save the Jenkins configuration information and the Jenkins execution script into the Jenkins system, and generating a target Jenkins hardware test task for execution; In step S3, parsing and translating the target hardware test file includes: Step S31, read the target hardware test file, check whether it meets the preset grammatical rules, if yes, execute step S32, otherwise, report an error and exit execution; Step S32, preprocessing the checked target hardware test file to generate a data structure in memory; Step S33: Translate the data structure in the memory to generate Jenkins configuration information and Jenkins execution script; The step S33 comprises: Step S331: Translate the variables in the data structure in the memory into global variables of Jenkins to obtain Jenkins configuration information; Step S332: logically expand the expanded part of the code logic of the data structure in the memory, translate and generate multiple Jenkins code blocks, directly translate the overall translation replacement part of the code logic into a Jenkins code block, and generate a Jenkins execution script; Step S333: If a logical error that cannot be translated is detected, an error message is given and the program exits.

2. The method according to claim 1, It is characterized in that The step S1 comprises: Step S111, based on preset keywords, preset data types, preset operators, preset operation priority, preset logic control symbols, and according to preset grammatical rules, generate the hardware test file.

3. The method according to claim 2, It is characterized in that The preset keywords include at least one of true, false, not, if, else, elif, for, while, def, or, and, continue, break, and return; The preset data type includes at least one of an integer, a floating point number, a string, a Boolean type, a Test type, and a Case type; The preset operator includes at least one of an arithmetic operator, a comparison operator, an assignment operator and a logical operator; The preset logic control symbol includes at least one of a conditional judgment, a for loop, and a while loop.

4. The method according to claim 1, It is characterized in that The preset grammar rules include at least one of the following grammar rules: The file header is marked with #! / usr / bin / env ht_creator; A line contains only one statement or expression, and no terminator is set at the end of the statement or expression; Use indentation to indicate code blocks; Variables must be defined before use, and are weakly typed variables; The use of blank lines is not restricted; There is no restriction on the use of spaces before and after operators; The script execution entry is the main() function; The def keyword is used to define custom data types and functions; The statements following "#" are comments.

5. The method according to claim 1, It is characterized in that The step S31 comprises: Step S311, check whether the file header conforms to the preset grammatical rules, if it conforms, execute step S312, otherwise, execute step S316; Step S312, check whether the keywords and operators conform to the preset grammatical rules, if they do, execute step S313, otherwise, execute step S316; Step S313, check whether the indentation complies with the preset grammatical rules, if yes, execute step S314, otherwise, execute step S316; Step S314, check whether the variable definition complies with the preset grammatical rules, if yes, execute step S315, otherwise, execute step S316; Step S315, check whether there is a main() entry, if so, execute step S32, otherwise, execute step S316; Step S316: Report an error and exit execution.

6. The method according to claim 1, It is characterized in that The step S32 comprises: Step S321, extracting variable definitions, function definitions, and Jenkins configuration parameter parts from the checked target hardware test file, and storing them in a data structure in the memory, wherein the variable definition includes a variable name and a variable value, and the function definition includes a function name, a function interface, and a function body; Step S322: For variables that can be calculated, directly calculate and replace the variables with actual calculation result values, and store them in the data structure in the memory; Step S323, replace the function name variable with the defined function body and store it in the data structure in the memory; Step S324, dividing the code logic part into an expansion part and an overall translation replacement part, and storing them in a data structure in the memory; Step S325: If a variable or function name that has not been defined in advance is detected, an error is reported and the program exits.

7. An electronic device, It is characterized in that include: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, wherein the instructions are configured to execute the method according to any one of claims 1 to 6.

8. A computer-readable storage medium, It is characterized in that Computer executable instructions are stored, and the computer executable instructions are used to execute the method according to any one of the preceding claims 1-6.