CN116932305B - Test file generation method and device, electronic equipment and storage medium - Google Patents

Test file generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116932305B
CN116932305B CN202311196843.9A CN202311196843A CN116932305B CN 116932305 B CN116932305 B CN 116932305B CN 202311196843 A CN202311196843 A CN 202311196843A CN 116932305 B CN116932305 B CN 116932305B
Authority
CN
China
Prior art keywords
command
subcommands
original
target
configuration
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
CN202311196843.9A
Other languages
Chinese (zh)
Other versions
CN116932305A (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.)
New H3C Information Technologies Co Ltd
Original Assignee
New H3C Information Technologies Co Ltd
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 New H3C Information Technologies Co Ltd filed Critical New H3C Information Technologies Co Ltd
Priority to CN202311196843.9A priority Critical patent/CN116932305B/en
Publication of CN116932305A publication Critical patent/CN116932305A/en
Application granted granted Critical
Publication of CN116932305B publication Critical patent/CN116932305B/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/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2289Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing by configuration test
    • 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)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Tests Of Electronic Circuits (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a test file generation method, a device, electronic equipment and a storage medium, and relates to the technical field of networks, wherein the method comprises the following steps: acquiring a target configuration file of the physical equipment, wherein the target configuration file comprises a plurality of commands; respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command; assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command; and generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, wherein the test file is used for testing the physical equipment. By applying the technical scheme provided by the embodiment of the application, the time of the physical equipment occupied by the test can be reduced, the labor cost is reduced, and the quality of the physical equipment is improved.

Description

Test file generation method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of network technologies, and in particular, to a method and apparatus for generating a test file, an electronic device, and a storage medium.
Background
In order to avoid the online problem caused by physical equipment such as a server, a switch and the like, the physical equipment needs to be tested in a laboratory environment, and the problem in the physical equipment is eliminated. For physical devices such as servers and switches, different hardware, such as chips, memories, hard disks, array cards, network cards, etc., needs to be configured according to different services in order to adapt to various service scenarios and meet various customer demands. Because the hardware configuration or specification of each physical device is different, the range of the configuration parameters of each physical device cannot be unified, so that a tester needs to assign values to the configuration parameters of each command of each physical device respectively to obtain a test file, and the test file is run on the physical device, thereby achieving the purpose of testing the physical device.
However, the number of physical devices is huge, the configuration of each physical device is complex, the number of commands and invalid information included in one physical device are also huge, the time consumed by a tester to acquire the commands of each physical device and assign the configuration parameters of each command of each physical device is huge, the time consumed by testing the occupied physical device is too long, and the labor cost is high. In addition, a command is composed of a plurality of configuration parameters, for the command, the configuration parameters have a plurality of combination modes, after a tester assigns a value to the configuration parameters of the command, only one combination mode of the configuration parameters can be tested when the physical equipment runs the corresponding test file, so that the test of the physical equipment cannot cover all the combination modes of the configuration parameters corresponding to the command, and further, certain problems of the physical equipment cannot be measured in a laboratory environment, and part of product quality problems are exposed to the current network.
Disclosure of Invention
The embodiment of the application aims to provide a test file generation method, a device, electronic equipment and a storage medium, so as to improve command coverage rate, improve test efficiency, reduce the time of physical equipment occupied by test, reduce labor cost and further improve the quality of the physical equipment. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a method for generating a test file, where the method includes:
acquiring a target configuration file of physical equipment, wherein the target configuration file comprises a plurality of commands;
respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command;
assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command;
and generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, wherein the test file is used for testing the physical equipment.
In some embodiments, the step of obtaining the target configuration file of the physical device includes:
acquiring an original configuration file of the physical equipment;
and removing dirty data and repeated commands in the original configuration file to obtain a target configuration file.
In some embodiments, the step of parsing the tree structure of each command to obtain a plurality of original subcommands corresponding to each command includes:
converting the command symbols in each command into mathematical symbols according to the mapping relation between the preset command symbols and the mathematical symbols to obtain a corresponding prefix expression of each command;
converting the prefix expression corresponding to each command into the suffix expression corresponding to each command to obtain an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or mathematical symbol of the command;
and carrying out mathematical calculation on the configuration parameters in the element queue corresponding to each command based on the mathematical symbols in the element queue corresponding to each command to obtain a plurality of original subcommands corresponding to each command.
In some embodiments, the step of mathematically calculating the configuration parameters in the element queue corresponding to each command based on the mathematical symbols in the element queue corresponding to each command to obtain a plurality of original subcommands corresponding to each command includes:
for each command, traversing each element of an element queue corresponding to the command from the head of the element queue;
When the traversed current element is a configuration parameter, writing the current element into a first stack;
when the traversed current element is a mathematical symbol, popping up two elements at the tail of the first stack; calculating the two elements and the current element to obtain a calculation result; writing the calculation result as an element into the first stack;
and when all the elements of the element queue are traversed, obtaining a plurality of original subcommands corresponding to the command.
In some embodiments, the step of parsing the tree structure of each command to obtain a plurality of original subcommands corresponding to each command includes:
acquiring a plurality of leaf nodes included in each command by utilizing a sliding window;
converting a plurality of leaf nodes included in each command into a dictionary corresponding to each command, wherein the dictionary comprises a plurality of partitions, one element included in each partition is a lower-level partition or a leaf node, and the logic relations among the elements in one partition are the same;
converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relation among the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command;
Traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
In some embodiments, the step of assigning the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain the plurality of target subcommands corresponding to each command includes:
removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command;
and respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
In a second aspect, an embodiment of the present application provides a test file generating apparatus, including:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target configuration file of physical equipment, and the target configuration file comprises a plurality of commands;
the analysis module is used for respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command;
the assignment module is used for assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command;
And the generation module is used for generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, and the test file is used for testing the physical equipment.
In some embodiments, the acquiring module is specifically configured to:
acquiring an original configuration file of the physical equipment;
and removing dirty data and repeated commands in the original configuration file to obtain a target configuration file.
In some embodiments, the parsing module includes:
the first conversion sub-module is used for converting the command symbols in each command into mathematical symbols according to the mapping relation between the preset command symbols and the mathematical symbols to obtain a corresponding intermediate expression of each command;
the second conversion sub-module is used for converting the intermediate expression corresponding to each command into the suffix expression corresponding to each command to obtain an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or a mathematical symbol of the command;
the computing sub-module is used for carrying out mathematical computation on the configuration parameters in the element queue corresponding to each command based on the mathematical symbols in the element queue corresponding to each command, so as to obtain a plurality of original sub-commands corresponding to each command.
In some embodiments, the computing submodule is specifically configured to:
for each command, traversing each element of an element queue corresponding to the command from the head of the element queue;
when the traversed current element is a configuration parameter, writing the current element into a first stack;
when the traversed current element is a mathematical symbol, popping up two elements at the tail of the first stack; calculating the two elements and the current element to obtain a calculation result; writing the calculation result as an element into the first stack;
and when all the elements of the element queue are traversed, obtaining a plurality of original subcommands corresponding to the command.
In some embodiments, the parsing module is specifically configured to:
acquiring a plurality of leaf nodes included in each command by utilizing a sliding window;
converting a plurality of leaf nodes included in each command into a dictionary corresponding to each command, wherein the dictionary comprises a plurality of partitions, one element included in each partition is a lower-level partition or a leaf node, and the logic relations among the elements in one partition are the same;
converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relation among the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command;
Traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
In some embodiments, the assignment module is specifically configured to:
removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command;
and respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the first aspects when executing a program stored on a memory.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium having a computer program stored therein, which when executed by a processor, implements the method steps of any of the first aspects.
The embodiment of the application has the beneficial effects that:
in the technical scheme provided by the embodiment of the application, after the target configuration file of one physical device is obtained, the plurality of commands included in the target configuration file are analyzed according to the tree structure of the commands, so that all original subcommands corresponding to each command can be obtained, assignment operation is carried out on the configuration parameters of the original subcommands, the test file corresponding to each command can be generated, the test file is operated on the physical device, and the physical device is tested. Compared with the mode of manually acquiring the commands and assigning the configuration parameters of the commands, in the embodiment of the application, under the conditions that the number of the physical devices is huge, the configuration of each physical device is complex, and the number of the commands and the invalid information included in one physical device are also huge, a plurality of test files corresponding to the plurality of commands can be automatically generated, the manual participation is not needed, the labor cost is reduced, the time for generating the test files is reduced, and the time of configuring the physical devices occupied by the test is reduced; in addition, the multiple commands included in the target configuration file are analyzed, all the combination modes of the configuration parameters included in each command, namely subcommands, can be obtained, so that the physical equipment is tested by the test file generated by all the combination modes of the configuration parameters, all the combination modes of the configuration parameters corresponding to the commands can be covered, the command coverage rate is improved, the problem of the physical equipment can be measured in a laboratory environment, the problem of the physical equipment is solved, and the quality of the physical equipment is improved.
Of course, it is not necessary for any one product or method of practicing the application to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the application, and other embodiments may be obtained according to these drawings to those skilled in the art.
FIG. 1 is a schematic flow chart of a test file generation method according to an embodiment of the present application;
fig. 2 is a schematic diagram of a refinement flow of step S11 according to an embodiment of the present application;
fig. 3 is a schematic diagram of a first refinement flow of step S12 according to an embodiment of the present application;
fig. 4 is a schematic diagram of a refinement flow of step S33 according to an embodiment of the present application;
fig. 5 is a schematic diagram of a second refinement flow of step S12 according to an embodiment of the present application;
FIG. 6a is a schematic diagram of a tree structure of a command according to an embodiment of the present application;
FIG. 6b is a diagram illustrating a dictionary form of a command according to an embodiment of the present application;
FIG. 6c is a schematic diagram of a list of commands according to an embodiment of the present application;
FIG. 7 is a schematic structural diagram of a test file generating device according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. Based on the embodiments of the present application, all other embodiments obtained by the person skilled in the art based on the present application are included in the scope of protection of the present application.
With the rise of new technologies such as the internet of things and cloud computing, data is in explosive growth, a large amount of data needs a large amount of servers/switches to support, and therefore, the demands of the servers and the switches are also promoted. In order to avoid the online problem caused by physical equipment such as a server, a switch and the like, the physical equipment needs to be tested in a laboratory environment, and the problem in the physical equipment is eliminated. For the physical devices such as the server and the switch, different hardware such as a chip, a memory, a hard disk, an array card, a network card and the like needs to be configured according to different services in order to adapt to various service scenes and meet various customer demands. Because the hardware configuration or specification of each physical device is different, the range of the configuration parameters of each physical device cannot be unified, so that a tester needs to assign values to the configuration parameters of each command of each physical device respectively to obtain a test file, and the test file is run on the physical device, thereby achieving the purpose of testing the physical device.
However, the number of physical devices is huge, the configuration of each physical device is complex, the number of commands and invalid information included in one physical device are also huge, the time consumed by a tester to acquire the commands of each physical device and assign the configuration parameters of each command of each physical device is huge, the time consumed by testing the occupied physical device is too long, and the labor cost is high. In addition, a command is composed of a plurality of configuration parameters, for the command, the configuration parameters have a plurality of combination modes, after a tester assigns a value to the configuration parameters of the command, only one combination mode of the configuration parameters can be tested when the physical equipment runs the corresponding test file, so that the test of the physical equipment cannot cover all the combination modes of the configuration parameters corresponding to the command, and further, certain problems of the physical equipment cannot be measured in a laboratory environment, and part of product quality problems are exposed to the current network.
In order to solve the above problems, an embodiment of the present application provides a test file generating method, as shown in fig. 1. The method can be applied to electronic equipment such as a server, a cluster and the like, the electronic equipment can also be physical equipment to be tested, and the electronic equipment is taken as an execution main body for the convenience of understanding and is not limited.
Referring to fig. 1, fig. 1 is a schematic flow chart of a test file generating method according to an embodiment of the present application, where the method includes the following steps:
step S11, a target configuration file of the physical equipment is obtained, wherein the target configuration file comprises a plurality of commands;
step S12, respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command;
step S13, assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command;
and S14, generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, wherein the test file is used for testing the physical equipment.
In the technical scheme provided by the embodiment of the application, after the target configuration file of one physical device is obtained, the plurality of commands included in the target configuration file are analyzed according to the tree structure of the commands, so that all original subcommands corresponding to each command can be obtained, assignment operation is carried out on the configuration parameters of the original subcommands, the test file corresponding to each command can be generated, the test file is operated on the physical device, and the physical device is tested. Compared with the mode of manually acquiring the commands and assigning the configuration parameters of the commands, in the embodiment of the application, under the conditions that the number of the physical devices is huge, the configuration of each physical device is complex, and the number of the commands and invalid information included in one physical device are also huge, a plurality of test files corresponding to the plurality of commands can be automatically generated, manual participation is not needed, the labor cost is reduced, the time consumption for generating the test files is reduced, the command coverage rate is improved, and the time of the physical devices occupied by configuration test is reduced.
In addition, the multiple commands included in the target configuration file are analyzed, all combination modes of the configuration parameters included in each command, namely subcommands, can be obtained, so that the physical equipment is tested by the test file generated by all combination modes of the configuration parameters, all combination modes of the configuration parameters corresponding to the commands can be covered, the problem of the physical equipment can be detected in a laboratory environment, the problem of the physical equipment is solved, and the quality of the physical equipment is improved.
In the above step S11, the physical device may be a server, a switch, or the like. According to the service requirement, one or more of the hardware such as a chip, a memory, a hard disk, an array card, a network card and the like is configured in the physical equipment, and the specification of each hardware can be configured according to the actual requirement. The target configuration file is used for configuring the physical device so that the physical device realizes the required service. Multiple command sets may be included within the target profile, and one command set may include multiple commands. A command may include a combination of configuration parameters, a command consisting of one or more configuration parameters, one or more command symbols.
The configuration file is stored in a designated location in the physical device. For a physical device that needs to be tested, the electronic device may obtain a target profile for the physical device from a specified location in the physical device.
In the step S12, after the electronic device obtains the target configuration file, the electronic device obtains a plurality of commands from the target configuration file, and for each command, analyzes the command according to the tree structure, so as to obtain a plurality of original subcommands corresponding to the command. The original subcommand corresponding to the command is a combination mode of a plurality of configuration parameters in the command, and the original subcommand consists of one or a plurality of configuration parameters and one or a plurality of command symbols.
For example, one command is: { all| { STRING <3-21> } [ both|export|import ] [ evpn ] }, wherein, {, }, |, [, ] are command symbols, all, STRING <3-21>, both, export, import, evpn, NULL are configuration parameters, and NULL is a hidden configuration parameter, i.e., the command can be expressed as { all|{ { STRING <3-21> } [ both|export|import|NULL ] [ evpn|NULL ] }. The electronic device analyzes the tree structure of the command, and 9 original subcommands can be obtained, as follows: { all }; { STRING <3-21> both evpn }; { STRING <3-21> both NULL }; { STRING <3-21> export evpn }; { STRING <3-21> export NULL }; { STRING <3-21> import evpn }; { STRING <3-21> import NULL }; { STRING <3-21> NULL evpn }; { STRING <3-21> NULL NULL }.
In the embodiment of the application, the electronic device can analyze the tree structure of the command by adopting a sliding window method or a method based on a mathematical expression, and the specific analysis mode is described in detail below, and is not described in detail here. In the embodiment of the application, the electronic equipment can also adopt other methods to analyze the tree structure of the command, and the method is not limited.
In the above step S13, the configuration parameters included in the original subcommand have no specific values, and even if configured to the physical device, cannot be run on the physical device. The target subcommand is given a specific value so that the target subcommand can be run on the physical device for testing the physical device.
After the electronic device acquires the plurality of original subcommands corresponding to each command, the electronic device can select a parameter value from the range indicated by the configuration parameter for each configuration parameter in each original subcommand, assign the parameter value to the configuration parameter in the original subcommand, and obtain a target subcommand after all the configuration parameters in the original subcommand are assigned.
Taking the { STRING <3-21> both evpn } original subcommand in step S12 as an example. The range indicated by the configuration parameter STRING <3-21> is a character STRING with the length of 3-21. Any STRING of length 3-21 can be used as the parameter value of the configuration parameter STRING <3-21>. The electronic device may select a STRING, such as "abc", from STRINGs of length 3-21, and assign "abc" to STRING <3-21>. The range indicated by the configuration parameter both is both, the range indicated by the configuration parameter evpn is evpn, and the electronic device may select both, evpn as parameter values of the configuration parameter both and the configuration parameter evpn, respectively. At this point, the electronic device may acquire the target subcommand: { "abc" both evpn }.
In the embodiment of the application, a plurality of parameter values can be obtained in the range indicated by the configuration parameters, and a plurality of parameter values can be selected in the range indicated by the configuration parameters to form a plurality of target subcommands so as to improve the test precision.
Still taking the { STRING <3-21> both evpn } original subcommand in step S12 above as an example. The electronic device may select a plurality of STRINGs, such as "abc", "abd", "abcd", and "abcd", from STRINGs of lengths 3 to 21, and assign "abc", "abdd", "abcd" to STRING <3-21>, and combine parameter values of configuration parameter both and configuration parameter evpn to obtain 3 target subcommands respectively: { "abc" both evpn }, { "abd" both evpn }, { "abcd" both evpn }. At this time, the number of target subcommands is equal to or greater than the number of original subcommands.
In some embodiments, to keep the command concise, the command running rate is increased, and the test efficiency of the physical device is improved, the step S13 may be: removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command; and respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
Wherein the NULL configuration parameter is NULL. After the electronic device acquires an original subcommand, NULL in the original subcommand is removed, and a concise intermediate subcommand is obtained. For each configuration parameter in the intermediate subcommand, the electronic device may select a parameter value from the range indicated by the configuration parameter, assign the parameter value to the configuration parameter in the intermediate subcommand, and obtain the target subcommand.
For example, one original subcommand is { STRING <3-21> NULL NULL }, and the electronic equipment removes "NULL" in the original subcommand to obtain an intermediate subcommand { STRING <3-21> }. The range indicated by the configuration parameter STRING <3-21> is a character STRING with the length of 3-21. Any STRING of length 3-21 can be used as the parameter value of the configuration parameter STRING <3-21 >. The electronic device may select a STRING, such as "abc", from STRINGs of length 3-21, and assign "abc" to STRING <3-21> to obtain the target subcommand { "abc" }.
When the parameter value is selected, the electronic device preferentially selects the boundary value of the range indicated by the configuration parameter, such as the STRINGs with lengths of 3 and 21 in the range indicated by the STRING <3-21 >. Under the condition that the target subcommand containing the boundary value verifies that the physical equipment is normal, the physical equipment has no abnormality in high probability, the physical equipment has no problem in high probability during online operation, and under the condition that the requirement on the physical equipment is not high, only the target subcommand containing the boundary value can be generated, so that the number of the target subcommands can be greatly reduced, and the test efficiency is improved under the condition that certain test precision is ensured.
In the step S14, after the electronic device writes the multiple target subcommands corresponding to each command obtained in the step S13, the multiple target subcommands corresponding to the command may be written into one file for each command, to obtain the test file corresponding to the command. The test file may also be referred to as a configuration file,
the electronic device may send the test file corresponding to each command to the physical device, where the physical device runs the test file. Under the condition that all test files are successfully operated, the electronic equipment can determine that the physical equipment is normal and has no problem, under the condition that the test files are failed to operate, the electronic equipment can determine that the physical equipment has the problem and output prompt information to inform a tester of the problem of the physical equipment when the test files are operated, so that a user can position a problem command and adjust a target configuration file in time.
In some embodiments, as shown in fig. 2, the step S11 may include the following steps.
Step S21, the original configuration file of the physical device is obtained.
The original configuration file is a configuration file actually stored in the physical device. The electronic equipment reads the configuration file from the physical equipment, and takes the read configuration file as an original configuration file.
The original configuration file comprises invalid information such as file compiling information, date authority information, view information and the like, and a plurality of commands. Wherein the plurality of commands are divided into commands in one or more views, there may be an overlap of commands in different views.
Step S22, removing dirty data and repeated commands in the original configuration file to obtain a target configuration file.
In the embodiment of the application, dirty data comprises invalid information such as file compiling information, date authority information, view information and the like. The invalidation information is necessary command-independent configuration information in the physical device.
The electronic device removes dirty data in the original configuration file to obtain an intermediate configuration file, commands in different views are integrated in the intermediate configuration file, and repeated commands exist in the commands. And the electronic equipment performs de-duplication processing on the command in the intermediate configuration file, and removes the repeated command to obtain the target configuration file.
In the technical scheme provided by the embodiment of the application, the electronic equipment removes dirty data in the configuration file, reduces the interference of invalid information on the test, and improves the test precision. In addition, the electronic equipment removes repeated commands in the configuration file, avoids that one command is converted into a test file for multiple times, is further used for testing for multiple times, and improves the testing efficiency.
In some embodiments, the electronic device may analyze the tree structure of each command by adopting a method based on a mathematical expression, so as to obtain a plurality of original subcommands corresponding to each command, and specifically, refer to a flow shown in fig. 3.
Step S31, according to the mapping relation between the preset command symbols and mathematical symbols, converting the command symbols in each command into mathematical symbols, and obtaining the corresponding intermediate expression of each command.
In the embodiment of the present application, the mapping relationship between command symbols and mathematical symbols (i.e., operators) is preset in the electronic device, as shown in table 1.
TABLE 1
And in the mapping relation between the preset command symbol and the mathematical symbol, the meaning of the mathematical symbol is defined at the same time, so that the mathematical symbol can realize the logic function with the corresponding command symbol.
For each command, the electronic device converts the command symbol in the command into a mathematical symbol according to a mapping relation between a preset command symbol and the mathematical symbol, and obtains a corresponding prefix expression of each command.
For example, one command is: { all| { STRING <3-21> } [ both|export|import ] [ evpn ] }. The electronic device converts the command into a suffix expression according to the mapping relation shown in the above table 1:
(all+((STRING<3-21>)(both+export+import+NULL)/>(expn+NULL)))。
Step S32, converting the prefix expression corresponding to each command into the suffix expression corresponding to each command, and obtaining an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or a mathematical symbol of the command.
For example, the suffix expression for a command is:
(all+((STRING<3-21>)(both+export+import+NULL)/>(expn+NULL)))。
the electronic device converts the suffix expression into a suffix expression, such as [ ' all ', ' STRING<3-21>', 'both', 'export', '+', 'import', '+', 'NULL', '+', '', 'evpn', 'NULL', '+', '/>', '+']The suffix expression is the element queue corresponding to the command.
In the embodiment of the application, the electronic equipment can utilize two stacks to realize the conversion of the suffix expression into the suffix expression. One for storing data symbols and one for storing the result of the conversion. For ease of description, the stack for storing the data symbols is referred to as a symbol stack, and the stack for storing the results of the conversion is referred to as a result stack.
The electronic equipment starts traversing from the head of the prefix expression, each traversing to one element, and if the current element is a configuration parameter, writing the configuration parameter into a result stack; if the current element is a mathematical symbol, writing the element into a symbol stack; when a complete bracket, namely "()" is formed in the symbol stack, eliminating a bracket with the minimum range, ejecting the mathematical symbols in the bracket from the symbol stack, writing the mathematical symbols into a result stack, and when two continuous identical mathematical symbols exist in the symbol stack, ejecting the mathematical symbols at the top of the bracket from the symbol stack, and writing the mathematical symbols into the result stack. After the traversal of the prefix expression is finished, the content in the result stack forms an element queue.
For example, the suffix expression of a command is:
(all+((STRING<3-21>)(both+export+import+NULL)/>(expn+null)) are given as examples.
The electronic device converts the suffix expression into the suffix expression in the above manner, and the conversion flow is shown in table 2.
TABLE 2
In table 2, the current element is an element currently traversed from the head of the prefix expression, and a part of the current element is shown in the sequence traversed from top to bottom. The symbol stack and the result stack show the partial change of the symbol stack and the result stack storage element, respectively, as the prefix expression is traversed.
Step S33, based on mathematical symbols in the element queues corresponding to each command, performing mathematical calculation on configuration parameters in the element queues corresponding to each command to obtain a plurality of original subcommands corresponding to each command.
In the embodiment of the application, the electronic device converts each command into the element queue which is easy to be analyzed by the computer by adopting the steps S31-S32, so that a plurality of original subcommands corresponding to each command can be quickly calculated by using a mathematical calculation mode. The mathematical calculation comprises addition and multiplication calculation, wherein the added time complexity of two elements is O (n), and the multiplied time complexity of two elements is O (n) 2 ) Therefore, by adopting the technical scheme provided by the embodiment of the application, the total time complexity is O (n 3 ) With the time complexity, the single command analysis reaches millisecond level, and the full-coverage test time of the command can be shortened to be within 24 hours. In the related art, a mode of manually acquiring the command and performing assignment test on the configuration parameters of the command may take several months, and therefore, the technical scheme provided by the embodiment of the application shortens the generation time of the test file and improves the test efficiency of the physical equipment.
In some embodiments, as shown in fig. 4, in step S33 described above, the electronic device may employ the following steps for each command to achieve the acquisition of the original subcommand.
Step S41, starting from the head of the element queue corresponding to the command, traversing each element of the element queue.
In the embodiment of the application, the sequence of the elements in the element queue is the same as the sequence of the elements written in the result stack, namely, the elements of the result stack are written in first, the elements in the element queue are written in the front and the elements in the result stack are written in the rear, and the elements in the element queue are written in the rear. The element queue corresponds to one stack, such as a second stack.
Step S42, when the traversed current element is the configuration parameter, the current element is written into the first stack. The first stack may be any stack in the electronic device.
Step S43, when the traversed current element is a mathematical symbol, two elements at the tail of the first stack are popped up; calculating the two elements and the current element to obtain a calculation result; the result of the calculation is written as an element to the first stack. Wherein the element at the tail of the stack is the element which is finally written into the first stack.
Step S44, when all elements of the element queue are traversed, a plurality of original subcommands corresponding to the commands are obtained.
After the electronic device acquires an element queue corresponding to a command, traversing the element from the head of the element queue, wherein each time the element is traversed, the element is the current element. In the embodiment of the application, when the element queue is the second stack, the electronic device traversing the element from the head of the element queue may pop an element from the head of the element queue, and the popped element is the current element.
After the electronic equipment obtains the current element, judging whether the current element is a configuration parameter or a mathematical symbol. And when the judgment result is that the current element is the configuration parameter, the electronic equipment writes the current element into the first stack.
When the judgment result is that the current element is a mathematical symbol, the electronic equipment pops up the first stack and finally writes two elements, and a mathematical calculation formula is obtained by connecting the two elements according to the current element, the mathematical calculation formula is calculated, a calculation result is obtained, and the calculation result is written into the first stack as an element.
After all elements of the element queue are popped up, the traversal is finished, and a plurality of original subcommands corresponding to the commands are obtained.
For example, the electronic device obtains an element queue of [ 'all', 'STRING', or a combination of the element queue and the element queue<3-21>', 'both', 'export', '+', 'import', '+', 'NULL', '+', '', 'evpn', 'NULL', '+', '/>', '+']Where 'all' is the first element of the element queue. The process of the electronic device obtaining the original subcommand corresponding to the element queue can be seen in table 3 below.
TABLE 3 Table 3
/>
In table 3, the current element is an element popped from the head of the element queue, and the popped elements are sequentially shown in the pop-up order from top to bottom. The execution action is an action performed by the electronic device based on the popped element. The first stack exposes changes to storage elements in the stack after the action is performed.
In the embodiment of the present application, the element queue corresponding to each command may be traversed in the manner of step S41 to step S44, so as to obtain a plurality of original subcommands corresponding to each command.
The inventor finds through experiments that a plurality of original subcommands corresponding to each command are obtained according to the mode shown in the figures 3 and 4, and 187932 subcommands can be obtained through analysis only in less than 250 seconds for one command which can be split into 187932 subcommands, so that the time complexity is low.
In some embodiments, the electronic device may analyze the tree structure of each command by using a sliding window-based method, so as to obtain a plurality of original subcommands corresponding to each command, which may refer to the flow shown in fig. 5.
In step S51, a plurality of leaf nodes included in each command are acquired using a sliding window.
In the embodiment of the application, the length of the sliding window is not fixed. For each command, the initial positions of the right boundary and the left boundary of the sliding window are all positioned at the head of the command, the electronic equipment moves the right boundary of the sliding window from the head of the command, stops sliding the right boundary when the value of the right boundary is a designated command symbol, and analyzes the command part in the sliding window to obtain one or more nodes of a command tree; and moving the left boundary of the sliding window to enable the left boundary to be equal to the right boundary, then moving the right boundary of the sliding window, stopping sliding the right boundary when the value of the right boundary is a designated command symbol, and analyzing the command part in the sliding window to obtain one or more nodes of the command tree. When both the right and left boundaries of the sliding window move to the tail of the command, the command parsing is completed. The electronic device may obtain a plurality of leaf nodes included in the command from the plurality of nodes carried.
In step S52, the plurality of leaf nodes included in each command are converted into a dictionary corresponding to each command, the dictionary includes a plurality of partitions, and each partition includes one element that is a lower-level partition or a leaf node, and the logical relationships among the elements in one partition are the same.
For each command, after the electronic device acquires a plurality of leaf nodes included in the command, traversing the leaf nodes one by one, and converting the plurality of leaf nodes included in the command into dictionaries corresponding to each command according to a logic relationship among the leaf nodes, and storing the dictionaries in a memory.
For example, one command is: { all| { STRING <3-21> } [ both|export|import ] [ evpn ] }. With a sliding window, looking for a composed command tree, as shown in FIG. 6a, element 1 represents "all", element 2 represents "NULL", element 3 represents "STRING <3-21>", element 4 represents "both", element 5 represents "export", element 6 represents "import", element 7 represents "evpn", and the leaf nodes obtained by the electronic device include "all", "STRING <3-21>", "both", "export", "import", "evpn", and "NULL".
The electronic device presents these leaf nodes in the form of a dictionary, as shown in fig. 6 b. The dictionary obtained by converting the leaf nodes comprises 5 partitions, namely partition 1-partition 5, and the logical relationship among elements in one partition is a sum relationship or an OR relationship.
Step S53, converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relationship between the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command.
For each command, the electronic equipment traverses the dictionary corresponding to the command according to the bottom-up sequence, realizes gradual recursion to the root node of the command tree, and converts the dictionary into a plurality of lists.
Taking the dictionary shown in fig. 6b obtained in step S52 as an example. In this dictionary, partition 5 is at the bottom and partition 1 is at the top. The electronic device traverses the dictionary in bottom-up order, resulting in 5 lists, list 1-list 5 shown in fig. 6c, where list 1 includes "all" and partition 4, list 2 includes partition 1, partition 2 and partition 3, list 3 includes "evpn" and "NULL" (NULL), list 4 includes "both", "export", "import" and "NULL" (NULL), and list 5 includes "STRING <3-21>". The partition 4 in the list 1 has an association relationship with all elements included in the list 2, the partition 3 in the list 2 has an association relationship with all elements included in the list 3, the partition 2 in the list 2 has an association relationship with all elements included in the list 4, and the partition 1 in the list 2 has an association relationship with all elements included in the list 5.
Step S54, traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
After obtaining a plurality of lists corresponding to each command and the association relation among the lists, aiming at each command, the electronic equipment traverses all the lists corresponding to the command according to the association relation among the lists from the top of the list to the bottom, and obtains a plurality of original subcommands corresponding to the command.
The description will be given with reference to a plurality of lists shown in fig. 6c as examples. From left to right, the association relationship between the lists can be found. Based on this, the electronic device may traverse the multiple lists shown in fig. 6c in the order of the multiple lists from left to right and one list from top to bottom, and first traverse list 1. When traversing the list 1, traversing from the top of the list 1 until the element 1 all and the partition 4 included in the list 1 have no association relationship with other lists, and stopping traversing to obtain an original subcommand all;
then, traversing the list 2 from left to right, traversing to the elements "partition 3", "partition 2" and "partition 1" included in the list 2; the 'partition 3', 'partition 2' and 'partition 1' have no association relation with other lists respectively, and the list 3-list 5 is continuously traversed;
when traversing the list 3, traversing from the top of the list 3 until the elements 7 'evpn', the elements 2 'null', the evpn 'and the null' included in the list 3 have no association relation with other lists, and stopping traversing;
When traversing the list 4, traversing from the top of the list 4 to the element 4 'both', the element 5 'export', the element 6 'import', the element 2 'blank', 'both', 'export', 'import', 'blank' and the other list included in the list 4 have no association relationship, and stopping traversing;
when traversing the list 5, traversing from the top of the list 5 to the elements 3 'STRING <3-21 >', wherein the list 5 comprises the elements, and the elements 3 'STRING <3-21 >' have no association relation with other lists, and stopping traversing;
according to the logical relation (sum relation) among the elements in the list 2, the traversed elements in the list 3, the traversed elements in the list 4 and the traversed elements in the list 5 are combined to obtain 8 original subcommands, wherein the original subcommands are respectively as follows: STRING <3-21>both evpn,STRING<3-21>both NULL,STRING<3-21>export evpn,STRING<3-21>export NULL,STRING<3-21>import evpn,STRING<3-21>import NULL,STRING<3-21>NULL evpn,STRING<3-21> NULL NULL.
In the technical scheme provided by the embodiment of the application, the electronic equipment obtains a plurality of original subcommands corresponding to each command by combining the conversion of the dictionary and the list in a sliding window mode. In this process, the electronic device needs to traverse the parameters More than 5 times, the time complexity is O (n 5 ) With this time complexity, a single command parse reaches the second level. In the related art, a mode of manually acquiring the command and performing assignment test on the configuration parameters of the command may take several months, and therefore, the technical scheme provided by the embodiment of the application shortens the generation time of the test file and improves the test efficiency of the physical equipment.
In the embodiment of the application, the electronic equipment can also adopt other methods based on the sliding window to analyze the tree structure of each command so as to obtain a plurality of original subcommands corresponding to each command. For example, a sliding window is utilized to obtain a plurality of nodes included in each command, the nodes can be converted into a command tree for display, and a user searches upwards from each leaf node to obtain a plurality of original subcommands. The method can also find out the combination mode of all the configuration parameters contained in one command and cover all the combination modes of the configuration parameters corresponding to the command, so that the problem of the physical equipment can be measured in a laboratory environment, the problem of the physical equipment is solved, and the quality of the physical equipment is improved.
Corresponding to the above test file generating method, as shown in fig. 7, an embodiment of the present application provides a test file generating device, where the device includes:
An obtaining module 71, configured to obtain a target configuration file of the physical device, where the target configuration file includes a plurality of commands;
the parsing module 72 is configured to parse the tree structure of each command to obtain a plurality of original subcommands corresponding to each command;
the assignment module 73 is configured to assign configuration parameters of a plurality of original subcommands corresponding to each command according to the range of the configuration parameters, so as to obtain a plurality of target subcommands corresponding to each command;
the generating module 74 is configured to generate, from the plurality of target subcommands corresponding to each command, a test file corresponding to each command, where the test file is used to test the physical device.
In the technical scheme provided by the embodiment of the application, after the target configuration file of one physical device is obtained, the plurality of commands included in the target configuration file are analyzed according to the tree structure of the commands, so that all original subcommands corresponding to each command can be obtained, assignment operation is carried out on the configuration parameters of the original subcommands, the test file corresponding to each command can be generated, the test file is operated on the physical device, and the physical device is tested. Compared with the mode of manually acquiring the commands and assigning the configuration parameters of the commands, in the embodiment of the application, under the conditions that the number of the physical devices is huge, the configuration of each physical device is complex, and the number of the commands and invalid information included in one physical device are also huge, a plurality of test files corresponding to the plurality of commands can be automatically generated, manual participation is not needed, the labor cost is reduced, the time consumption for generating the test files is reduced, the command coverage rate is improved, and the time of the physical devices occupied by configuration test is reduced.
In some embodiments, the acquiring module 71 may specifically be configured to:
acquiring an original configuration file of the physical equipment;
and removing dirty data and repeated commands in the original configuration file to obtain the target configuration file.
In some embodiments, the parsing module 72 may include:
the first conversion sub-module is used for converting the command symbols in each command into mathematical symbols according to the mapping relation between the preset command symbols and the mathematical symbols to obtain a corresponding intermediate expression of each command;
the second conversion sub-module is used for converting the intermediate expression corresponding to each command into the suffix expression corresponding to each command to obtain an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or a mathematical symbol of the command;
the computing sub-module is used for carrying out mathematical computation on the configuration parameters in the element queue corresponding to each command based on the mathematical symbols in the element queue corresponding to each command, so as to obtain a plurality of original sub-commands corresponding to each command.
In some embodiments, the above calculation submodule may be specifically used to:
for each command, traversing each element of the element queue starting from the head of the element queue corresponding to the command;
When the traversed current element is a configuration parameter, writing the current element into a first stack;
when the traversed current element is a mathematical symbol, popping up two elements at the tail of the first stack; calculating the two elements and the current element to obtain a calculation result; writing the calculation result as an element into a first stack;
when all elements of the element queue are traversed, a plurality of original subcommands corresponding to the command are obtained.
In some embodiments, the parsing module 72 may be specifically configured to:
acquiring a plurality of leaf nodes included in each command by utilizing a sliding window;
converting a plurality of leaf nodes included in each command into a dictionary corresponding to each command, wherein the dictionary comprises a plurality of partitions, one element included in each partition is a lower-level partition or a leaf node, and the logic relations among the elements in one partition are the same;
converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relation among the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command;
traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
In some embodiments, the assignment module 73 may specifically be configured to:
removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command;
and respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
The embodiment of the application also provides an electronic device, as shown in fig. 8, which comprises a processor 81, a communication interface 82, a memory 83 and a communication bus 84, wherein the processor 81, the communication interface 82 and the memory 83 complete communication with each other through the communication bus 84,
a memory 83 for storing a computer program;
the processor 81 is configured to implement any of the above-described test file generation methods when executing the program stored in the memory 83.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present application, there is also provided a computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the steps of any of the test file generating methods described above.
In yet another embodiment of the present application, there is also provided a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the test file generation methods of the above embodiments.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present application, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the apparatus, electronic device, storage medium embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and references to the parts of the description of the method embodiments are only needed.
The foregoing description is only of the preferred embodiments of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (10)

1. A method of generating a test file, the method comprising:
acquiring a target configuration file of physical equipment, wherein the target configuration file comprises a plurality of commands;
respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command;
assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command;
generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, wherein the test file is used for testing the physical equipment;
the step of respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command comprises the following steps:
converting the command symbols in each command into mathematical symbols according to the mapping relation between the preset command symbols and the mathematical symbols to obtain a corresponding prefix expression of each command;
Converting the prefix expression corresponding to each command into the suffix expression corresponding to each command to obtain an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or mathematical symbol of the command;
for each command, traversing each element of an element queue corresponding to the command from the head of the element queue;
when the traversed current element is a configuration parameter, writing the current element into a first stack;
when the traversed current element is a mathematical symbol, popping up two elements at the tail of the first stack; calculating the two elements and the current element to obtain a calculation result; writing the calculation result as an element into the first stack;
and when all the elements of the element queue are traversed, obtaining a plurality of original subcommands corresponding to the command.
2. The method of claim 1, wherein the step of obtaining the target profile for the physical device comprises:
acquiring an original configuration file of the physical equipment;
and removing dirty data and repeated commands in the original configuration file to obtain a target configuration file.
3. The method of claim 1, wherein the step of parsing the tree structure of each command to obtain a plurality of original subcommands corresponding to each command, further comprises:
Acquiring a plurality of leaf nodes included in each command by utilizing a sliding window;
converting a plurality of leaf nodes included in each command into a dictionary corresponding to each command, wherein the dictionary comprises a plurality of partitions, one element included in each partition is a lower-level partition or a leaf node, and the logic relations among the elements in one partition are the same;
converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relation among the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command;
traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
4. A method according to any one of claims 1 to 3, wherein the step of assigning configuration parameters of a plurality of original subcommands corresponding to each command according to the range of configuration parameters to obtain a plurality of target subcommands corresponding to each command comprises:
removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command;
And respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
5. A test file generation apparatus, the apparatus comprising:
the system comprises an acquisition module, a storage module and a control module, wherein the acquisition module is used for acquiring a target configuration file of physical equipment, and the target configuration file comprises a plurality of commands;
the analysis module is used for respectively carrying out tree structure analysis on each command to obtain a plurality of original subcommands corresponding to each command;
the assignment module is used for assigning values to the configuration parameters of the plurality of original subcommands corresponding to each command according to the range of the configuration parameters to obtain a plurality of target subcommands corresponding to each command;
the generation module is used for generating a test file corresponding to each command by a plurality of target subcommands corresponding to each command, and the test file is used for testing the physical equipment;
the parsing module comprises:
the first conversion sub-module is used for converting the command symbols in each command into mathematical symbols according to the mapping relation between the preset command symbols and the mathematical symbols to obtain a corresponding intermediate expression of each command;
The second conversion sub-module is used for converting the intermediate expression corresponding to each command into the suffix expression corresponding to each command to obtain an element queue corresponding to each command, wherein one element of the element queue corresponding to each command is a configuration parameter or a mathematical symbol of the command;
a computing sub-module, configured to traverse, for each command, each element of an element queue corresponding to the command, starting from a head of the element queue; when the traversed current element is a configuration parameter, writing the current element into a first stack; when the traversed current element is a mathematical symbol, popping up two elements at the tail of the first stack; calculating the two elements and the current element to obtain a calculation result; writing the calculation result as an element into the first stack; and when all the elements of the element queue are traversed, obtaining a plurality of original subcommands corresponding to the command.
6. The apparatus of claim 5, wherein the obtaining module is specifically configured to:
acquiring an original configuration file of the physical equipment;
and removing dirty data and repeated commands in the original configuration file to obtain a target configuration file.
7. The apparatus of claim 5, wherein the parsing module is further configured to:
acquiring a plurality of leaf nodes included in each command by utilizing a sliding window;
converting a plurality of leaf nodes included in each command into a dictionary corresponding to each command, wherein the dictionary comprises a plurality of partitions, one element included in each partition is a lower-level partition or a leaf node, and the logic relations among the elements in one partition are the same;
converting the dictionary corresponding to each command into a plurality of lists corresponding to each command, and recording the association relation among the lists, wherein one list corresponding to each command comprises elements in one partition of the dictionary corresponding to each command;
traversing a plurality of lists corresponding to each command according to the association relation among the lists from the top of the list to the bottom, and obtaining a plurality of original subcommands corresponding to the command.
8. The apparatus according to any of the claims 5-7, wherein the assignment module is specifically configured to:
removing the empty configuration parameters in the plurality of original subcommands corresponding to each command to obtain a plurality of intermediate subcommands corresponding to each command;
and respectively endowing each configuration parameter in the plurality of intermediate subcommands corresponding to each command with a value in the range of the configuration parameter to obtain a plurality of target subcommands corresponding to each command.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-4.
CN202311196843.9A 2023-09-15 2023-09-15 Test file generation method and device, electronic equipment and storage medium Active CN116932305B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311196843.9A CN116932305B (en) 2023-09-15 2023-09-15 Test file generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311196843.9A CN116932305B (en) 2023-09-15 2023-09-15 Test file generation method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116932305A CN116932305A (en) 2023-10-24
CN116932305B true CN116932305B (en) 2023-12-12

Family

ID=88375778

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311196843.9A Active CN116932305B (en) 2023-09-15 2023-09-15 Test file generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116932305B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117194278B (en) * 2023-11-08 2024-02-23 新华三网络信息安全软件有限公司 Device command management method and device, storage medium and electronic device

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102624736A (en) * 2012-03-20 2012-08-01 瑞斯康达科技发展股份有限公司 TL1 (transaction language 1) command verification method and TL1 command verification device
WO2014078747A1 (en) * 2012-11-15 2014-05-22 Maxwell Worthington, Llc Natural language command string for controlling target applications
CN107506271A (en) * 2017-08-25 2017-12-22 郑州云海信息技术有限公司 A kind of method of testing and device
EP3722943A1 (en) * 2019-04-12 2020-10-14 Holberton School Correction of software coding projects
CN112822031A (en) * 2019-11-18 2021-05-18 中盈优创资讯科技有限公司 Network equipment configuration file analysis method and device
CN114153668A (en) * 2021-11-17 2022-03-08 北京金山云网络技术有限公司 Automatic testing method and device, electronic equipment and storage medium
CN115858256A (en) * 2021-09-24 2023-03-28 四川爱联科技股份有限公司 Test method and device for Internet of things equipment and electronic equipment
CN116107892A (en) * 2023-02-01 2023-05-12 浙江极氪智能科技有限公司 Automatic test method, device, equipment and storage medium
CN116467047A (en) * 2023-04-24 2023-07-21 软安科技有限公司 Method and device for detecting container configuration compliance, storage medium and terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140310690A1 (en) * 2013-04-15 2014-10-16 Futurewei Technologies, Inc. System and Method for Generating Automated Test Cases for Command Line Based Applications
CN116521153A (en) * 2022-01-20 2023-08-01 北京字跳网络技术有限公司 Graph generation method, device, equipment and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102624736A (en) * 2012-03-20 2012-08-01 瑞斯康达科技发展股份有限公司 TL1 (transaction language 1) command verification method and TL1 command verification device
WO2014078747A1 (en) * 2012-11-15 2014-05-22 Maxwell Worthington, Llc Natural language command string for controlling target applications
CN107506271A (en) * 2017-08-25 2017-12-22 郑州云海信息技术有限公司 A kind of method of testing and device
EP3722943A1 (en) * 2019-04-12 2020-10-14 Holberton School Correction of software coding projects
CN112822031A (en) * 2019-11-18 2021-05-18 中盈优创资讯科技有限公司 Network equipment configuration file analysis method and device
CN115858256A (en) * 2021-09-24 2023-03-28 四川爱联科技股份有限公司 Test method and device for Internet of things equipment and electronic equipment
CN114153668A (en) * 2021-11-17 2022-03-08 北京金山云网络技术有限公司 Automatic testing method and device, electronic equipment and storage medium
CN116107892A (en) * 2023-02-01 2023-05-12 浙江极氪智能科技有限公司 Automatic test method, device, equipment and storage medium
CN116467047A (en) * 2023-04-24 2023-07-21 软安科技有限公司 Method and device for detecting container configuration compliance, storage medium and terminal

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Pmfs中目录项索引的实现;杨顺;陈志广;肖侬;;计算机应用(第05期);全文 *
Tangible power loss lessening by hybridized beautiful demoiselle-enriched particle swarm and pyramid optimization algorithms;Kanagasabai, L.;INTERNATIONAL JOURNAL OF SYSTEM ASSURANCE ENGINEERING AND MANAGEMENT;全文 *
基于Python的SCPI命令解释器设计与优化;潘琦;陈晗;曹炳尧;李迎春;;工业控制计算机(第06期);全文 *
基于双栈结构的中缀表达式算法设计与实现;许晓宇;;智能计算机与应用(第06期);全文 *

Also Published As

Publication number Publication date
CN116932305A (en) 2023-10-24

Similar Documents

Publication Publication Date Title
CN116932305B (en) Test file generation method and device, electronic equipment and storage medium
US9996332B2 (en) Accurately estimating install time
US20210150305A1 (en) Forecasting time-series data in a network environment
CN113228006A (en) Apparatus and method for detecting anomalies in successive events and computer program product thereof
US20200174967A1 (en) Suggesting a destination folder for a file to be saved
CN111008701A (en) Data quantization method and device based on neural network and computer readable storage medium
CN114356893A (en) Metadata tuning method, device, equipment and storage medium based on machine learning
CN114265702B (en) iSCSI service load balancing method, device, equipment and medium
JP2023548915A (en) Domain generalization margin using meta-learning for deep face recognition
US20090328006A1 (en) Instruction-trace generation program, instruction-trace generating device, and instruction-trace generating method
CN116932304A (en) Register test method and device, electronic equipment and storage medium
US20230334325A1 (en) Model Training Method and Apparatus, Storage Medium, and Device
US20170193152A1 (en) System and method for combined path tracing in static timing analysis
CN113555031B (en) Training method and device of voice enhancement model, and voice enhancement method and device
CN109343985A (en) A kind of data processing method, device and storage medium
US20220366293A1 (en) Text augmentation of a minority class in a text classification problem
KR102177940B1 (en) Method and apparatus for measuring relevance between nodes of edge-labeled multigraph
CN111639760B (en) Discrete feature representation by class priority
CN112464101A (en) Electronic book sorting recommendation method, electronic device and storage medium
CN111488970A (en) Execution optimization method and device of neural network
US11334607B2 (en) Identifying key words within a plurality of documents
CN109522211A (en) Interface parameters transmission method, device, electronic equipment and storage medium
US9734270B2 (en) Control path power adjustment for chip design
CN115938353B (en) Voice sample distributed sampling method, system, storage medium and electronic equipment
CN113746899B (en) Cloud platform access method and device

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