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

Test method and device for command line interface Download PDF

Info

Publication number
CN101471826A
CN101471826A CNA200810189611XA CN200810189611A CN101471826A CN 101471826 A CN101471826 A CN 101471826A CN A200810189611X A CNA200810189611X A CN A200810189611XA CN 200810189611 A CN200810189611 A CN 200810189611A CN 101471826 A CN101471826 A CN 101471826A
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.)
Granted
Application number
CNA200810189611XA
Other languages
Chinese (zh)
Other versions
CN101471826B (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

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; while is 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, what wherein be labeled as leafy node is to have in the order line<CR〉prompting the place, said<CR〉point out this order line of expression to finish, can import carriage return and carry out test, if do not contain in the order line<CR〉information, 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 needs to 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 that there are the following problems at least in the prior art: 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 is achieved through the following technical solutions:
A kind of method of testing of command line interface comprises:
The aggregate command that acquisition need be tested;
From the root node of described aggregate command, described aggregate command is carried out the conversion of binary tree of equal value;
Leafy node to described 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 the bar single command that is obtained is tested.
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 from the root node of the aggregate command that is obtained, and described 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 described 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;
The order test cell is used for each the bar single command that is obtained is tested.
By the above-mentioned technical scheme that provides as can be seen, aggregate command at first by obtaining to test, then from the root node of described aggregate command, described aggregate command is carried out the conversion of binary tree of equal value, leafy node to described 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 by 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 described method of embodiment of the present invention;
Fig. 3 carries out structural representation after binary tree of equal value transforms for aggregate command in the embodiment of the present invention given example;
Fig. 4 is the order line structural representation under many views in the prior art;
Fig. 5 is the structural representation of the described 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 by 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 use in conjunction with the order line testing tool.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, now in conjunction with the accompanying drawings the specific embodiment of the present invention is described, Figure 2 shows that the schematic flow sheet of the described method of embodiment of the present invention, described method comprises:
Step 11: the aggregate command that acquisition need be tested;
Specifically, when by Command Line Interface equipment under test being carried out test operation exactly, utilize specific functional 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 the aggregate command that needs of acquisition are tested,, adopt the mode of preorder traversal that described aggregate command is converted into binary tree of equal value from the root node of described aggregate command.Wherein in binary tree of equal value, increase and to reach the sky node and represent optional relation and coordination in the described aggregate command, increase unreachable empty node and represent essential relation in the described aggregate command.
The concrete mode of preorder traversal that adopts is carried out the conversion of binary tree of equal value, can realize by following process:
From the root node of described aggregate command, first ground floor node is designated the left branch of binary tree of equal value.At this moment, if described ground floor node is option, then will the right branch corresponding be designated and reaches the sky node with described ground floor node; If described ground floor node is an essential option, then the right branch corresponding with described ground floor node is designated unreachable empty node.
Simultaneously, if the ground floor node of described 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, if and 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 the right branch corresponding be designated and reach the sky node with described second ground floor node; If these two and list and be essential option, that is to say and must select one of them, then the right branch corresponding with described second ground floor node is designated unreachable empty node.
And then the rest may be inferred, if and listd more than 3 or 3, then a plurality of ground floor nodes arranged side by side are identified successively according to above operation, to the last during a ground floor node, whether judge that these are a plurality of again and list is optional, and operate accordingly again according to judged result, so just realized described 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 the optionally meaning of expression, that is to say A, B, and three of C also list and are option, and this aggregate command COMMAND1 can one select directly execution.
Be illustrated in figure 3 as the structural representation after this aggregate command is carried out binary tree conversion of equal value, among the figure: from root node COMMAND1, at first first ground floor node A is designated left branch, owing to there is option arranged side by side to exist, so will the right branch corresponding be designated and reach the sky node with A, here can identify with " O ", 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, while A, 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 identify with " X ", also can identify with other symbol.
In addition, when including one or more minutes nodes under the ground floor node of described aggregate command, described ground floor node as root node, is carried out the conversion of binary tree of equal value to described ground floor node.With above-mentioned for example in, 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 are 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 described binary tree of equal value travels through again, and carry out the path access of leafy node, thereby obtain each bar single command and corresponding expection information to root node.
Here the method that travels through leafy node can be that each leafy node of described 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 at leafy node on the link of root 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 to carry out again aforesaid operations, 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 described leafy node is for can reach the sky node, comprise final command cue information in the expection information by the single command that described leafy node obtained so; If described leafy node is unreachable empty node, so by just not comprising final command cue information in the expection information of the single command that described leafy node obtained.
With above-mentioned for example in, aggregate command COMMAND1[A|B|C] the fractionation traversal, travel through according to the binary tree of equal value among Fig. 3, above-mentioned aggregate command can 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〉represent that this order line finishes, can import carriage return and directly carry out test; And arranged side by side { A}{B}{C}{<CR〉} represents that these four informations are to occur side by side, and order in no particular order.
Step 14: each the bar single command that is 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 described aggregate command increases sandwich construction, when just the level of command tree is deep, in the conversion process of carrying out binary tree of equal value, branch below the described unreachable empty node can 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.
By above operating procedure, just common aggregate command can be carried out the conversion of binary tree of equal value, simplified 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 described 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 by 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; Each option of only selecting in a plurality of options obtains the corresponding aggregate command that substitutes; 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 by 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 have been owing to marked asterisk (*), and 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, oppositely 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 COMMAND2A?B?C?D?E <CR>
2 COMMAND2A?B?C?D {<CR>}{E}
3 COMMAND2A?B?C {<CR>}{E}{D}
4 COMMAND2A?B {<CR>}{E}{D}{C}
5 COMMAND2?A {<CR>}{E}{D}{C}{B}
6 COMMAND2E?D?C?B?A <CR>
7 COMMAND2E?D?C?B {<CR>}{A}
8 COMMAND2E?D?C {<CR>}{A}{B}
9 COMMAND2E?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)
By above optimization fractured operation, just described aggregate command optimization can 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 by such method: select Total Options, and with its forward combination, obtain an alternative aggregate command that comprises Total Options; Described 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 above second step and the 3rd operation that 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; Each option of only selecting in a plurality of options obtains the corresponding aggregate command that substitutes; 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 by providing operation interface to the user, 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 described 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 described active user's level, obtain the final single command of each bar of described 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[A B|C D]; 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 COMMAND3A?B <CR>
2 2: configuration stage COMMAND3?A {B}
3 2: configuration stage COMMAND3C?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)
As can be known, in active user's rank, when promptly carrying out the positive test as list item 1~5 under the configuration stage, each individual command that is obtained exists from last table 3, and this command-levels of representing each individual command is not write low; Then at other low user class of active user's level, when promptly carrying out the negative testing as list item 6~7 under the monitoring level, two individual commands that obtained are non-existent, and this command-levels of representing these two individual commands 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 do not need negative testing is carried out in this single command, for example go up the list item 2 in the table 3,4, order in 5 does not just need to carry out negative testing, this is because these orders are not to comprise<CR〉the final order of 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, with regard to not needing reverse test is carried out in these orders like this, thereby further simplified the process of checking, improved verification efficiency.
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, first view of user's login can be used as root node, it is leafy node that other a plurality of views are used as, and described 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 first view of user's login need 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, each view can 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 described 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 do not need the aggregate command under this view is tested 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 expect that to meeting in whole branches the branch of information identifies, here said 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, those can be had and expect that the branch of information carries out beta pruning and handles meeting of sign, just they be 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, as Fig. 5 is the structural representation of device as described in the embodiment of the present invention, and described 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 by Command Line Interface.
Described command tree conversion unit is used for from the root node of the aggregate command that is obtained, and described aggregate command is carried out the conversion of binary tree of equal value.Specifically, exactly after the aggregate command that a certain needs of acquisition are tested,, adopt the mode of preorder traversal that described aggregate command is converted into binary tree of equal value from the root node of described aggregate command.Wherein in binary tree of equal value, increase and to reach the sky node and represent optional relation and coordination in the described aggregate command, increase unreachable empty node and represent essential relation in the described aggregate command.
Described single command acquiring unit is used for the leafy node of described 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 described 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, described aggregate command optimization is split as a plurality of alternative aggregate command; By described command tree conversion unit each alternative aggregate command is handled operation again, as above the method execution mode is described 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, can also comprise the rank authentication unit in described testing apparatus, described rank authentication unit is used for the command-levels of the single command that is obtained is verified, and carries out corresponding record when the command-levels mistake.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 described active user's level, the final single command of each bar that is 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 described 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, it is leafy node that other a plurality of views are used as, and described 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 described 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 travels through,, then expect that to meeting in whole branches the branch of information identifies if find not meet the not covering branch of expection information; 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 tested equipment, also can be arranged to independent functional entity.
In sum, embodiment of the present invention is by carrying out common aggregate command the conversion of binary tree of equal value, simplified 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; only be the preferable embodiment of the present invention; but protection scope of the present invention is not limited thereto; anyly be familiar with those skilled in the art in the technical scope that the embodiment of the invention discloses; 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 (23)

