CN112799649B - Code construction method, device, equipment and storage medium - Google Patents

Code construction method, device, equipment and storage medium Download PDF

Info

Publication number
CN112799649B
CN112799649B CN202010543411.0A CN202010543411A CN112799649B CN 112799649 B CN112799649 B CN 112799649B CN 202010543411 A CN202010543411 A CN 202010543411A CN 112799649 B CN112799649 B CN 112799649B
Authority
CN
China
Prior art keywords
code
command
construction
code construction
commands
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010543411.0A
Other languages
Chinese (zh)
Other versions
CN112799649A (en
Inventor
贺洪军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN202010543411.0A priority Critical patent/CN112799649B/en
Publication of CN112799649A publication Critical patent/CN112799649A/en
Priority to PCT/CN2021/099361 priority patent/WO2021254243A1/en
Priority to EP21826277.2A priority patent/EP4167076A4/en
Priority to JP2022554637A priority patent/JP7433464B2/en
Priority to US18/010,014 priority patent/US20230251952A1/en
Application granted granted Critical
Publication of CN112799649B publication Critical patent/CN112799649B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a code construction method, a code construction device, code construction equipment and a storage medium. The method comprises the following steps: generating at least two test construction commands according to different environment variables in the code construction commands; executing the at least two test construction commands on the codes respectively, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands; and executing the adjusted code construction command on the code.

Description

Code construction method, device, equipment and storage medium
Technical Field
The present application relates to the field of computers, and in particular, to a code construction method, apparatus, device, and storage medium.
Background
In the prior art, the code auditing requirements are stricter and wider due to the safety consideration, and the code binary equivalent auditing also becomes an important index.
There are two general methods for dealing with binary equivalent auditing of codes in the industry: passive analysis and active defense.
Passive analysis: and comparing the code construction results, and analyzing and explaining that the difference is caused by factors which do not influence program logic, such as time stamps, random numbers, file sequences and the like, so as to indirectly prove binary equivalence of the code to be audited. This way of encountering a discrepancy and then passively analyzing has the following disadvantages: 1. if the difference is found to be re-analyzed, the time requirement of the user is often not met, and a difference analysis report cannot be provided for the user in time; 2. the reusability is poor, and because the analysis result has low reusability, a large amount of analysis work is repeated, which is time-consuming and labor-consuming, possibly after the replacement engineering; 3. the analysis efficiency is low, in the construction process, the difference is transmitted, the tiny difference in the construction starting process can cause the big difference of the final result, when in passive analysis, the reverse tracing is needed, the layer-by-layer analysis is needed, the root cause causing the construction result difference is found, the analysis process is time-consuming and labor-consuming, and the efficiency is lower.
Active defense: analyzing engineering source codes in advance to find out factors possibly influencing binary equivalence of codes: the method comprises the steps of modifying time stamps, random numbers, file sequences, character sets and the like into constants for repairing or avoiding on the premise of not affecting program logic, so that binary consistency of multiple construction results is achieved, and the binary equivalence of audited codes is guaranteed. Disadvantages of this approach: 1. the reusability is poor, the work of analyzing and modifying the engineering source codes can not be reused, and complex engineering analysis and modification work can be repeated after the engineering is replaced; 2. the analysis efficiency is low, manual work is needed to analyze engineering, the workload is large, and omission is possible.
Disclosure of Invention
In order to solve the technical problems, the application provides a code construction method, a device, equipment and a storage medium.
In a first aspect, an embodiment of the present application provides a code construction method, including:
generating at least two test construction commands according to different environment variables in the code construction commands;
executing the at least two test construction commands on the codes respectively, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands;
and executing the adjusted code construction command on the code.
In a second aspect, an embodiment of the present application provides a code construction apparatus, including:
the generating module is used for generating at least two test construction commands according to different environment variables in the code construction commands;
the adjusting module is used for respectively executing the at least two test construction commands on the codes, and adjusting the code construction commands according to environment variables in the code construction commands if the execution results are inconsistent;
and the execution module is used for executing the adjusted code construction command on the code.
In a third aspect, the present application provides an apparatus comprising:
one or more processors;
a storage means for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement methods as provided by embodiments of the present application.
In a fourth aspect, embodiments of the present application provide a storage medium storing a computer program which, when executed by a processor, implements any of the methods of the embodiments of the present application.
With respect to the above embodiments and other aspects of the application and implementations thereof, further description is provided in the accompanying drawings, detailed description and claims.
Drawings
FIG. 1 is a schematic flow chart of a code construction method provided by the application;
FIG. 2 is a schematic diagram of a code construction device according to the present application;
fig. 3 is a schematic structural diagram of an apparatus according to the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in detail hereinafter with reference to the accompanying drawings. It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be arbitrarily combined with each other.
The steps illustrated in the flowchart of the figures may be performed in a computer system, such as a set of computer-executable instructions. Also, while a logical order is depicted in the flowchart, in some cases, the steps depicted or described may be performed in a different order than presented herein.
In an exemplary embodiment, fig. 1 is a schematic flow chart of a code construction method provided in the present application, where the method may be adapted to cope with a binary audit of a code, and the method may be performed by a code construction apparatus, where the code construction apparatus may be implemented by software and/or hardware and integrated on a device. The device may be a computer device.
As shown in fig. 1, the code construction method provided by the present application includes S110, S120, and S130.
S110, generating at least two test construction commands according to different environment variables in the code construction commands.
Wherein the environmental variables include: at least one of a user name, a system time, a time stamp, a random number, a file order, and a character set.
The environment variable is a variable included in the code construction command, for example, if the code construction command generates a compressed package file command, the environment variable is a timestamp.
The different environment variables may be different types of environment variables, or may be different values corresponding to the same type of environment variables, for example, the different environment variables may be a time stamp a and a time stamp B, or may be a time stamp a and a user name C, which is not limited in the embodiment of the present application.
Specifically, tracking the engineering construction process, the engineering construction process refers to a process of binary conversion of codes, monitoring code construction commands in the engineering construction process, suspending execution of the code construction commands, and generating at least two test construction commands according to different environment variables, for example, tracking the engineering construction process, the engineering construction process refers to a process of binary conversion of codes, monitoring code construction commands in the engineering construction process, suspending execution of the code construction commands, and generating a test construction command according to the system time A and a test construction command according to the system time B if the environment variables are the system time A and the system time B; if the environment variable is the system time A and the user name C, generating a test construction command according to the system time A and generating a test construction command according to the user name C; alternatively, if the environment variables are the timestamp Q, the random number M and the user name C, a test construction command is generated according to the timestamp Q, a test construction command is generated according to the random number M, and a test construction command is generated according to the user name C; or, if the environment variables are the system time a, the system time B and the system time P, generating a test construction command according to the system time a, generating a test construction command according to the system time B and generating a test construction command according to the system time P.
S120, respectively executing the at least two test construction commands on the codes, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands.
The at least two test construction commands are executed on the code respectively, for example, if the environment variables are the system time a and the system time B, one test construction command is generated according to the system time a, one test construction command is generated according to the system time B, the test construction command generated according to the system time a is executed on the code, and the test construction command generated according to the system time B is executed on the code; if the environment variables are system time A, system time B and system time P, generating a test construction command according to the system time A, generating a test construction command according to the system time B, generating a test construction command according to the system time P, executing the test construction command according to the system time A on the code, executing the test construction command according to the system time B on the code, and executing the test construction command according to the system time P on the code; alternatively, if the environment variables are the timestamp Q, the random number M, and the user name C, a test construction command is generated according to the timestamp Q, a test construction command is generated according to the random number M, a test construction command is generated according to the user name C, a test construction command generated according to the timestamp Q is executed on the code, a test construction command generated according to the random number M is executed on the code, and a test construction command generated according to the user name C is executed on the code.
Specifically, if the execution results are inconsistent, the code construction command is adjusted according to the environment variable in the code construction command, for example, if the environment variable is the system time a and the system time B, a test construction command is generated according to the system time a, a test construction command is generated according to the system time B, the test construction command generated according to the system time a is executed on the code, the test construction command generated according to the system time B is executed on the code, if the execution result of the test construction command generated according to the system time a is X on the code, the execution result of the test construction command generated according to the system time B is Y on the code, because the execution result X and the execution result Y are different, the execution result is inconsistent, and the code construction command is adjusted according to the system time; if the environment variables are system time A, system time B and system time P, generating a test construction command according to the system time A, generating a test construction command according to the system time B, generating a test construction command according to the system time P, executing the test construction command according to the system time A on the code, executing the test construction command according to the system time B on the code, executing the test construction command according to the system time P on the code, wherein the execution result of the test construction command according to the system time A on the code is X, the execution result of the test construction command according to the system time B on the code is Y, and the execution result of the test construction command according to the system time P on the code is Z; alternatively, if the environment variables are the timestamp Q, the random number M, and the user name C, a test construction command is generated according to the timestamp Q, a test construction command is generated according to the random number M, a test construction command generated according to the timestamp Q is executed on the code, a test construction command generated according to the random number M is executed on the code, a test construction command generated according to the user name C is executed on the code, an execution result of the test construction command generated according to the timestamp Q is X on the code, an execution result of the test construction command generated according to the random number M is X on the code, an execution result of the test construction command generated according to the user name C is Y on the code, and the code construction command is adjusted according to the timestamp, the random number, and the user name because the execution result X and the execution result Y are different.
S130, executing the adjusted code construction command on the code.
Specifically, the code construction command after the adjustment is executed on the code, for example, if the environment variable is a timestamp, the system time of the code construction command is adjusted to a fixed value, and the code construction command for adjusting the system time to the fixed value is executed on the code; and if the environment variable is the file list order, adjusting the code construction command to order the execution result by using an ordering tool after the execution result is obtained, and executing the adjusted code construction command on the code.
The application provides a code construction method, which generates at least two test construction commands according to different environment variables in the code construction commands; executing the at least two test construction commands on the codes respectively, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands; and executing the adjusted code construction command on the code can enable the construction results of the codes to be consistent, and automatically realize reproducible code construction.
On the basis of the above embodiments, modified embodiments of the above embodiments are proposed, and it is to be noted here that only the differences from the above embodiments are described in the modified embodiments for the sake of brevity of description.
In one embodiment, adjusting the code build command according to an environmental variable in the code build command includes:
inquiring a database according to the code construction command to obtain a first adjustment rule corresponding to the code construction command;
and adjusting each environment variable in the code construction command according to the first adjustment rule.
The database in which the correspondence relation between the code construction command and the adjustment rule is established in advance may be, for example, the database stores therein the code construction command W and the adjustment rule of all the environment variables in the code construction command W; code build command G and adjustment rules for all environment variables in code build command G; code build command K and adjustment rules for all environment variables in code build command K.
The first adjustment rule may include an adjustment rule of all environment variables in the code construction command, for example, if the code construction command includes environment variable D and environment variable E, the first adjustment rule includes an adjustment rule of environment variable D and an adjustment rule of environment variable E.
Specifically, a database is queried according to a code construction command, and a first adjustment rule corresponding to the code construction command is obtained; the adjusting each environmental variable in the code construction command according to the first adjustment rule may, for example, query a database according to the code construction command W to obtain an adjustment rule of all environmental variables in the code construction command W, and if all environmental variables in the code construction command W are the environmental variable D and the environmental variable E, obtain an adjustment rule of the environmental variable D and an adjustment rule of the environmental variable E, adjust the environmental variable D in the code construction command W according to the adjustment rule of the environmental variable D and adjust the environmental variable E in the code construction command W according to the adjustment rule of the environmental variable E.
In one embodiment, adjusting the respective environment variables in the code build command according to the first adjustment rule includes:
if the code construction command comprises a time stamp, setting the system time corresponding to the code construction command as fixed time;
if the code construction command comprises a random number, constructing a target file system, and replacing the file system corresponding to the code construction command with the target file system so that the file to be archived has fixed node information;
and if the code construction command comprises a file list sequence, sequencing at least one execution result corresponding to the code construction command by using a sequencing tool.
Wherein, the code construction command can include at least one environment variable of a time stamp (environment variable), a random number (environment variable) and a file list order (environment variable).
Specifically, if the code construction command includes a time stamp, setting a system time corresponding to the code construction command as a fixed time; if the code construction command comprises a random number, constructing a target file system, and replacing the file system corresponding to the code construction command with the target file system so that the file to be archived has fixed node information; if the code construction command includes a file list sequence, at least one execution result corresponding to the code construction command is ordered by using an ordering tool, for example, if the code construction command includes only a timestamp, the system time corresponding to the code construction command is set as a fixed time; if the code construction command comprises a time stamp and a random number, setting the system time corresponding to the code construction command as fixed time, constructing a target file system, and replacing the file system corresponding to the code construction command with the target file system so as to enable the file to be archived to have fixed node information; if the code construction command includes a time stamp, a random number and a file list sequence, the system time corresponding to the code construction command is set to be a fixed time, a target file system is constructed, the file system corresponding to the code construction command is replaced by the target file system, so that the file to be archived has fixed node information, and at least one execution result corresponding to the code construction command is ordered by using an ordering tool.
In one embodiment, adjusting the code build command according to an environmental variable in the code build command includes:
inquiring a database according to the environment variables corresponding to the at least two test construction commands to obtain a second adjustment rule corresponding to the environment variables;
and adjusting the environment variable according to the second adjustment rule.
The database may be, for example, a database including the adjustment rules of the environment variable D and the environment variable D, the adjustment rules of the environment variable R and the environment variable R, and the adjustment rules of the environment variable H and the environment variable H.
The second adjustment rule may include an adjustment rule of an environment variable corresponding to the test construction command.
Specifically, the environment variable which causes inconsistent execution results is determined in advance according to the test construction command, and the environment variable can be one or more, for example, the environment variable which causes inconsistent execution results is determined to be the environment variable D according to the test construction command, then the database is queried to obtain an adjustment rule of the environment variable D, and the environment variable D is adjusted according to the adjustment rule of the environment variable D.
It should be noted that the code construction command may include a plurality of environment variables, and the environment variable that causes the inconsistent execution result may be one or a plurality of environment variables, for example, the code construction command includes environment variable Q, environment variable D, and environment variable R, and the environment variable that causes the inconsistent execution result is environment variable Q; the code construction command also comprises an environment variable Q and an environment variable D, so that the environment variables with inconsistent execution results are the environment variable Q and the environment variable D; if the environment variables which cause inconsistent execution results are the environment variable Q and the environment variable D, inquiring a database according to the environment variable Q to obtain an adjustment rule of the environment variable Q, and inquiring the database according to the environment variable D to obtain an adjustment rule of the environment variable D.
In a specific example, if the code construction command includes an environment variable Q, an environment variable D and an environment variable R, a test construction command N1 is generated according to the environment variable Q1 in the code construction command, a test construction command N2 is generated according to the environment variable Q2 in the code construction command, a test construction command V1 is generated according to the environment variable D1 in the code construction command, a test construction command V2 is generated according to the environment variable D2 in the code construction command, a test construction command U1 is generated according to the environment variable R1 in the code construction command, a test construction command U2 is generated according to the environment variable R2 in the code construction command, if the execution result of the test construction command N1 and the execution result of the test construction command N2 are consistent, the execution result of the test construction command V1 and the test construction command V2 are inconsistent, the execution result of the test construction command U1 and the test construction command U2 are consistent, an adjustment rule of the environment variable D is obtained by querying a database according to the environment variable D, and the adjustment rule of the environment variable D is adjusted according to the adjustment rule of the environment variable D.
In one embodiment, adjusting the environmental variable according to the second adjustment rule includes:
and if the environment variable in the code construction command is a time stamp, setting the system time corresponding to the code construction command as fixed time.
The fixed time may be set by a system or set by a person, which is not limited in the embodiment of the present invention.
Specifically, if the environment variable in the code construction command is a timestamp, the system time corresponding to the code construction command is set to a fixed time, for example, it may be that a non-reproducible construction reason caused by the timestamp in the engineering is detected: for example, when a tar tool generates a compressed package (when a tar command generates a compressed package file, a timestamp is generated in a file header according to the current time of a system; and finding out a corresponding adjustment rule according to the query database, for example, a command of generating a compressed package file by the tar, constructing a new tar command by the monitoring module, setting the system time for executing the tar command as a fixed time, and enabling the compressed package file generated by executing the same tar command for multiple times to keep binary consistency.
In one embodiment, adjusting the environmental variable according to the second adjustment rule includes:
if the environment variable in the code construction command is a random number, constructing a target file system;
and replacing the file system corresponding to the code construction command with a target file system so that the file to be archived has fixed node information.
Specifically, if the environment variable in the code construction command is a random number, constructing a target file system; the file system corresponding to the code construction command is replaced by a target file system, so that the file to be archived has fixed node information, for example, the irreproducible construction reason caused by random numbers in engineering is detected: for example, when generating a cpio file, an inode of the file packed into the cpio is a random number; and finding a corresponding adjustment rule according to the query database, such as generating an inode random problem of a packaged file in the cpio (constructing an independent file system, such as ext4, and the like, copying the packaged file into the independent file system in sequence, so that the packaged file has a fixed inode value, and then generating the cpio file in the independent file system, so that the cpio files generated in multiple constructions keep binary consistency).
In one embodiment, adjusting the environmental variable according to the second adjustment rule includes:
and if the environment variable in the code construction command is the file list order, sequencing at least one execution result corresponding to the code construction command by using a sequencing tool.
Specifically, if the environment variable in the code construction command is a file list order, the at least one execution result corresponding to the code construction command is sequenced by using a sequencing tool, for example, it may be that a non-reproducible construction caused by the file list order in the engineering is detected: such as find commands, the order of the multiple results found is not fixed; and finding a corresponding adjustment method, such as a find command, through a search database, and sequencing the found multiple results by using a sort tool such as a sort, so that the found multiple results of executing the find command are consistent.
In one embodiment, generating at least two test build commands from different environment variables in the code build commands includes:
tracking a code construction process and monitoring a code construction command in the code construction process;
when the code construction command is acquired, suspending the execution of the code construction command;
At least two test build commands are generated from different environment variables in the code build commands.
In one specific example, tracking the entire engineering construction process; monitoring code construction commands in the engineering construction process; suspending execution of the current code build command; building two test building commands, wherein the two test building commands set different environment variables (such as user names, system time and other factors possibly causing irreproducible building); sequentially executing two newly constructed test construction commands; comparing the outputs of the two test build commands, and if the outputs are inconsistent, determining the current code build command as a code build command that is not reproducible to the build.
In another specific example, the build process of the ptrace project is monitored (not limited to); detecting an environment variable which is not reproducible and constructed in the engineering; finding an adjustment rule corresponding to the environment variable according to the database; adjusting the environment variable according to the adjustment rule to obtain a new code construction command; replacing the original code build command with a new code build command; executing the new code build command.
The method prepares an adjustment rule for an environment variable which causes nonrepeatable construction in advance, and stores the adjustment rule into a database; after the new adjustment rule is obtained, the new adjustment rule is added into the database, and the database is updated in real time.
The application can reuse the existing analysis nonreciprocal construction result, automatically locate and repair the environment variable which causes nonreciprocal construction in the engineering construction process under the condition of not modifying the engineering source code, and ensure the binary consistency of repeated construction, thereby conveniently completing the binary equivalent audit of the code.
In another specific example, the construction process of an engineering is monitored; the irreproducible build cause in the project due to the time stamp is detected: for example, when a tar tool generates a compressed package (when a tar command generates a compressed package file, a timestamp is generated in a file header according to the current time of a system; searching a database according to the time stamp to find an adjustment rule corresponding to the time stamp, if a command of generating a compressed package file by tar, constructing a new tar command by a monitoring module, setting the system time for executing the tar command as a fixed time, and executing the compressed package file generated by the same tar command for multiple times can keep binary consistency; and adjusting the time stamp according to the adjustment rule to obtain an adjusted code construction command, and executing the adjusted code construction command on the code.
In another specific example, the construction process of an engineering is monitored; the irreproducible construction cause due to random numbers in the engineering is detected: for example, when generating a cpio file, an inode of the file packed into the cpio is a random number; finding an adjustment rule corresponding to the random number according to the random number query database, such as generating an inode random problem of a packaged file in the cpio (constructing an independent file system, such as ext4, and the like, copying the packaged file into the independent file system in sequence, so that the packaged file has a fixed inode value, then generating the cpio file in the independent file system, and keeping binary consistency of the cpio file generated during multiple construction); and adjusting the code construction command according to the adjustment rule, and executing the adjusted code construction command on the code.
In another specific example, the construction process of an engineering is monitored; detecting nonrenewable construction in engineering due to file list order: such as find commands, the order of the multiple results found is not fixed; searching a database according to the file list breaking sequence to find an adjustment rule corresponding to the file list sequence, (if find command, sort the found results by using sort tools such as sort, etc., then the found results of find command are consistent; adjusting the code construction command according to the adjustment rule; and executing the adjusted code construction command on the code.
In another specific example, engineering construction is initiated; monitoring engineering construction; monitoring code construction commands in the engineering construction process; suspending execution of the current code build command; building two test building commands (setting different environment variables, enabling the two commands to use different system time, user name and other factors which possibly cause irreproducible building); executing a first test construction command; executing a second test build command; comparing the execution results of the two test construction commands, and if the binary numbers are inconsistent, locating a nonrepeatable construction reason; resume execution of the pause command; detecting a construction process, and if the construction is not completed, jumping to execute a code construction command step in the construction process of the monitoring engineering; otherwise, ending the flow.
In another specific example, a database is established that stores environment variables and adjustment rules for the environment variables that can cause multiple build binary inconsistencies; starting engineering construction; monitoring engineering construction; detecting an environmental variable that causes non-reproducibility; acquiring an adjustment rule of the detected irreproducible environment variable according to the database; and adjusting the environment variable according to the adjustment rule to obtain an adjusted code construction command. Executing the adjusted code construction command, detecting the construction process, and if the construction is not completed, jumping to execute the code construction command step in the monitoring engineering construction process; otherwise, ending the flow.
The present application provides a code construction device, fig. 2 is a schematic structural diagram of the code construction device provided by the present application, the device is configured in a computer device, referring to fig. 2, the device includes:
a generating module 21, configured to generate at least two test construction commands according to different environment variables in the code construction commands;
the adjustment module 22 is configured to execute the at least two test construction commands on the code respectively, and if the execution results are inconsistent, adjust the code construction command according to the environment variable in the code construction command;
and the execution module 23 is used for executing the adjusted code construction command on the code.
The code construction device provided in this embodiment is used to implement the code construction method in this embodiment, and the implementation principle and technical effects of the code construction device provided in this embodiment are similar to those of the code construction method in this embodiment, and are not described here again.
On the basis of the above embodiments, modified embodiments of the above embodiments are proposed, and it is to be noted here that only the differences from the above embodiments are described in the modified embodiments for the sake of brevity of description.
In one embodiment, the adjustment module 22 is specifically configured to:
Inquiring a database according to the code construction command to obtain a first adjustment rule corresponding to the code construction command;
and adjusting each environment variable in the code construction command according to the first adjustment rule.
In one embodiment, the adjustment module 22 is specifically configured to:
inquiring a database according to the environment variable in the code construction command to obtain a second adjustment rule corresponding to the environment variable;
and adjusting the environment variable according to the second adjustment rule.
In one embodiment, the adjustment module 22 is specifically configured to:
and if the environment variable in the code construction command is a time stamp, setting the system time corresponding to the code construction command as fixed time.
In one embodiment, the adjustment module 22 is specifically configured to:
if the environment variable in the code construction command is a random number, constructing a target file system;
and replacing the file system corresponding to the code construction command with a target file system so that the file to be archived has fixed node information.
In one embodiment, the adjustment module 22 is specifically configured to:
and if the environment variable in the code construction command is the file list order, sequencing at least one execution result corresponding to the code construction command by using a sequencing tool.
In one embodiment, the adjustment module 22 is specifically configured to:
tracking a code construction process and monitoring a code construction command in the code construction process;
when the code construction command is acquired, suspending the execution of the code construction command;
at least two test build commands are generated from different environment variables in the code build commands.
The application provides a code construction device, which comprises: the generating module is used for generating at least two test construction commands according to different environment variables in the code construction commands; the adjusting module is used for respectively executing the at least two test construction commands on the codes, and adjusting the code construction commands according to environment variables in the code construction commands if the execution results are inconsistent; the execution module is used for executing the adjusted code construction command on the code, multiplexing the existing analysis irreproducible construction result, automatically finding, repairing or avoiding the factors causing the irreproducible construction in the engineering construction process without manually modifying the engineering source code by a user, and realizing the binary consistency of the repeated construction result, thereby improving the efficiency of the code effectiveness audit.
The present application provides an apparatus, fig. 3 is a schematic structural diagram of an apparatus provided by the present application, as shown in fig. 3, where the apparatus provided by the present application includes one or more processors 51 and a storage device 52; the number of processors 51 in the device may be one or more, one processor 51 being taken as an example in fig. 3; the storage device 52 is used for storing one or more programs; the one or more programs are executed by the one or more processors 51 such that the one or more processors 51 implement the method as described in fig. 1 in an embodiment of the present application.
The apparatus further comprises: a communication device 53, an input device 54 and an output device 55.
The processor 51, the storage means 52, the communication means 53, the input means 54 and the output means 55 in the device may be connected by a bus or by other means, in fig. 3 by way of example.
The input device 54 may be used to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the apparatus. The output means 55 may comprise a display device such as a display screen.
The communication device 53 may include a receiver and a transmitter. The communication device 53 is provided to perform information transmission and reception communication according to the control of the processor 51. The information includes, but is not limited to, uplink grant information.
The storage device 52, which is a computer-readable storage medium, may be configured to store a software program, a computer-executable program, and modules, such as program instructions/modules (e.g., the generation module 21, the adjustment module 22, and the execution module 23 in the code construction device) corresponding to the code construction method described in fig. 1 according to the embodiment of the present application. Storage device 52 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functionality; the storage data area may store data created according to the use of the device, etc. In addition, the storage 52 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, storage 52 may further include memory located remotely from processor 51, which may be connected to the device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The embodiment of the application also provides a storage medium, which stores a computer program, and the computer program realizes the code construction method according to the embodiment of the application when being executed by a processor, and the method comprises the following steps:
generating at least two test construction commands according to different environment variables in the code construction commands;
executing the at least two test construction commands on the codes respectively, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands;
and executing the adjusted code construction command on the code.
The computer storage media of embodiments of the application may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access Memory (Random Access Memory, RAM), a Read-Only Memory (ROM), an erasable programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), a flash Memory, an optical fiber, a portable CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. A computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to: electromagnetic signals, optical signals, or any suitable combination of the preceding. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, radio Frequency (RF), and the like, or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The foregoing description is only exemplary embodiments of the application and is not intended to limit the scope of the application.
It will be appreciated by those skilled in the art that the term user equipment encompasses any suitable type of wireless user equipment, such as mobile telephones, portable data processing devices, portable web browsers, or car-mounted mobile stations.
In general, the various embodiments of the application may be implemented in hardware or special purpose circuits, software, logic or any combination thereof. For example, some aspects may be implemented in hardware, while other aspects may be implemented in firmware or software which may be executed by a controller, microprocessor or other computing device, although the application is not limited thereto.
Embodiments of the application may be implemented by a data processor of a mobile device executing computer program instructions, e.g. in a processor entity, either in hardware, or in a combination of software and hardware. The computer program instructions may be assembly instructions, instruction set architecture (Instruction Set Architecture, ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages.
The block diagrams of any of the logic flows in the figures of this application may represent program steps, or may represent interconnected logic circuits, modules, and functions, or may represent a combination of program steps and logic circuits, modules, and functions. The computer program may be stored on a memory. The Memory may be of any type suitable to the local technical environment and may be implemented using any suitable data storage technology, such as, but not limited to, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), optical Memory devices and systems (digital versatile Disk (Digital Video Disc, DVD) or Compact Disk (CD)), and the like. The computer readable medium may include a non-transitory storage medium. The data processor may be of any type suitable to the local technical environment, such as, but not limited to, general purpose computers, special purpose computers, microprocessors, digital signal processors (Digital Signal Processing, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), programmable logic devices (Field-Programmable Gate Array, FGPA), and processors based on a multi-core processor architecture.
The foregoing detailed description of exemplary embodiments of the application has been provided by way of exemplary and non-limiting examples. Various modifications and adaptations to the above embodiments may become apparent to those skilled in the art without departing from the scope of the application, which is defined in the accompanying drawings and claims. Accordingly, the proper scope of the application is to be determined according to the claims.

Claims (11)

1. A code construction method, comprising:
generating at least two test construction commands according to different environment variables in the code construction commands;
executing the at least two test construction commands on the codes respectively, and if the execution results are inconsistent, adjusting the code construction commands according to environment variables in the code construction commands;
and executing the adjusted code construction command on the code.
2. The method of claim 1, wherein adjusting the code build command based on environmental variables in the code build command comprises:
inquiring a database according to the code construction command to obtain a first adjustment rule corresponding to the code construction command;
and adjusting each environment variable in the code construction command according to the first adjustment rule.
3. The method of claim 2, wherein adjusting the respective environment variables in the code build command according to the first adjustment rule comprises:
if the code construction command comprises a time stamp, setting the system time corresponding to the code construction command as fixed time;
if the code construction command comprises a random number, constructing a target file system, and replacing the file system corresponding to the code construction command with the target file system so that the file to be archived has fixed node information;
and if the code construction command comprises a file list sequence, sequencing at least one execution result corresponding to the code construction command by using a sequencing tool.
4. The method of claim 1, wherein adjusting the code build command based on environmental variables in the code build command comprises:
inquiring a database according to the environment variables corresponding to the at least two test construction commands to obtain a second adjustment rule corresponding to the environment variables;
and adjusting the environment variable according to the second adjustment rule.
5. The method of claim 4, wherein adjusting the environmental variable according to the second adjustment rule comprises:
And if the environment variable in the code construction command is a time stamp, setting the system time corresponding to the code construction command as fixed time.
6. The method of claim 4, wherein adjusting the environmental variable according to the second adjustment rule comprises:
if the environment variable in the code construction command is a random number, constructing a target file system;
and replacing the file system corresponding to the code construction command with a target file system so that the file to be archived has fixed node information.
7. The method of claim 4, wherein adjusting the environmental variable according to the second adjustment rule comprises:
and if the environment variable in the code construction command is the file list order, sequencing at least one execution result corresponding to the code construction command by using a sequencing tool.
8. The method of claim 1, wherein generating at least two test build commands from different environment variables in a code build command comprises:
tracking a code construction process and monitoring a code construction command in the code construction process;
when the code construction command is acquired, suspending the execution of the code construction command;
At least two test build commands are generated from different environment variables in the code build commands.
9. A code construction apparatus, comprising:
the generating module is used for generating at least two test construction commands according to different environment variables in the code construction commands;
the adjusting module is used for respectively executing the at least two test construction commands on the codes, and adjusting the code construction commands according to environment variables in the code construction commands if the execution results are inconsistent;
and the execution module is used for executing the adjusted code construction command on the code.
10. An apparatus, comprising:
one or more processors;
a storage means for storing one or more programs;
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-8.
11. A storage medium storing a computer program which, when executed by a processor, implements the method of any one of claims 1-8.
CN202010543411.0A 2020-06-15 2020-06-15 Code construction method, device, equipment and storage medium Active CN112799649B (en)

Priority Applications (5)

Application Number Priority Date Filing Date Title
CN202010543411.0A CN112799649B (en) 2020-06-15 2020-06-15 Code construction method, device, equipment and storage medium
PCT/CN2021/099361 WO2021254243A1 (en) 2020-06-15 2021-06-10 Code construction method and apparatus, device, and storage medium
EP21826277.2A EP4167076A4 (en) 2020-06-15 2021-06-10 Code construction method and apparatus, device, and storage medium
JP2022554637A JP7433464B2 (en) 2020-06-15 2021-06-10 Code construction methods, apparatus, devices and storage media
US18/010,014 US20230251952A1 (en) 2020-06-15 2021-06-10 Code construction method and device, apparatus, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010543411.0A CN112799649B (en) 2020-06-15 2020-06-15 Code construction method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112799649A CN112799649A (en) 2021-05-14
CN112799649B true CN112799649B (en) 2023-09-12

Family

ID=75806489

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010543411.0A Active CN112799649B (en) 2020-06-15 2020-06-15 Code construction method, device, equipment and storage medium

Country Status (5)

Country Link
US (1) US20230251952A1 (en)
EP (1) EP4167076A4 (en)
JP (1) JP7433464B2 (en)
CN (1) CN112799649B (en)
WO (1) WO2021254243A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112799649B (en) * 2020-06-15 2023-09-12 中兴通讯股份有限公司 Code construction method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887365A (en) * 2009-05-15 2010-11-17 国际商业机器公司 Be used to construct method and system based on the executable code of the application of assembly
CN103140838A (en) * 2010-10-27 2013-06-05 株式会社日立制作所 Method of converting source code and source code conversion program
CN104375875A (en) * 2013-08-15 2015-02-25 国际商业机器公司 Method for compiler optimization of applications and compiler
CN108052344A (en) * 2017-12-11 2018-05-18 北京奇虎科技有限公司 A kind of kernel difference detecting method and device
CN110941424A (en) * 2019-11-28 2020-03-31 Oppo广东移动通信有限公司 Compiling parameter optimization method and device and electronic equipment

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH04337846A (en) * 1991-05-15 1992-11-25 Nec Corp Inspection method for operating system
US7404110B1 (en) * 2004-12-01 2008-07-22 Advanced Micro Devices, Inc. Method and system for self-assembling instruction opcodes for a custom random functional test of a microprocessor
CN101470620B (en) * 2007-12-29 2013-01-16 珠海金山软件有限公司 Method and apparatus for judging PE file source code consistency
JP5052472B2 (en) * 2008-09-30 2012-10-17 株式会社野村総合研究所 Program setting information switching system and switching method
US8819652B2 (en) * 2010-07-30 2014-08-26 General Electric Company System and method for parametric system evaluation
JP6561212B2 (en) * 2016-09-01 2019-08-14 株式会社日立製作所 Inquiry handling system and method
CN112799649B (en) * 2020-06-15 2023-09-12 中兴通讯股份有限公司 Code construction method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101887365A (en) * 2009-05-15 2010-11-17 国际商业机器公司 Be used to construct method and system based on the executable code of the application of assembly
CN103140838A (en) * 2010-10-27 2013-06-05 株式会社日立制作所 Method of converting source code and source code conversion program
CN104375875A (en) * 2013-08-15 2015-02-25 国际商业机器公司 Method for compiler optimization of applications and compiler
CN108052344A (en) * 2017-12-11 2018-05-18 北京奇虎科技有限公司 A kind of kernel difference detecting method and device
CN110941424A (en) * 2019-11-28 2020-03-31 Oppo广东移动通信有限公司 Compiling parameter optimization method and device and electronic equipment

Also Published As

Publication number Publication date
JP7433464B2 (en) 2024-02-19
US20230251952A1 (en) 2023-08-10
EP4167076A1 (en) 2023-04-19
WO2021254243A1 (en) 2021-12-23
CN112799649A (en) 2021-05-14
EP4167076A4 (en) 2023-11-22
JP2023517614A (en) 2023-04-26

Similar Documents

Publication Publication Date Title
CN107273286B (en) Scene automatic test platform and method for task application
US20150026664A1 (en) Method and system for automated test case selection
CN108845940B (en) Enterprise-level information system automatic function testing method and system
CN109359094B (en) Distributed system log full-link tracking method and device
CN109960653A (en) Regression testing method, device, equipment and storage medium
CN111104304A (en) Multi-task scene performance testing method, storage medium, electronic device and system
CN106407102B (en) Fuzzy testing method, device and system for application program
CN111190827A (en) Interface automation test method and device, storage medium and electronic equipment
CN104750601A (en) Test method and test device
CN112799649B (en) Code construction method, device, equipment and storage medium
CN106557419B (en) Program testing method and device
CN115335821A (en) Offloading statistics collection
CN106682210B (en) Log file query method and device
CN111552521A (en) Application data reporting method, device, server and storage medium
CN114826768A (en) Cloud vulnerability processing method applying big data and AI technology and AI analysis system
CN113886221B (en) Test script generation method and device, storage medium and electronic equipment
CN115576831A (en) Test case recommendation method, device, equipment and storage medium
CN113688134B (en) Visual variable management method, system and equipment based on multidimensional data
CN110795259A (en) Method and device for analyzing application collapse
CN112579472B (en) Automatic generation method and device for test cases
CN113126998A (en) Incremental source code acquisition method and device, electronic equipment and storage medium
CN113821486A (en) Method and device for determining dependency relationship between pod libraries and electronic equipment
CN107291610A (en) Testing case management and device
CN114531335B (en) Method, equipment and device for detecting management information base data
CN117294487A (en) Network vulnerability management and control method, management and control device and vulnerability management and control system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant