CN101471826B - Test method and device for command line interface - Google Patents

Test method and device for command line interface Download PDF

Info

Publication number
CN101471826B
CN101471826B CN 200810189611 CN200810189611A CN101471826B CN 101471826 B CN101471826 B CN 101471826B CN 200810189611 CN200810189611 CN 200810189611 CN 200810189611 A CN200810189611 A CN 200810189611A CN 101471826 B CN101471826 B CN 101471826B
Authority
CN
China
Prior art keywords
command
aggregate
node
line interface
binary tree
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.)
Expired - Fee Related
Application number
CN 200810189611
Other languages
Chinese (zh)
Other versions
CN101471826A (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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN 200810189611 priority Critical patent/CN101471826B/en
Publication of CN101471826A publication Critical patent/CN101471826A/en
Application granted granted Critical
Publication of CN101471826B publication Critical patent/CN101471826B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a method and a device for testing a command line interface (CLI). The method comprises the following steps: acquiring a cluster command to be tested; conducting equivalent binary tree conversion to the cluster command from the root node of the cluster command; traversing the leaf node of the equivalent binary tree; accessing the path from the leaf node to the root node to acquire each single command and the corresponding expected prompting message; and testing the acquired single commands. The method simplifies the construction of the command tree through equivalent binary tree conversion and establishes a command tree which can be easily tested, thereby improving the testability, reducing the waste of computing resources of equipment and remarkably improving the testing efficiency.

Description

The method of testing of command line interface and device
Technical field
The present invention relates to the testing of equipment field, relate in particular to a kind of method of testing and device of network equipment command line interface.
Background technology
(Command Line Interface CLI) is the main mode of operation that current network equipment is provided with to Command Line Interface.Perfect day by day along with network equipment function; The content of order line is also being enriched constantly, when utilizing Command Line Interface that the network equipment is operated, usually can run into many views, other Command Line Interface of multi-user's level; And the Command Line Interface of different views or different user level the order test that can carry out be different; And just can reach several thousand orders easily, the combination of different implications even can reach more than the hundreds of thousands bar between the order is simultaneously along with the upgrading or the transition of system; The replacement of new and old order also can appear in the system equipment, for equipment has proposed higher order testing requirement.
For instance, following command format is a kind of aggregate command form common on the network equipment:
Display{ip{routi|vpn}|clock[config]|fib{acl|verbose|vpn}}
The mentioned order form showed with the form of command tree just formed command tree as shown in Figure 1; The structure of command tree comes from syntax rule among Fig. 1, and what wherein be labeled as leafy node is the place that < CR>prompting is arranged in the order line, and this order line of said < CR>prompting expression finishes; Can import carriage return and carry out test; If do not contain < CR>information in the order line, represent that then this order line can not finish, need proceed to fill in; Other node is word or the parameter in the order line, is the part of a complete order; And the node of the display representative at command tree top can be regarded the root node of command tree as.
Just can form a complete order like this from root node to arbitrary leafy node, when carrying out the test of command line interface, just need carry out testing authentication the complete order of each bar.And according to command format of the prior art and command tree structure, equipment is carrying out order when test, often need expend more system resources to realize testing computational process, and when order quantity was more, the efficient that test is contribute is very low also.
In sum; In realizing process of the present invention, the inventor finds to exist at least in the prior art following problem: according to command format of the prior art and command tree structure, equipment is when carrying out the order test; Need expend more system resources and realize testing computational process; Simultaneously when order quantity when more, the efficient of test is very low also, can't satisfy the testing requirement of system upgrade or transition.
Summary of the invention
Embodiment of the present invention technical problem to be solved is to provide a kind of method of testing and device of command line interface; Can simplify the structure of command tree; Set up a command tree that is easy to test; Improve testability, thereby reduced the waste of calculation of equipments resource, and improved the efficient of test greatly.
Embodiment of the present invention realizes through following technical scheme:
A kind of method of testing of command line interface comprises:
The aggregate command that acquisition need be tested;
Begin from the root node of said aggregate command, said aggregate command is carried out the conversion of binary tree of equal value;
Leafy node to said binary tree of equal value travels through, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information;
Each bar single command to being obtained is tested;
Wherein, said leafy node to said binary tree of equal value travels through, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information, specifically comprises:
Leafy node to said binary tree of equal value travels through; Each leafy node of said binary tree of equal value link to root node is linked together; And carry out the path access of leafy node to root node, obtain each bar single command and corresponding expection information.
Embodiment of the present invention also provides a kind of testing apparatus of command line interface, comprising:
The aggregate command acquiring unit is used to obtain the aggregate command that need test;
The command tree conversion unit is used for beginning from the root node of the aggregate command that obtained, said aggregate command is carried out the conversion of binary tree of equal value;
The single command acquiring unit is used for the leafy node of said binary tree of equal value is traveled through, with said etc.
Each leafy node of valency binary tree links together to the link of root node, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information;
The order test cell is used for each the bar single command that is obtained is tested.
Can find out by the above-mentioned technical scheme that provides; The aggregate command that at first need test through acquisition, the root node from said aggregate command begins then, said aggregate command is carried out the conversion of binary tree of equal value; Leafy node to said binary tree of equal value travels through again; And carry out the path access of leafy node to root node, and obtain each bar single command and corresponding expection information, at last each the bar single command that is obtained is tested.Simplify the structure of command tree like this through the conversion of binary tree of equal value, set up a command tree that is easy to test, improved testability, thereby reduced the waste of calculation of equipments resource, and improved the efficient of test greatly.
Description of drawings
Fig. 1 is a command tree structural representation common in the prior art;
Fig. 2 is the schematic flow sheet of the said method of embodiment of the present invention;
Fig. 3 carries out the structural representation after binary tree of equal value transforms for aggregate command in the son that embodiment of the present invention is given an example;
Fig. 4 is the order line structural representation under many views in the prior art;
Fig. 5 is the structural representation of the said device of embodiment of the present invention.
Embodiment
Embodiment of the present invention provides a kind of method of testing and device of command line interface.For high-end data equipment, when carrying out the test of command line interface, usually face a lot of problems, many views problem for example, multi-level problem is ordered problems such as branch problem and untapped order more.Embodiment of the present invention is through carrying out common aggregate command the conversion of binary tree of equal value; Simplify the structure of command tree, set up out a command tree that is easy to test, improved testability; Thereby reduced the waste of calculation of equipments resource, and improved the efficient of test greatly.
The said method flow process can also be used TCL (Tool Command Language; Tool Command Language) test script language is write; Each process step is generated the functional module of automatic test, and then combine the order line testing tool to use.So just can in test process, realize automatic test, can also support polytype testing requirements such as validity, consistency simultaneously, improve the testing efficiency of command line interface.
For better describing embodiment of the present invention, combine the accompanying drawing specific embodiments of the invention to describe at present, shown in Figure 2 is the schematic flow sheet of the said method of embodiment of the present invention, said method comprises:
Step 11: the aggregate command that acquisition need be tested;
Specifically, when through Command Line Interface equipment under test being carried out test operation exactly, utilize the particular functionality module to obtain a certain the aggregate command that needs are tested.
Step 12: aggregate command is carried out the conversion of binary tree of equal value.
Specifically, exactly after obtaining the aggregate command that needs test, begin, adopt the mode of preorder traversal that said aggregate command is converted into binary tree of equal value from the root node of said aggregate command.Wherein in binary tree of equal value, increase and to reach the sky node and represent optional relation and coordination in the said aggregate command, increase unreachable empty node and represent the essential relation in the said aggregate command.
The concrete mode of preorder traversal that adopts is carried out the conversion of binary tree of equal value, can realize through following process:
Begin from the root node of said aggregate command, first ground floor node is designated the left branch of binary tree of equal value.At this moment, if said ground floor node is option, then will be designated and reach the sky node with the corresponding right branch of said ground floor node; If said ground floor node is an essential option, then will be designated unreachable empty node with the corresponding right branch of said ground floor node.
Simultaneously, if the ground floor node of said aggregate command has a plurality of and lists, then second ground floor node arranged side by side is identified on the left branch under above-mentioned definite reached at the sky node.At this moment; And if to list be exactly two; That is to say that second ground floor node is last ground floor node; Judge these two and whether list be optional so again, if these two and list and be option, then will be designated and to reach the sky node with said second corresponding right branch of ground floor node; If these two and list and be essential option, that is to say and must select one of them, then will be designated unreachable empty node with said second corresponding right branch of ground floor node.
And then the rest may be inferred; And if listd more than 3 or 3; Then according to above operation a plurality of ground floor nodes arranged side by side are identified successively, whether to the last during a ground floor node, judging that these are a plurality of again and lising is optional; And operate accordingly again according to judged result, so just realized said aggregate command is carried out the conversion of binary tree of equal value.
For instance, as if the aggregate command that is obtained be: COMMAND1 [A|B|C].Here A, B and C are exactly three ground floor nodes arranged side by side of aggregate command COMMAND1, the meaning that symbol " | " expression is arranged side by side; And symbol " [" and "] " is exactly to represent the optional meaning, that is to say A, B, and three of C also list and are option, and this aggregate command COMMAND1 can one select, and directly carries out.
Be illustrated in figure 3 as this aggregate command and carry out the structural representation after binary tree of equal value transforms; Among the figure: COMMAND1 begins from root node; At first first ground floor node A is designated left branch, owing to there is option arranged side by side to exist, can reaches the sky node so will the right branch corresponding be designated with A; Here can use " O " to identify, also can identify with other symbol; Then second ground floor node B arranged side by side is identified on the left branch under above-mentioned definite reached at the sky node; Just under the left branch under the node O; Owing to also have an option C arranged side by side to exist, can reach sky node O so will the right branch corresponding be designated with B; Same, again with the 3rd ground floor node C arranged side by side according to above method, be identified on the above-mentioned left branch that reaches under the sky node O; Be last ground floor node owing to C this moment, while A, B; Three of C also list and are option, can reach sky node O so will the right branch corresponding with C be designated.
In addition, in above example, if the aggregate command that is obtained is: COMMAND1{A|B|C}.The meaning that the symbol here " { " and " } " expression is essential, A just, B, these three of C also list and are essential option, and this aggregate command COMMAND1 must select one just can carry out executable operations.
When this aggregate command is carried out the conversion of binary tree of equal value, to node A, B; The identification procedure of C is identical with said method, just after having identified C, because C is last ground floor node; A simultaneously, B, three of C also list and are essential option; So the right branch corresponding with C is designated unreachable empty node, unreachable here empty node can use " X " to identify, and also can identify with other symbol.
In addition, when including one or more minutes nodes under the ground floor node of said aggregate command, said ground floor node as root node, is carried out the conversion of binary tree of equal value to said ground floor node.In the above-mentioned example of being takeed; Aggregate command COMMAND1 [A|B|C]; Ground floor node A wherein or B or C might also include one or more branch nodes down; This moment just can be with A or B or C as root node, according to above-described method A or B or C is carried out the conversion of binary tree of equal value, finally just can obtain a complete binary tree of equal value.
Step 13: the traversal leafy node obtains single command and expection information.
Specifically; Exactly in the operation of carrying out above step 12; Aggregate command is carried out after the conversion of binary tree of equal value; Leafy node to said binary tree of equal value travels through again, and carries out the path access of leafy node to root node, thereby obtains each bar single command and corresponding expection information.
Here the method that travels through leafy node can be that each leafy node of said binary tree of equal value link to root node is linked together; And carry out the path access of leafy node, thereby obtain each bar single command and corresponding expection information to root node.Wherein, if leafy node is for can reach sky node or unreachable empty node, this leafy node is being connected on the link of root node so, all non-NULL left branch all are the expection informations of the single command that obtained; And below the left branch of being had time, more further non-NULL left branch also is the expection information of the single command that obtained.That is to say that if be connected on the link of root node at leafy node, left branch is not the sky node, then this left branch is exactly the expection information of single command; If this left branch is the sky node, following one deck of this left branch of arriving so, this time if the left branch of one deck is not the sky node down, then one deck left branch also is the expection information of single command under this; But if the left branch of following one deck is the sky node, then need carry out aforesaid operations again, promptly arrive following one deck of this layer left branch again; Whether the left branch of judging one deck under this again is the sky node; If not empty node, this left branch is exactly the expection information of single command so, by that analogy.
In addition, if said leafy node is for can reach the sky node, comprise final command cue information in the expection information by the single command that said leafy node obtained so; If said leafy node is unreachable empty node, so by just not comprising final command cue information in the expection information of the single command that said leafy node obtained.
In the above-mentioned example of being takeed, the fractionation of aggregate command COMMAND1 [A|B|C] traversal travels through according to the binary tree of equal value among Fig. 3, can above-mentioned aggregate command be split into four single commands:
COMMAND1?A
COMMAND1?B
COMMAND1?C
COMMAND1
When obtaining above four single commands, can also obtain its expection information on Command Line Interface respectively, form one-to-one relationship, shown in the table 1 specific as follows:
Sequence number Split the single command that obtains The expection information
1 COMMAND1?A ?<CR>
2 COMMAND1?B ?<CR>
3 COMMAND1?C ?<CR>
4 COMMAND1 ?{A}{B}{C}{<CR>}
(table 1)
Above expection information < CR>representes that this order line finishes, and can import carriage return and directly carry out test; And { A}{B}{C}{ < CR>} arranged side by side representes that these four informations are to occur side by side, and order in no particular order.
Step 14: each the bar single command to being obtained is tested.
Specifically, exactly after the operation of carrying out above step 13, just can carry out test operation, realize all standing that order is decomposed each the bar single command that is obtained.
In addition; When said aggregate command increase sandwich construction, when just the level of command tree is deep, in the conversion process of carrying out binary tree of equal value; Can the branch below the said unreachable empty node be removed; Directly beta pruning has so just improved the efficient that test is contribute greatly, has further reduced the waste of calculation of equipments resource.
Through above operating procedure; Just can common aggregate command be carried out the conversion of binary tree of equal value; Simplify the structure of command tree, set up out a command tree that is easy to test, improved testability; Thereby reduced the waste of calculation of equipments resource, and improved the efficient of test greatly.
In addition; In the operation of carrying out above step 11; During aggregate command that acquisition need be tested; If when the aggregate command that obtained is the combination of a plurality of options of random order, then said aggregate command optimization is split as a plurality of alternative aggregate command, and then each alternative aggregate command is carried out follow-up processing operation to this.
Optimization described here splits and can realize through following method: select Total Options, and with its forward combination, obtain an alternative aggregate command; The alternative aggregate command that combination is obtained according to forward is removed an option successively at afterbody, obtains the corresponding aggregate command that substitutes; Select Total Options, and, obtain an alternative aggregate command its reverse combination; According to the alternative aggregate command that reverse combination obtained, remove an option successively at afterbody, obtain the corresponding aggregate command that substitutes; An each option in a plurality of options, corresponding aggregate command that substitutes of acquisition only selected; Do not select any one option, obtain an alternative aggregate command; Check all alternative aggregate command that obtained, subdue the alternative aggregate command of repetition.
Positive and negative twice selection through such proved that also the succession of each option arranged side by side does not have dependence.
For instance, if obtain aggregate command be: COMMAND2{A|B|C|D|E} *
Comprising 5 can select the item: A, B, C, D, E.These five options since marked asterisk ( *), then expression can select wherein several to be attached to order COMMAND2 back arbitrarily, and additional order also is arbitrarily; And then operate according to above-described optimization method for splitting, obtain one-to-one relationship as shown in table 2 below:
1, selects Total Options, forward combination (being 1 in the table 2)
2, according to the forward combination, successively decrease at afterbody successively (being 2-5 in the table 2)
3, select Total Options, reverse combination (being 6 in the table 2)
4, according to oppositely combination, successively decrease at afterbody successively (being 7-10 in the table 2)
5, each option of selection (being 11-15 in the table 2)
When 6, an option does not select (being 16 in the table 2)
7, subdue duplicate keys (5 in the table 2 and 11,10 and 15 is actually repetition)
Sequence number Split the alternative aggregate command that obtains The expection information
1 COMMAND2?A?B?C?D?E <CR>
2 COMMAND2?A?B?C?D {<CR>}{E}
3 COMMAND2?A?B?C {<CR>}{E}{D}
4 COMMAND2?A?B {<CR>}{E}{D}{C}
5 COMMAND2?A {<CR>}{E}{D}{C}{B}
6 COMMAND2?E?D?C?B?A <CR>
7 COMMAND2?E?D?C?B {<CR>}{A}
8 COMMAND2?E?D?C {<CR>}{A}{B}
[0072]
9 COMMAND2 E D {<CR>{ A}{B}{C}
10 COMMAND2 E {<CR>{ A}{B}{C}{D}
11 (repeating 5) COMMAND2 A {<CR>{ B}{C}{D}{E}
12 COMMAND2 B {<CR>{ A}{C}{D}{E}
13 COMMAND2 C {<CR>{ A}{B}{D}{E}
14 COMMAND2 D {<CR>{ A}{B}{C}{E}
15 (repeating 10) COMMAND2 E {<CR>{ A}{B}{C}{D}
16 COMMAND2 { A}{B}{C}{D}{E}
(table 2)
Through above optimization fractured operation, just can said aggregate command optimization be split as a plurality of alternative aggregate command, and then each alternative aggregate command is carried out follow-up processing operation.
In addition, above-described optimization splits and also can realize through such method: select Total Options, and with its forward combination, obtain an alternative aggregate command that comprises Total Options; Said first option of stem that comprises the alternative aggregate command of Total Options is removed, obtain an alternative aggregate command; First option of the stem that will remove is placed on afterbody, obtains the alternative aggregate command that another comprises Total Options; And then repeat the operation that above second step and the 3rd goes on foot; Circulation current first option of stem that comprises the alternative aggregate command of Total Options is removed; Obtain the corresponding aggregate command that substitutes; And first option of the stem that will remove is placed on the afterbody of corresponding substitute aggregate command, obtains to comprise accordingly the alternative aggregate command of Total Options; An each option in a plurality of options, corresponding aggregate command that substitutes of acquisition only selected; Do not select any one option, obtain an alternative aggregate command; Check all alternative aggregate command that obtained, subdue the alternative aggregate command of repetition.
In addition, described optimization splits except realizing according to above method, can also be through to the user operation interface being provided; By the user voluntarily the fractionation compound mode is set; Thereby obtain the corresponding aggregate command that substitutes, improved and optimized the flexibility that splits, optimized test process.
In addition, when each bar order is tested, all right other correctness of verification command level, and when the command-levels mistake, carry out corresponding record.Specifically; Under the active user's rank under the said aggregate command, each the bar single command that is obtained is tested, if there be a certain single command not exist; The command-levels mistake of this single command then, and the command-levels that writes down this single command is write low error situation.
Except carrying out above positive test, can also carry out negative testing.Specifically, under other low user class of said active user's level, obtain the final single command of each bar of said aggregate command, final single command described here is to comprise < CR>prompting, can directly import the single command that test is carried out in carriage return; And then the final single command of each bar that is obtained tested, if there be a certain final single command to exist, the command-levels mistake of this final single command then, and the command-levels that writes down this final single command is write high error situation.
For instance, as if the aggregate command that obtains be: COMMAND3 [AB|CD]; And active user's rank is 2, i.e. configuration stage.Carry out the conversion of binary tree of equal value according to the above method, and after carrying out the traversal of leafy node, obtain rank checking project as shown in table 3 below, list item 1~5th wherein, the content of positive test, list item 6~7th, the content of negative testing:
Sequence number Rank Split the individual command that obtains The expection information
1 2: configuration stage COMMAND3?A?B <CR>
2 2: configuration stage COMMAND3?A {B}
3 2: configuration stage COMMAND3?C?D <CR>
4 2: configuration stage COMMAND3?C D
5 2: configuration stage COMMAND3 {A}{C}
6 (deriving from 1) 1: monitoring level COMMAND3?A?B Order does not exist
7 (deriving from 3) 1: monitoring level COMMAND3?C?D Order does not exist
(table 3)
Can know that from last table 3 in active user's rank, when promptly carrying out the positive test like list item 1~5 under the configuration stage, each individual command that is obtained exists, command-levels of this each individual command of expression is not write low; Then at other low user class of active user's level, when promptly carrying out the negative testing like list item 6~7 under the monitoring level, two individual commands that obtained are non-existent, and command-levels of these these two individual commands of expression is not write height.The conclusion of comprehensive positive and negative test just can learn that the command-levels of the order in list item 6 and 7 is correct.
Here if a certain single command is not final single command, then need not carry out negative testing, for example go up the list item 2 in the table 3 this single command; 4; Order in 5 just need not carried out negative testing, and this is because these orders are not the final order that comprises < CR>information, that is to say that these orders not exclusively belong to current order; Might belong to prefix or the parameter of even lower level in not ordering; So just need not carry out reverse test, thereby further simplify the process of checking, improve verification efficiency these orders.
In addition; When there is a plurality of view in command line interface; Be illustrated in figure 4 as the order line structural representation under many views, in this case, can first view of user's login be used as root node; It is leafy node that other a plurality of views are used as, and said a plurality of views are carried out the conversion of binary tree of equal value.Because first view when user logins might be different at every turn; So when choosing root node; Only need first view of user's login be used as root node, be leafy node and other views are used as, and then these a plurality of views carried out the conversion of binary tree of equal value.
After obtaining many view equivalents binary tree, can each view be used as root node, a plurality of aggregate command under each view are carried out the conversion of binary tree of equal value again, thereby just under many views, formed the forest of Management Information Base; And then traversal each view of the binary tree of equal value after transforming, obtain each the bar aggregate command under a plurality of views; So just can carry out the operation of above-mentioned steps 12 to this each bar aggregate command.
In addition; After a plurality of views are carried out the conversion of binary tree of equal value; Can also the leafy node of many view equivalents binary tree of being obtained be traveled through, and carry out the path access of leafy node, thereby obtain each view and corresponding expection aggregate command to root node; And then import said expection aggregate command, and verify with this whether the view corresponding with this expection aggregate command exists, obtain view checking result.Specifically, if the expection aggregate command of input does not exist, then corresponding with this expection aggregate command view is non-existent also; If the expection aggregate command of input exists, then corresponding with this expection aggregate command view also exists.
The above-mentioned view checking result who obtains also can be used as the precondition that the aggregate command under this view is tested.Specifically, if view checking result then can test the aggregate command under this view for this view exists; Otherwise,, then need not test the aggregate command under this view if view checking result does not exist for this view.
In addition, after each the bar single command that is obtained is tested, can also obtain original order in the test process.Be exactly specifically; When the leafy node to each the bar aggregate command under all views travels through; If find not meet the not covering branch of expection information; Then the branch to accord with expectation information in whole branches identifies, and said here the covering refers to main command in syntax rule, do not describe other branches that this leafy node is in coordination.
After the whole single command tests that obtained are finished, the more imperfect branch that never identifies is done the traversal of leafy node, thereby obtain finally not meet the part order of expection information, original order in the test process just.Here in order to make imperfect branch more clear, can there be the branch of the accord with expectation information of sign to carry out beta pruning those and handles, just they are removed; So just can obtain an incomplete command tree, and then travel through the leafy node of these imperfect branches, thereby obtain original order.
Embodiment of the present invention also provides a kind of testing apparatus of command line interface; Like Fig. 5 is the structural representation of the said device of embodiment of the present invention, and said device comprises aggregate command acquiring unit, command tree conversion unit, single command acquiring unit and order test cell.Wherein said aggregate command acquiring unit is used to obtain the aggregate command that need test; Specifically; When equipment under test being carried out test operation, obtain the aggregate command that a certain needs are tested exactly by described aggregate command acquiring unit through Command Line Interface.
Described command tree conversion unit is used for beginning from the root node of the aggregate command that is obtained, and said aggregate command is carried out the conversion of binary tree of equal value.Specifically, exactly after obtaining the aggregate command that a certain needs test, begin, adopt the mode of preorder traversal that said aggregate command is converted into binary tree of equal value from the root node of said aggregate command.Wherein in binary tree of equal value, increase and to reach the sky node and represent optional relation and coordination in the said aggregate command, increase unreachable empty node and represent the essential relation in the said aggregate command.
Described single command acquiring unit is used for the leafy node of said binary tree of equal value is traveled through, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information.Specifically, be that each leafy node of binary tree of equal value link to root node is linked together, and carry out the path access of leafy node, thereby obtain each bar single command and corresponding expection information to root node.
Described order test cell is used for each the bar single command that is obtained is tested, and realizes all standing that order is decomposed.
In addition, can also comprise the optimization split cells in the said testing apparatus, when described optimization split cells is used to work as the aggregate command that is obtained and is the combination of a plurality of options of random order, said aggregate command optimization is split as a plurality of alternative aggregate command; By said command tree conversion unit each alternative aggregate command is handled operation again, as above the method execution mode is said for concrete optimization method for splitting.
Can also comprise user's operational module in the described optimization split cells, described user's operational module is used to offer user interface, is provided with voluntarily by the user and splits combination, obtains the corresponding aggregate command that substitutes.
In addition, in said testing apparatus, can also comprise the rank authentication unit, described rank authentication unit is used for the command-levels of the single command that is obtained is verified, and when the command-levels mistake, carries out corresponding record.Specifically, under active user's rank, each the bar single command that is obtained is tested, if there be a certain single command not exist, the command-levels mistake of this single command then, and the command-levels that writes down this single command is write low error situation; Under other low user class of said active user's level; The final single command of each bar to being obtained is tested; If there is a certain final single command to exist, the command-levels mistake of this final single command then, and the command-levels that writes down this final single command is write high error situation.
In addition; In said testing apparatus, can also comprise the view converting unit; Described view converting unit is used for when there is a plurality of view in command line interface; First view of user's login is used as root node, and it is leafy node that other a plurality of views are used as, and said a plurality of views are carried out the conversion of binary tree of equal value; And each view is used as root node, a plurality of aggregate command under each view are carried out the conversion of binary tree of equal value; Behind the view of binary tree of equal value after traversal transforms, obtain each the bar aggregate command under a plurality of views.
In addition, can also comprise that in said testing apparatus utility command is not found the unit, described not utility command finds that the unit is used for after each the bar single command that is obtained is tested, and finds original order in the test process.Specifically, when the leafy node to each the bar aggregate command under all views traveled through, if find not meet the not covering branch of expection information, then the branch to accord with expectation information in whole branches identified; After the whole single command tests that obtained are finished, the traversal of leafy node is done by the imperfect branch that does not identify, thereby obtain original order in the test process.
Above-described testing apparatus can be arranged on the equipment to be tested, also can be arranged to independent functional entity.
In sum; Embodiment of the present invention is through carrying out common aggregate command the conversion of binary tree of equal value; Simplify the structure of command tree, set up out a command tree that is easy to test, improved testability; Thereby reduced the waste of calculation of equipments resource, and improved the efficient of test greatly; In test process, can also solve the problem that many views exist, and can effectively verify command-levels, all original orders on the simultaneously all right discovering device have improved the coverage effect of test, have cleared away the test blind area.
The above; Be merely the preferable embodiment of the present invention; But protection scope of the present invention is not limited thereto; Any technical staff who is familiar with the present technique field is in the technical scope that the embodiment of the invention discloses, and the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of claim.

Claims (19)

1. the method for testing of a command line interface is characterized in that,
The aggregate command that acquisition need be tested;
Begin from the root node of said aggregate command, said aggregate command is carried out the conversion of binary tree of equal value;
Leafy node to said binary tree of equal value travels through, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information;
Each bar single command to being obtained is tested;
Wherein, said leafy node to said binary tree of equal value travels through, and carries out the path access of leafy node to root node, obtains each bar single command and corresponding expection information, specifically comprises:
Leafy node to said binary tree of equal value travels through; Each leafy node of said binary tree of equal value link to root node is linked together; And carry out the path access of leafy node to root node, obtain each bar single command and corresponding expection information.
2. the method for testing of command line interface as claimed in claim 1 is characterized in that, said method also comprises:
When said aggregate command increase sandwich construction, during the conversion of the row equivalent binary tree of going forward side by side, the branch below the unreachable empty node is removed.
3. the method for testing of command line interface as claimed in claim 1 is characterized in that, said method also comprises:
When said aggregate command is the combination of a plurality of options of random order, said aggregate command optimization is split as a plurality of alternative aggregate command.
4. the method for testing of command line interface as claimed in claim 3 is characterized in that, described optimization splits and is specially:
Select Total Options, and, obtain an alternative aggregate command its forward combination;
The alternative aggregate command that combination is obtained according to forward is removed an option successively at afterbody, obtains the corresponding aggregate command that substitutes;
Select Total Options, and, obtain an alternative aggregate command its reverse combination;
According to the alternative aggregate command that reverse combination obtained, remove an option successively at afterbody, obtain the corresponding aggregate command that substitutes;
An each option in a plurality of options, corresponding aggregate command that substitutes of acquisition only selected;
Do not select any one option, obtain an alternative aggregate command;
Check all alternative aggregate command that obtained, subdue the alternative aggregate command of repetition.
5. the method for testing of command line interface as claimed in claim 3 is characterized in that, described optimization splits and is specially:
A, selection Total Options, and, obtain an alternative aggregate command that comprises Total Options with its forward combination;
B, said first option of stem that comprises the alternative aggregate command of Total Options is removed, obtain an alternative aggregate command;
C, first option of stem that will remove are placed on afterbody, obtain the alternative aggregate command that another comprises Total Options;
Repeat above B step and C step; Circulation current first option of stem that comprises the alternative aggregate command of Total Options is removed; Obtain the corresponding aggregate command that substitutes; And first option of the stem that will remove is placed on the afterbody of corresponding substitute aggregate command, obtains to comprise accordingly the alternative aggregate command of Total Options;
An each option in a plurality of options, corresponding aggregate command that substitutes of acquisition only selected;
Do not select any one option, obtain an alternative aggregate command;
Check all alternative aggregate command that obtained, subdue the alternative aggregate command of repetition.
6. the method for testing of command line interface as claimed in claim 3 is characterized in that, described optimization splits and is specially:
Through operation interface being provided to the user, by the user fractionation combination is set voluntarily, obtain the corresponding aggregate command that substitutes.
7. the method for testing of command line interface as claimed in claim 1 is characterized in that, said method also comprises:
Under the active user's rank under the said aggregate command; Each bar single command to being obtained is tested; If there be a certain single command not exist, the command-levels mistake of this single command then, and the command-levels that writes down this single command is lower than due other error situation of level.
8. the method for testing of command line interface as claimed in claim 7 is characterized in that, said method also comprises:
Under other low user class of said active user's level, obtain the final single command of each bar of said aggregate command;
The final single command of each bar to being obtained is tested, if there is a certain final single command to exist, and the command-levels mistake of this final single command then, and the command-levels that writes down this final single command is higher than due grade of other error situation.
9. the method for testing of command line interface as claimed in claim 1 is characterized in that, said method also comprises:
When there is a plurality of view in command line interface, first view of user's login is used as root node, it is leafy node that other a plurality of views are used as, and said a plurality of views are carried out the conversion of binary tree of equal value;
Each view is used as root node, a plurality of aggregate command under each view is carried out the conversion of binary tree of equal value;
The view of binary tree of equal value after traversal transforms obtains each the bar aggregate command under a plurality of views.
10. the method for testing of command line interface as claimed in claim 9 is characterized in that, after said a plurality of views are carried out the conversion of binary tree of equal value, also comprises:
Leafy node to many view equivalents binary tree of being obtained travels through, and carries out the path access of leafy node to root node, obtains each view and corresponding expection aggregate command;
Import said expection aggregate command, verify whether the view corresponding with this expection aggregate command exists, obtain view checking result.
11. the method for testing of command line interface as claimed in claim 10 is characterized in that, said method also comprises:
Said view is verified the result as the precondition that the aggregate command under this view is tested,
If the result is for this view exists in the view checking, then the aggregate command under this view is tested; Otherwise, then the aggregate command under this view is not tested.
12. the method for testing of command line interface as claimed in claim 9 is characterized in that, said method also comprises:
When the leafy node to each the bar aggregate command under all views traveled through, if find not meet the not covering branch of expection information, then the branch to accord with expectation information in whole branches identified;
After the whole single command tests that obtained were finished, the traversal to leafy node is done by the imperfect branch that does not identify obtained original order in the test process.
13. the testing apparatus of a command line interface is characterized in that, comprising:
The aggregate command acquiring unit is used to obtain the aggregate command that need test;
The command tree conversion unit is used for beginning from the root node of the aggregate command that obtained, said aggregate command is carried out the conversion of binary tree of equal value;
The single command acquiring unit; Be used for the leafy node of said binary tree of equal value is traveled through; Each leafy node of said binary tree of equal value link to root node is linked together; And carry out the path access of leafy node to root node, obtain each bar single command and corresponding expection information;
The order test cell is used for each the bar single command that is obtained is tested.
14. the testing apparatus of command line interface as claimed in claim 13 is characterized in that, also comprises in the said testing apparatus:
Optimize split cells, when being used to work as the aggregate command that is obtained and being the combination of a plurality of options of random order, said aggregate command optimization is split as a plurality of alternative aggregate command;
By said command tree conversion unit each alternative aggregate command is handled operation again.
15. the testing apparatus of command line interface as claimed in claim 14 is characterized in that, comprises in the said optimization split cells:
User's operational module is used to offer user interface, is provided with voluntarily by the user and splits combination, obtains the corresponding aggregate command that substitutes.
16. the testing apparatus of command line interface as claimed in claim 15 is characterized in that, also comprises in the said testing apparatus:
The rank authentication unit is used for the command-levels of the single command that obtained is verified, and when the command-levels mistake, carries out corresponding record; Wherein:
Under active user's rank, each the bar single command that is obtained is tested, if there be a certain single command not exist, the command-levels mistake of this single command then, and the command-levels that writes down this single command is lower than due other error situation of level;
Under other low user class of said active user's level; The final single command of each bar to being obtained is tested; If there is a certain final single command to exist, the command-levels mistake of this final single command then, and the command-levels that writes down this final single command is higher than due grade of other error situation.
17. the testing apparatus of command line interface as claimed in claim 13 is characterized in that, also comprises in the said testing apparatus:
The view converting unit is used for when there is a plurality of view in command line interface, and first view of user's login is used as root node, and it is leafy node that other a plurality of views are used as, and said a plurality of views are carried out the conversion of binary tree of equal value; And each view is used as root node, a plurality of aggregate command under each view are carried out the conversion of binary tree of equal value;
Behind the view of binary tree of equal value after traversal transforms, obtain each the bar aggregate command under a plurality of views.
18. the testing apparatus of command line interface as claimed in claim 17 is characterized in that, also comprises in the said testing apparatus:
Utility command is not found the unit, is used for after each the bar single command that is obtained is tested, and finds original order in the test process, wherein:
When the leafy node to each the bar aggregate command under all views traveled through, if find not meet the not covering branch of expection information, then the branch to accord with expectation information in whole branches identified; After the whole single command tests that obtained were finished, the traversal to leafy node is done by the imperfect branch that does not identify obtained original order in the test process.
19. the testing apparatus like one of them described command line interface of claim 13-18 is characterized in that, said testing apparatus is arranged on the equipment to be tested, or is arranged to independent functional entity.
CN 200810189611 2007-12-27 2007-12-27 Test method and device for command line interface Expired - Fee Related CN101471826B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200810189611 CN101471826B (en) 2007-12-27 2007-12-27 Test method and device for command line interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200810189611 CN101471826B (en) 2007-12-27 2007-12-27 Test method and device for command line interface

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN2007103023842A Division CN101197734B (en) 2007-12-27 2007-12-27 Test approach and device for command line interface

Publications (2)

Publication Number Publication Date
CN101471826A CN101471826A (en) 2009-07-01
CN101471826B true CN101471826B (en) 2012-12-12

Family

ID=40828969

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200810189611 Expired - Fee Related CN101471826B (en) 2007-12-27 2007-12-27 Test method and device for command line interface

Country Status (1)

Country Link
CN (1) CN101471826B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102495933A (en) * 2011-12-14 2012-06-13 黄桂青 Systematic auto balancing equivalent transformation method for constructive geometry binary tree structure of Boolean operation
CN103678100B (en) * 2012-09-10 2016-09-14 联芯科技有限公司 The application automated testing method of terminal and system thereof
CN104317724A (en) * 2014-11-17 2015-01-28 上海斐讯数据通信技术有限公司 Code automation test method of CLI module under Linux platform
CN107977310B (en) * 2017-11-06 2021-01-26 杭州迪普科技股份有限公司 Traversal test command generation method and device
CN109857667B (en) * 2019-02-03 2021-10-08 苏州市龙测智能科技有限公司 Interface automation test method, test device, test equipment and storage medium
CN110071848B (en) * 2019-03-27 2020-12-08 武汉思普崚技术有限公司 Method, apparatus and storage medium for automated test command line commands
US11210757B2 (en) * 2019-12-13 2021-12-28 Advanced Micro Devices, Inc. GPU packet aggregation system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1719786A (en) * 2004-07-08 2006-01-11 中兴通讯股份有限公司 Automatic testing system and method for command of command line interface of data communication apparatus

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1719786A (en) * 2004-07-08 2006-01-11 中兴通讯股份有限公司 Automatic testing system and method for command of command line interface of data communication apparatus

Also Published As

Publication number Publication date
CN101471826A (en) 2009-07-01

Similar Documents

Publication Publication Date Title
CN101197734B (en) Test approach and device for command line interface
CN101471826B (en) Test method and device for command line interface
CN104598376B (en) The layering automatization test system and method for a kind of data-driven
US8151248B1 (en) Method and system for software defect management
CN101984416B (en) Method and device for generating test case
CN102880667B (en) Test task scheduling method based on critical paths and tabu search
CN102053912A (en) Device and method for automatically testing software based on UML (unified modeling language) graphs
CN101808109A (en) Model conversion and formalization verification method of semantic Web service combination
CN103678446B (en) Improved mode map based on Data View and database table
CN102750301A (en) Blueprint generating method for integrated avionic system model aiming at architecture analysis and design language (AADL) description
CN105760296A (en) Automation testing control method, device and terminal
CN104915262A (en) Calibration system and method based on EXCEL data structure
CN105912601A (en) Partition storage method for distributed real-time memory database of energy management system
CN102970163B (en) Power communication backbone network node upgrade method and system
CN105187255A (en) Fault analysis method, fault analysis device and server
CN111324538A (en) Micro-service parallel test environment management method based on dynamic routing
CN104978269A (en) Automatic testing method
CN111142929A (en) Firmware configuration method, device, equipment and medium in equipment production process
CN105681070A (en) Method and system for automatically collecting and analyzing computer cluster node information
CN110784349B (en) Automatic generation method and device for power communication equipment and network cutover scheme
CN107748720A (en) A kind of method and device of the service parameter of detection function test cases
CN115622260B (en) Centralized monitoring method and system for multi-energy combination
CN110533320A (en) A kind of power equipment power failure planning device based on Hadoop platform
CN113206712B (en) Software radio conformance testing method and system
CN106612213A (en) An equipment test method and apparatus

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20121212

Termination date: 20151227

EXPY Termination of patent right or utility model