1, a kind of method of testing of command line interface is characterized in that,
The aggregate command that acquisition need be tested;
From the root node of described aggregate command, described aggregate command is carried out the conversion of binary tree of equal value;
Leafy node to described 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 the bar single command that is obtained is tested.
2, the method for testing of command line interface as claimed in claim 1 is characterized in that, described root node from described aggregate command carries out the conversion of binary tree of equal value to described aggregate command, specifically comprises:
From the root node of described aggregate command, adopt the mode of preorder traversal that described aggregate command is converted into binary tree of equal value;
Wherein in binary tree of equal value, increase and to reach the sky node and represent optional relation and coordination in the described aggregate command, increase unreachable empty node and represent essential relation in the described aggregate command.
3, the method for testing of command line interface as claimed in claim 2 is characterized in that, described method also comprises:
When including one or more minutes nodes under the ground floor node of described aggregate command, described ground floor node as root node, is carried out the conversion of binary tree of equal value to described ground floor node.
4, as the method for testing of one of them described command line interface of claim 1-3, it is characterized in that, described leafy node to described binary tree of equal value travels through, and carry out the path access of leafy node to root node, obtain each bar single command and corresponding expection information, specifically comprise:
Leafy node to described binary tree of equal value travels through, each leafy node of described 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.
5, the method for testing of command line interface as claimed in claim 4 is characterized in that, when carrying out leafy node to the path access of root node, described method also comprises:
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;
If described leafy node is for can reach the sky node, comprise final command cue information in the expection information by the single command that described leafy node obtained so;
If described leafy node is unreachable empty node, so by just not comprising final command cue information in the expection information of the single command that described leafy node obtained.
As the method for testing of claim 2 or 3 described command line interfaces, it is characterized in that 6, described method also comprises:
When described aggregate command increase sandwich construction, during the conversion of the row equivalent binary tree of going forward side by side, the branch below the described unreachable empty node is removed.
As the method for testing of one of them described command line interface of claim 1-3, it is characterized in that 7, described method also comprises:
When described aggregate command is the combination of a plurality of options of random order, described aggregate command optimization is split as a plurality of alternative aggregate command.
8, the method for testing of command line interface as claimed in claim 7 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;
Each option of only selecting in a plurality of options obtains the corresponding aggregate command that substitutes;
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.
9, the method for testing of command line interface as claimed in claim 7 is characterized in that, described optimization splits and is specially:
Select Total Options, and, obtain an alternative aggregate command that comprises Total Options its forward combination;
Described 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;
Repeat the operation in above second step and the 3rd 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;
Each option of only selecting in a plurality of options obtains the corresponding aggregate command that substitutes;
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.
10, the method for testing of command line interface as claimed in claim 7 is characterized in that, described optimization splits and is specially:
By providing operation interface to the user, by the user fractionation combination is set voluntarily, obtain the corresponding aggregate command that substitutes.
As the method for testing of one of them described command line interface of claim 1-3, it is characterized in that 11, described method also comprises:
Under the active user's rank under the described 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.
12, the method for testing of command line interface as claimed in claim 11 is characterized in that, described method also comprises:
Under other low user class of described active user's level, obtain the final single command of each bar of described aggregate command;
The final single command of each bar that is 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.
As the method for testing of one of them described command line interface of claim 1-3, it is characterized in that 13, described 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 described 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.
14, the method for testing of command line interface as claimed in claim 13 is characterized in that, after described 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 described expection aggregate command, verify whether the view corresponding with this expection aggregate command exists, obtain view checking result.
15, the method for testing of command line interface as claimed in claim 14 is characterized in that, described method also comprises:
Described 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.
16, the method for testing of command line interface as claimed in claim 13 is characterized in that, described method also comprises:
When the leafy node to each the bar aggregate command under all views travels through,, then expect that to meeting in whole branches the branch of information identifies if find not meet the not covering branch of expection information;
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.
17, a kind of testing apparatus of 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 from the root node of the aggregate command that is obtained, and described 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 described 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;
The order test cell is used for each the bar single command that is obtained is tested.
18, the testing apparatus of command line interface as claimed in claim 17 is characterized in that, also comprises in the described 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, described aggregate command optimization is split as a plurality of alternative aggregate command;
By described command tree conversion unit each alternative aggregate command is handled operation again.
19, the testing apparatus of command line interface as claimed in claim 18 is characterized in that, comprises in the described 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.
20, the testing apparatus of command line interface as claimed in claim 17 is characterized in that, also comprises in the described testing apparatus:
The rank authentication unit is used for the command-levels of the single command that obtained is verified, and carries out corresponding record when the command-levels mistake; 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 write low error situation;
Under other low user class of described active user's level, the final single command of each bar that is 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.
21, the testing apparatus of command line interface as claimed in claim 17 is characterized in that, also comprises in the described 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 described 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.
22, the testing apparatus of command line interface as claimed in claim 21 is characterized in that, also comprises in the described 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 travels through,, then expect that to meeting in whole branches the branch of information identifies if find not meet the not covering branch of expection information; 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.
As the testing apparatus of one of them described command line interface of claim 17-22, it is characterized in that 23, described testing apparatus is arranged on the tested equipment, or be 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 true CN101471826A (en) 2009-07-01
CN101471826B 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)

