A kind of test script language conversion that realizes becomes the method and system of executable instruction
Technical field
The present invention relates to the communications field, relate in particular to a kind of test script language conversion that realizes and become the method and system of executable instruction.
Background technology
TTCN3 (Testing and Test Control Notation vesion3; Test and test control representation the 3rd edition) as the test script language of a kind of standardized test description and test implementation; Be widely used in various telecom agreements and the Internet protocol field tests, as comprising uniformity test, interoperability test, unit testing etc.Because coding/decoding module is an important software function in the TTCN3 system; Therefore; When carrying out the test macro exploitation; The developer needs at first according to different test platforms corresponding coding/decoding module to be set, and based on the coding/decoding module that is provided with corresponding system under test (SUT) is carried out follow-up development.
TTCN3 is a kind of descriptive script, can not directly be used to drive system under test (SUT), has only TTCN3 is changed into executable instruction (can be binary executable instruction) could to realize the control to system under test (SUT) afterwards; Therefore, before operation TTCN3 script, need carry out encoding and decoding, be about to the TTCN3 script and convert executable instruction to the TTCN3 script; Then seem particularly important in the TTCN3 encoding and decoding that the TTCN3 script is carried out being used in the encoding-decoding process.
At present, generate the mode of TTCN3 encoding and decoding, mainly manually generate, specifically may further comprise the steps through the developer:
Step 1, developer are to current TTCN3 test script, and combing goes out needed all the test primitive of this TTCN3 test script.
Each bar test primitive that step 2, developer go out to combing; Analyze the data structure that this test primitive is adopted in the TTCN3 test script; And the compilation tool that is used in combination; Determine API (Application Programming Interface, the API) function that this test primitive is carried out the required use of encoding and decoding.
Step 3, developer determine every test primitive pairing control interface (control interface is meant the control stream that encoding and decoding are corresponding) in current test macro.
Step 4, developer adopt compilation tool according to corresponding control interface, data structure and the api function of this test primitive the corresponding software program to be compiled to every test primitive, generate and the corresponding TTCN3 encoding and decoding of this test primitive.
Adopt the mode of existing generation TTCN3 encoding and decoding, have following technological deficiency:
(1) can successfully generate the bigger self diathesis that depends on the developer of TTCN3 encoding and decoding, not only understand TTCN3 test script grammer, also need understand the corresponding programming language of api function etc. like the needs developer.
The scale of (2) combing, analytical test primitive and current test macro is closely connected, and test macro is more complicated, needs the test primitive quantity of combing, analysis many more, workload more greatly, loaded down with trivial details more; In the Development Engineering of reality, often may be owing to the omission or the mistake of combing in early stage, analytical work, work such as will bring bigger correction to the development in later stage, augment.
(3) when in test macro, increasing new test primitive; Also need the technician test primitive that increases newly to be carried out the work of above-mentioned (1) and (2); When the test primitive that increases newly more for a long time; Big through the artificial mode workload that generates encoding and decoding of this kind, efficient is low, overall is unfavorable for exploitation, upgrading etc. to test macro.
Summary of the invention
The embodiment of the invention provides a kind of test script language conversion that realizes to become the method and system of executable instruction, to improve speed, efficient and the success ratio that the test script language conversion is become executable instruction.
A kind of test script language conversion that realizes becomes the method for executable instruction, comprising:
Reception carries the conversion request of test script to be converted;
From said test script to be converted, determine control primitive to be converted;
From the corresponding relation of control primitive and the encoding and decoding of storage, determine and the corresponding encoding and decoding of said control primitive to be converted;
The encoding and decoding that employing is determined are encoded to said control primitive to be converted, form corresponding executable instruction.
Preferably, said corresponding relation is the pairing corresponding relation of test macro of the said test script to be converted of current operation.
Preferably, said method before receiving said conversion request, also can comprise step:
From all test script source files, extract control primitive;
To each test macro, from the control primitive that extracts, choose and the corresponding control primitive of said test macro; Generate respectively and the corresponding encoding and decoding of choosing of control primitive, and set up the corresponding relation and the storage of the control primitive chosen and corresponding encoding and decoding.
Preferably, in the said method, from the test script source file, extract control primitive, can comprise: from said test script source file, search the corresponding organization definition symbol of control output end mouth; The control primitive that needs extraction confirmed as in the corresponding primitive of organization definition symbol that finds.
Preferably; In the said method; Generate respectively and the corresponding encoding and decoding of choosing of control primitive; Can comprise step: to every control primitive of choosing, analyze the data structure of said control primitive correspondence, and determine each data member corresponding application program programming api interface in the said data structure according to the organization definition symbol of the corresponding control output end mouth of the control primitive of choosing; Adopt the corresponding compilation tool of said test macro that the corresponding api interface of the data member in the said data structure is compiled, the compiling result who obtains is the pairing encoding and decoding of choosing of control primitive.
Preferably, the language of said test script to be converted is test and the 3rd edition TTCN3 language of test control representation.
Based on preceding method, the embodiment of the invention also provides a kind of test script language conversion that realizes to become the system of executable instruction, and this system comprises:
Receiving trap is used to receive the conversion request that carries test script to be converted;
Device confirmed in control primitive, is used for determining control primitive to be converted from said test script to be converted;
Device is confirmed in encoding and decoding, is used for determining and the corresponding encoding and decoding of said control primitive to be converted from the control primitive of storage and the corresponding relation of encoding and decoding;
Conversion equipment is used to adopt encoding and decoding that said encoding and decoding confirm that device determines that said control primitive is confirmed that the control primitive of determining the unit encodes, and forms corresponding executable instruction.
Preferably, said corresponding relation is the pairing corresponding relation of test macro of the said test script to be converted of current operation.
Preferably, said system also can comprise:
The encoding and decoding generating apparatus was used for before said receiving trap receives said conversion request, from all test script source files, extracted control primitive; To each test macro; From the control primitive that extracts, choose and the corresponding control primitive of said test macro; Generate respectively and the corresponding encoding and decoding of choosing of control primitive, and set up the corresponding relation and the storage of the control primitive chosen and corresponding encoding and decoding.
Preferably, can above-mentioned coding generating apparatus be divided into:
The unit searched in control primitive, is used for extracting control primitive from all test script source files;
Control primitive cutting unit is used for to each test macro, searches the control primitive that the unit extracts from said control primitive and chooses and the corresponding control primitive of said test macro;
The encoding and decoding generation unit is used for to each test macro, generates corresponding with said test macro respectively choosing and controls the corresponding encoding and decoding of primitive;
Storage unit is used to set up the corresponding relation of the control primitive chosen and corresponding encoding and decoding, and stores said corresponding relation.
Preferably, the unit searched in said control primitive, specifically is used for: search the corresponding organization definition symbol of control output end mouth from said test script source file; The control primitive that needs extraction confirmed as in the corresponding primitive of organization definition symbol that finds.
Preferably, said encoding and decoding generation unit specifically is used for:
To every control primitive of choosing; Organization definition symbol based on the corresponding control output end mouth of the control primitive of choosing analyzes the corresponding data structure of said control primitive, and determines each data member corresponding application program programming api interface in the said data structure;
Adopt the corresponding compilation tool of said test macro that the corresponding api interface of the data member in the said data structure is compiled, the compiling result who obtains is the pairing encoding and decoding of choosing of control primitive.
The embodiment of the invention also provides a kind of encoding and decoding generating apparatus that is applied in the test script language conversion process, and this encoding and decoding generating apparatus can comprise:
The unit searched in control primitive, is used for extracting control primitive from all test script source files;
Control primitive cutting unit is used for to each test macro, searches the control primitive that the unit extracts from said control primitive and chooses and the corresponding control primitive of said test macro;
The encoding and decoding generation unit is used for to each test macro, generates corresponding with said test macro respectively choosing and controls the corresponding encoding and decoding of primitive;
Storage unit is used to set up the corresponding relation of the control primitive chosen and corresponding encoding and decoding, and stores said corresponding relation.
Preferably, the unit searched in said control primitive, specifically is used for: search the corresponding organization definition symbol of control output end mouth from said test script source file; The control primitive that needs extraction confirmed as in the corresponding primitive of organization definition symbol that finds.
Preferably, said encoding and decoding generation unit specifically is used for:
To every control primitive of choosing; Organization definition symbol based on the corresponding control output end mouth of the control primitive of choosing analyzes the corresponding data structure of said control primitive, and determines each data member corresponding application program programming api interface in the said data structure;
Adopt the corresponding compilation tool of said test macro that the corresponding api interface of the data member in the said data structure is compiled, the compiling result who obtains is the pairing encoding and decoding of choosing of control primitive.
In the embodiment of the invention; When receiving the conversion request that carries test script to be converted; From this test script to be converted, determine control primitive to be converted, and from the corresponding relation of control primitive and the encoding and decoding of storage, determine and the corresponding encoding and decoding of said control primitive to be converted; And then adopt the encoding and decoding of determining that said control primitive to be converted is encoded, form corresponding executable instruction.Adopt technical scheme of the present invention; When the control primitive in treating the conversion testing script is encoded; The encoding and decoding of being adopted can be directly obtained from the corresponding relation of control primitive that prestores and encoding and decoding; With respect to obtaining the encoding and decoding corresponding to operations such as the corresponding api interface of each data member compile through artificial the carrying out of the technician api interface that each data member is corresponding in data structure analysis, the specified data structure, the corresponding compilation tool of employing to every control primitive in the prior art with this control primitive; Technical scheme of the present invention has improved the speed of obtaining the corresponding encoding and decoding of control primitive to a certain extent; Thereby improved and to have controlled the speed that primitive converts executable instruction to; Then improved the speed and the efficient that the test script language are changed into executable instruction on the whole, under the more situation of control primitive, seemed particularly evident; In addition; Technical scheme of the present invention need not depend on technician's skill level; Therefore; Reduced human factor to a certain extent and caused control primitive is converted to the problem of executable instruction failure, will control the success ratio that primitive converts executable instruction to improve, the data structure of human factor such as analysis and Control primitive correspondence is inaccurate, inaccurate, the compile error of the api interface of each data member etc. in the specified data structure.
Description of drawings
Fig. 1 becomes the method flow diagram of executable instruction for realizing the test script language conversion in the embodiment of the invention;
Fig. 2 is the method flow diagram of the corresponding relation of default control primitive and encoding and decoding in the embodiment of the invention;
Fig. 3 is for searching the method flow diagram of control primitive from all test script source files in the embodiment of the invention;
Fig. 4 becomes one of structural representation of the system of executable instruction for realization test script language conversion in the embodiment of the invention;
Fig. 5 becomes two of the structural representation of the system of executable instruction for realization test script language conversion in the embodiment of the invention;
Fig. 6 is the structural representation of encoding and decoding generating apparatus in the embodiment of the invention.
Embodiment
To the technical matters that prior art exists, the embodiment of the invention provides a kind of test script language conversion that realizes to become the method and system of executable instruction, to improve speed, efficient and the success ratio that the test script language conversion is become executable instruction.Realize that the test script language conversion becomes the method for executable instruction, comprising: receive the conversion request that carries test script to be converted; From said test script to be converted, determine control primitive to be converted; From the corresponding relation of control primitive and the encoding and decoding of storage, determine and the corresponding encoding and decoding of said control primitive to be converted; The encoding and decoding that employing is determined are encoded to said control primitive to be converted, form corresponding executable instruction.Adopt technical scheme of the present invention; When the control primitive in treating the conversion testing script is encoded; The encoding and decoding of being adopted can be directly obtained from the corresponding relation of control primitive that prestores and encoding and decoding; With respect to obtaining the encoding and decoding corresponding to operations such as the corresponding api interface of each data member compile through artificial the carrying out of the technician api interface that each data member is corresponding in data structure analysis, the specified data structure, the corresponding compilation tool of employing to every control primitive in the prior art with this control primitive; Technical scheme of the present invention has improved the speed of obtaining the corresponding encoding and decoding of control primitive to a certain extent; Thereby improved and to have controlled the speed that primitive converts executable instruction to; Then improved the speed and the efficient that the test script language are changed into executable instruction on the whole, under the more situation of control primitive, seemed particularly evident; In addition; Technical scheme of the present invention need not depend on technician's skill level; Therefore; Reduced human factor to a certain extent and caused control primitive is converted to the problem of executable instruction failure, will control the success ratio that primitive converts executable instruction to improve, the data structure of human factor such as analysis and Control primitive correspondence is inaccurate, inaccurate, the compile error of the api interface of each data member etc. in the specified data structure.
Below in conjunction with Figure of description technical scheme of the present invention is carried out detailed description.
Referring to Fig. 1, become the method flow diagram of executable instruction for realizing the test script language conversion in the embodiment of the invention, this method can comprise step:
Step 101, reception carry the conversion request of test script to be converted.
Step 102, from said test script to be converted, determine control primitive to be converted.
Step 103, from the corresponding relation of control primitive and the encoding and decoding of storage, determine and the corresponding encoding and decoding of said control primitive to be converted.
The encoding and decoding that step 104, employing are determined are encoded to said control primitive to be converted, form corresponding executable instruction.
Preferably; In the embodiment of the invention; Can be directed against all test script source files in advance; From this test script source file, extract control primitive (the control primitive that from each test script source file, extracts can constitute the set of control primitive); And generate corresponding encoding and decoding to the control primitive that extracts, and set up corresponding relation and the storage of respectively controlling between primitive and the encoding and decoding, so that directly obtain the corresponding encoding and decoding of control primitive when encoding for the follow-up control primitive of treating in the conversion testing script.Preferably; Because same test script can be applied to different test macros, and the compilation tool of control primitive that different test macros possibly need and use is different, therefore; For adapting to different test macros; So that operation is gone back test script and can be controlled this test macro accurately in test macro, in the embodiment of the invention, to each test macro; Can from the set of control primitive, choose and the corresponding control primitive of said test macro; And generate respectively and the corresponding encoding and decoding of choosing of control primitive, and set up the corresponding relation of the control primitive chosen and corresponding encoding and decoding, promptly each test macro is corresponding to the corresponding relation of control primitive and corresponding encoding and decoding; Promptly when test script moves in current test macro; The encoding and decoding that control primitive in this test script is encoded are to determine according to deserving the corresponding control primitive of Pretesting system and the corresponding relation of encoding and decoding; Thereby make the executable instruction that obtains of encoding of the control primitive in the test script is more met current test macro, move this executable instruction and can control current test macro more accurately.Based on foregoing, in the embodiment of the invention, before the said method flow process, also comprise the preset flow process of the corresponding relation of control source code and corresponding encoding and decoding, this preset flow process is as shown in Figure 2, can comprise step:
Step 201, from all test script source files, extract control primitive.
Step 202, to each test macro, from the control primitive that step 201 extracts, choose and the corresponding control primitive of said test macro.
Step 203, to the test macro that relates in the step 202, be that every corresponding control primitive of this test macro generates corresponding encoding and decoding; And set up the corresponding relation of the corresponding control primitive encoding and decoding corresponding of this test macro with it.
Preferably, in the embodiment of the invention, for realizing accurately current test macro being controlled, the corresponding relation that uses in the step 103 in the said method flow process is and the corresponding corresponding relation of current test macro.
Preferably; In test macro; Possibly have a lot of control primitive, but be not that primitive all in the test script all needs coding, the primitive that the encoding and decoding of exploitation only need relate to the organization definition symbol of control output end mouth in the test script is encoded and is got final product; Therefore, in the above-mentioned steps 201, concrete implementation is following: to each test script source file, from this test script source file, search the corresponding organization definition symbol of control output end mouth; The control primitive that need from this test script source file, extract confirmed as in the corresponding primitive of organization definition symbol that finds.From all test script source files, extract the mode of control primitive, concrete flow process can be as shown in Figure 3.The language of the test script to be converted in the embodiment of the invention can be TTCN3 or TTCN2; Because test script to be converted has the specific syntax (being the TTCN grammer) of self, such as: how definition structure, how to define Union, how to define Port (being aforementioned control output end mouth); Therefore, in the step 103 of said method flow process, can from said test script to be converted, determine control primitive to be converted through searching and lexical analysis.Lexical analysis mainly is in the test script source file, to search corresponding definition and record according to the TTCN grammer; Search all Port like needs, the character string (being aforesaid organization definition symbol) of then in source file, searching " Type port port title message{} " gets final product.
Preferably, in the step 203 in the said method flow process,, generate and the corresponding encoding and decoding of this control primitive, comprising to every corresponding control primitive of each test macro:
To every control primitive, analyze the data structure of said control primitive correspondence according to the organization definition symbol of the corresponding control output end mouth of this control primitive, and determine each data member corresponding application program programming api interface in the said data structure; Adopt the corresponding compilation tool of said test macro that the corresponding api interface of the data member in the said data structure is compiled, the compiling result who obtains is the pairing encoding and decoding of choosing of control primitive.
Referring to Fig. 3, for from all test script source files, extracting the method flow diagram of control primitive in the embodiment of the invention, this method comprises:
Step 301, from current test script source file, search the corresponding organization definition symbol of control output end mouth, deserve Pretesting script source file and be in the script test source file of the current organization definition symbol search operation of not carrying out the control output end mouth one of them.
The organization definition symbol of the control output end mouth that step 302, record find from deserve Pretesting script source file.
Step 303, judge whether all test script files to have been carried out searching of control output end mouth structure delimiter; If then execution in step 304, otherwise the script test source file execution in step 301 of the next one not carried out the organization definition symbol search operation of control output end mouth.
Step 304, from step 302, choose organization definition symbol to be analyzed in the organization definition symbol of the control output end mouth of record; And the corresponding control primitive of this organization definition to be analyzed symbol analyzed; Obtain the data structure that relates to this control primitive; If this data structure comprises minor structure, also obtain the minor structure of this data structure, said current control output end mouth is current one of them that also do not control in the control output end mouth that primitive analyzes in the record in the step 302.
The data structure and the minor structure thereof of the correspondence that obtains analyzed in the corresponding control primitive of organization definition symbol of step 305,304 pairs of current control output ends of recording step mouth.
Step 306, judge whether the corresponding control primitive of organization definition symbol of all control output end mouths of step 302 record is analyzed; If then execution in step 307, otherwise the next one controlled the organization definition symbol execution in step 304 of the control output end mouth that primitive analyzes.
Step 307, process ends.
Preferably; For minimizing redundant information further, guarantee to control the accuracy of test macro, to reduce the transmission load of test macro; In the above-mentioned steps 202; Choose and the corresponding control primitive of test macro, specific as follows: according to test macro the function that will realize, be used to the control primitive of realizing that each function is corresponding according to choosing; Convert each control primitive to executable instruction, and set the needed bit number of each executable instruction.
Based on the preceding method flow process, the embodiment of the invention also provides a kind of test script language conversion that realizes to become the system of executable instruction, and the structure of this system can be as shown in Figure 4, comprising:
Receiving trap 41 is used to receive the conversion request that carries test script to be converted;
Device 42 confirmed in control primitive, is used for determining control primitive to be converted from said test script to be converted;
Device 43 is confirmed in encoding and decoding, is used for determining and the corresponding encoding and decoding of said control primitive to be converted from the control primitive of storage and the corresponding relation of encoding and decoding;
Conversion equipment 44 is used to adopt encoding and decoding that encoding and decoding confirm that device 43 determines that control primitive is confirmed that the control primitive of determining unit 42 encodes, and forms corresponding executable instruction.
Preferably, said corresponding relation is the pairing corresponding relation of test macro of the said test script to be converted of current operation.
Preferably, said system also can comprise encoding and decoding generating apparatus 45, can be as shown in Figure 5:
Encoding and decoding generating apparatus 45 was used for before receiving trap 41 receives said conversion request, from all test script source files, extracted control primitive; To each test macro; From the control primitive that extracts, choose and the corresponding control primitive of said test macro; Generate respectively and the corresponding encoding and decoding of choosing of control primitive, and set up the corresponding relation and the storage of the control primitive chosen and corresponding encoding and decoding.
Preferably, the embodiment of the invention also can be divided encoding and decoding generating apparatus 45, and unit 451, control primitive cutting unit 452, encoding and decoding generation unit 453, storage unit 454 searched in the control primitive that is divided into as shown in Figure 6, wherein:
Unit 451 searched in control primitive, is used for extracting control primitive from all test script source files;
Control primitive cutting unit 452 is used for to each test macro, searches the control primitive that the unit extracts from said control primitive and chooses and the corresponding control primitive of said test macro;
Encoding and decoding generation unit 453 is used for to each test macro, generates corresponding with said test macro respectively choosing and controls the corresponding encoding and decoding of primitive;
Storage unit 454 is used to set up the corresponding relation of the control primitive chosen and corresponding encoding and decoding, and stores said corresponding relation.
Preferably, unit 451 searched in control primitive, specifically is used for: search the corresponding organization definition symbol of control output end mouth from said test script source file; The control primitive that needs extraction confirmed as in the corresponding primitive of organization definition symbol that finds.
Preferably; Encoding and decoding generation unit 453; Specifically be used for: to every control primitive of choosing; Organization definition symbol according to the corresponding control output end mouth of the control primitive of choosing analyzes the corresponding data structure of said control primitive, and determines each data member corresponding application program programming api interface in the said data structure; Adopt the corresponding compilation tool of said test macro that the corresponding api interface of the data member in the said data structure is compiled, the compiling result who obtains is the pairing encoding and decoding of choosing of control primitive.
The embodiment of the invention also provides a kind of encoding and decoding generating apparatus that is applied in the test script language conversion process; The structure of this encoding and decoding generating apparatus is as shown in Figure 6; Comprise that controlling primitive searches unit 451, control primitive cutting unit 452, encoding and decoding generation unit 453, storage unit 454; The function of each unit repeats no more at this as previously mentioned.
In the embodiment of the invention; On the one hand; When the control primitive in treating the conversion testing script is encoded; The encoding and decoding of being adopted can be directly obtained from the corresponding relation of control primitive that prestores and encoding and decoding; With respect to obtaining the encoding and decoding corresponding to operations such as the corresponding api interface of each data member compile through artificial the carrying out of the technician api interface that each data member is corresponding in data structure analysis, the specified data structure, the corresponding compilation tool of employing to every control primitive in the prior art with this control primitive; Technical scheme of the present invention has improved the speed of obtaining the corresponding encoding and decoding of control primitive to a certain extent; To control the speed that primitive converts executable instruction to thereby improved, improve the speed and the efficient that the test script language are changed into executable instruction then on the whole, under the more situation of control primitive, seem particularly evident; In addition; Technical scheme of the present invention need not depend on technician's skill level; Therefore; Reduced human factor to a certain extent and caused control primitive is converted to the problem of executable instruction failure, will control the success ratio that primitive converts executable instruction to improve, the data structure of human factor such as analysis and Control primitive correspondence is inaccurate, inaccurate, the compile error of the api interface of each data member etc. in the specified data structure; On the other hand; When in advance the corresponding relation of control primitive and encoding and decoding being set; To different test macros corresponding corresponding relation is set; Promptly when test script moves in current test macro; The encoding and decoding that control primitive in this test script is encoded are to determine with the corresponding relation of encoding and decoding according to deserving the corresponding control primitive of Pretesting system, thereby feasible the executable instruction that obtains of encoding of control primitive in the test script are more met current test macro, move this executable instruction and can control current test macro more accurately; Again on the one hand; When being directed against the corresponding relation of each test macro default control primitive and encoding and decoding, be that the control primitive corresponding with this test macro that selects is generated corresponding encoding and decoding and stores corresponding relation, therefore need not generate corresponding coding-decoding operation to the not corresponding control primitive of test macro; Therefore; Not only improved the encoding and decoding formation speed, but also minimizing redundant information further, to reduce the transmission load of test macro.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, belong within the scope of claim of the present invention and equivalent technologies thereof if of the present invention these are revised with modification, then the present invention also is intended to comprise these changes and modification interior.