Cited By (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
CN103678100A (en) * 2012-09-10 2014-03-26 联芯科技有限公司 Application automatic testing method and system of terminal
CN104317724A (en) * 2014-11-17 2015-01-28 上海斐讯数据通信技术有限公司 Code automation test method of CLI module under Linux platform
CN107977310A (en) * 2017-11-06 2018-05-01 杭州迪普科技股份有限公司 One kind traversal test command generation method and device
CN110071848A (en) * 2019-03-27 2019-07-30 武汉思普崚技术有限公司 The method and apparatus of automatic test order line command
WO2020155778A1 (en) * 2019-02-03 2020-08-06 苏州市龙测智能科技有限公司 Interface automation test method, test apparatus, test device and storage medium
CN114902181A (en) * 2019-12-13 2022-08-12 超威半导体公司 GPU (graphics processing Unit) packet aggregation system

Family Cites Families (1)

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

Cited By (8)

* 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
CN103678100A (en) * 2012-09-10 2014-03-26 联芯科技有限公司 Application automatic testing method and system of terminal
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
CN107977310A (en) * 2017-11-06 2018-05-01 杭州迪普科技股份有限公司 One kind traversal test command generation method and device
WO2020155778A1 (en) * 2019-02-03 2020-08-06 苏州市龙测智能科技有限公司 Interface automation test method, test apparatus, test device and storage medium
CN110071848A (en) * 2019-03-27 2019-07-30 武汉思普崚技术有限公司 The method and apparatus of automatic test order line command
CN114902181A (en) * 2019-12-13 2022-08-12 超威半导体公司 GPU (graphics processing Unit) packet aggregation system

Also Published As

Publication number Publication date
CN101471826B (en) 2012-12-12

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
US8151248B1 (en) Method and system for software defect management
CN100409710C (en) Method and system for checking configuration of nodes in telecommunications network
DE102012102770B9 (en) System and method for error isolation and error mitigation based on network modeling
CN104598376B (en) The layering automatization test system and method for a kind of data-driven
CN101645036B (en) Method for automatically distributing test tasks based on capability level of test executor
CN109583002B (en) Avionics integrated design method
CN102880667B (en) Test task scheduling method based on critical paths and tabu search
CN103678446B (en) Improved mode map based on Data View and database table
CN101808109A (en) Model conversion and formalization verification method of semantic Web service combination
CN102053912A (en) Device and method for automatically testing software based on UML (unified modeling language) graphs
CN109241514A (en) Data automatically imported method, device, computer equipment and storage medium
CN102750301A (en) Blueprint generating method for integrated avionic system model aiming at architecture analysis and design language (AADL) description
CN101119239A (en) Off-lining test execution constructing method and apparatus
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
CN111324538A (en) Micro-service parallel test environment management method based on dynamic routing
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
Aier How clustering enterprise architectures helps to design service oriented architectures
CN107203464A (en) The localization method and device of traffic issues
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