CN102855191A - Embedded basic software code branch coverage testing data inheritance searching method - Google Patents

Embedded basic software code branch coverage testing data inheritance searching method Download PDF

Info

Publication number
CN102855191A
CN102855191A CN2012103200566A CN201210320056A CN102855191A CN 102855191 A CN102855191 A CN 102855191A CN 2012103200566 A CN2012103200566 A CN 2012103200566A CN 201210320056 A CN201210320056 A CN 201210320056A CN 102855191 A CN102855191 A CN 102855191A
Authority
CN
China
Prior art keywords
test data
basic software
software code
embedded basic
searching method
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
CN2012103200566A
Other languages
Chinese (zh)
Other versions
CN102855191B (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.)
63928 TROOPS PEOPLE'S LIBERATION ARMY
Original Assignee
63928 TROOPS PEOPLE'S LIBERATION ARMY
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 63928 TROOPS PEOPLE'S LIBERATION ARMY filed Critical 63928 TROOPS PEOPLE'S LIBERATION ARMY
Priority to CN201210320056.6A priority Critical patent/CN102855191B/en
Publication of CN102855191A publication Critical patent/CN102855191A/en
Application granted granted Critical
Publication of CN102855191B publication Critical patent/CN102855191B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the technical field of computer information processing and in particular relates to an embedded basic software code branch coverage testing data inheritance searching method. According to the method, a testing data searching process is replaced by a searching and optimizing process based on an inheritance algorithm, and fitness function takes branch predicate of tested software as a basis, testing data can traverse all the branches of the tested software, and the testing data is close to boundary of an input subspace. Besides, cross variation comprises searching from a group of one point instead of a single point, thus probability ratio falling into a false peak is greatly reduced compared with that of point-to-point transfer searching, and data inheritance searching efficiency is high.

Description

A kind of embedded basic software code branches coverage test data genetic searching method
Technical field
The present invention relates to technical field of computer information processing, be specifically related to a kind of embedded basic software code branches coverage test data genetic searching method.
Background technology
Genetic algorithm (Genetic Algorithm) is that the Holland of the U.S. at first put forward in 1975, it is a kind of Optimum search algorithm based on natural selection principle and natural genetic mechanism, life evolutionary mechanism in its simulating nature circle is realized the optimization of specific objective in manual system.Its operand is a group chromosome (being called individuality), i.e. population (Population).Here each chromosome is corresponding to a solution of problem.Genetic algorithm adopts based on the selection strategy of fitness ratio and select individuality in current population from initial population, produces population of future generation with crossover and mutation.Develop so from generation to generation, until meet the desired end condition.Genetic algorithm is a potential feasible solution with single chromosome problem of representation in the expression in solution space, and it is corresponding with the search by a potential solution space to operate in an evolutionary process on the chromosome population.
Embedded basic software is a kind of safety-critical software, for guaranteeing its q﹠r, generally need to carry out the software code Logical Coverage Testing.Logic covers and can be divided into again statement covering, branch's covering, path covering etc.Test to refer to design some groups of test datas by branch's coverage criterion, the operation tested program makes getting true branch and get false ramification and experiencing at least once of each judgement in the calling program, and the true-false value of namely judging all once was satisfied.
According to domain test (Domain Testing) principle, the input space of tested software (being the territory) can be divided into different subspaces, and the division of subspace is to be determined by the branch's predicate in the tested software.Can more effectively find path error and the miscount of tested software near the test data on border, subspace.Therefore, the target of branch's coverage test data selection is, with a small amount of test data all branches of tested software all is performed, and these test datas are as much as possible near the border of subspace.
Because embedded basic software is larger, complexity is higher, and exploitation branch coverage test data need to spend a large amount of human and material resources, adopts the means of robotization can effectively improve efficient and the quality of test data search.Many traditional automatic modes are processed a single-point of search volume.Climbing method for example, its uses iterate improvement method, and each iteration is selected a new point from the field of some now.Obviously, in the population for multi-peak searching space, it is easy to be absorbed in false local peaking.
Summary of the invention
For the deficiencies in the prior art, the invention provides a kind of embedded basic software code branches coverage test data genetic searching method, test data genetic searching method of the present invention can be expanded easily, to support branch's predicate, various branch and the cycle program structure of different input data types, complexity.
The objective of the invention is to adopt following technical proposals to realize:
A kind of embedded basic software code branches coverage test data genetic searching method, its improvements are that described method comprises the steps:
(1) generates random number;
(2) select initial population;
(3) according to the parameter coding mode individuality string of described initial population is mapped to actual parameter value, and passes to tested software;
(4) determine fitness function;
(5) cross and variation is improved test data, forms the more excellent population of a new generation;
(6) loop step (1)-(5), until find the target component value that covers all embedded basic software branches, all branches of test data traversal tested software finish this search procedure.
Wherein, in the described step (2), select initial population according to embedded basic software parameter request.
Wherein, in the described step (3), when the individuality string of initial population is mapped to actual parameter value, and when passing to tested software, drive the tested software operation; Described tested software refers to embedded basic software.
Wherein, in the described step (4), determine fitness function according to tested embedded basic software code, described fitness function is take branch's predicate of embedded basic software code as the basis.
Wherein, for obtaining embedded basic software code branches coverage test data tested software is carried out plug-in mounting.
Wherein, in the described step (5), described cross and variation is that the colony since a point carries out.
Wherein, described method is adaptive test data searching method.
Compared with the prior art, the beneficial effect that reaches of the present invention is:
Embedded basic software code branches coverage test data genetic searching method has higher search efficiency than other method.Test data searching method of the present invention is take branch's predicate as the basis, and test data can travel through all branches of tested software, and test data is very near the border of inputting the subspace.In order to optimize fitness function, constantly revise from generation to generation test data by genetic algorithm, formed a kind of adaptive test data searching method.This method is to search for from the colony of a point rather than from a single point, and a single-point of many conventional process search volume, thereby the transfer search that this method falls into the likelihood ratio point-to-point of ghost peak greatly reduced, and has the search efficiency of better convergence and Geng Gao.
This test data searching method can be expanded easily, to support branch's predicate, various branch and the cycle program structure of different input data types, complexity.
Description of drawings
Fig. 1 is embedded basic software code branches coverage test data genetic searching method process flow diagram provided by the invention;
Fig. 2 is IF-THEN-ELSE control Liu Shu provided by the invention and former tested software synoptic diagram;
Fig. 3 is tested software plug-in mounting example schematic provided by the invention;
Fig. 4 is tested software control stream tree provided by the invention.
Embodiment
Below in conjunction with accompanying drawing the specific embodiment of the present invention is described in further detail.
Embedded basic software code branches coverage test data genetic searching method flow process provided by the invention as shown in Figure 1, the method comprises the steps:
(1) generates random number;
(2) select initial population;
(3) according to the parameter coding mode individuality string of described initial population is mapped to actual parameter value, and passes to tested software;
(4) determine fitness function;
(5) cross and variation is improved test data, forms the more excellent population of a new generation;
(6) loop step (1)-(5), until find the target component value that covers all embedded basic software branches, all branches of test data traversal tested software finish this search procedure.
Fitness function is take branch's predicate of embedded basic software code as the basis, whole search procedure is from generating initial population, then according to the parameter coding mode the individual bit string in the population is mapped to actual parameter value, and passes to tested software, drive the operation of tested software.Characteristics according to tested embedded basic software code are determined fitness function, calculate the fitness function value during tested software operation, assess the fitness of every group of test data, the higher explanation test data of fitness and Expected Results are more approaching, utilize afterwards the basic operator such as intersection, variation that test data is improved, form the more excellent population of a new generation, and so forth, until find the target component value that covers all branches, test data can travel through all branches of tested software, just can finish this search procedure.
Below in conjunction with the IF conditional statement, the branch's coverage test data search strategy based on genetic algorithm is described.Fig. 2 has shown the example of a simple IF-THEN-ELSE condition.C NRepresent branch's predicate, S N+1(corresponding to node (N+1)) and S N+2(corresponding to node (N+2)) is respectively pending statement sequence.If C NBe true, carry out S N+1, otherwise carry out S N+2
Suppose C NBe A=B, A and B are integer (also may be the complicated function of input parameter).For the S in the XM (N+1) N+1, A must value B.Be the S in the XM (N+2) N+2, A can get any value of being not equal to B (A ≠ B).But the preferential value of A is (B+1) and (B-1), because these two value next-door neighbour borders, subspace more are conducive to the discovery procedure mistake.From the genetic algorithm angle, for node (N+1), A value and B are more approaching, and fitness (Fitness) is just higher.Need to carry out plug-in mounting to tested software in order to obtain branch's coverage test data, specific as follows:
if C N then
CHECK_BRANCH(NODE_NUMBER);
LOOKING_BRANCH(NODE_NUMBER _SIB,DATA1 _SIB,DATA2 _SIB);
S N+1
else
CHECK_BRANCH(NODE_NUMBER _SIB);
LOOKING_BRANCH(NODE_NUMBER,DATA1,DATA2);
S N+2
end if;
CHECK_BRANCH only has the input parameter of an integer type, i.e. node number NODE_NUMBER.Whether CHECK_BRANCH has recorded this node and had carried out.If be performed, preserve relevant test data.Like this, can begin the node that do not travel through for the next one and generate test data.
The input parameter of LOOKING_BRANCH has 3, comprises brotgher of node NODE_NUMBER _ SIBIf the brotgher of node not yet is traversed, LOOKING_BRANCH calculates the fitness of the brotgher of node.The looking variable save next one does not travel through the node number of node, and whether LOOKING_BRANCH understands the brotgher of node according to variable looking is the next node of needs traversal.
The value of DATA1 and DATA2 only depends on branch's predicate function, does not need out of Memory.In above-mentioned example, the condition of XM (N+1) is C N(A=B), this moment, the value of DATA1 was A, and the value of DATA2 is B.For node (N+2), DATA1 is constant, and DATA2 adopts (B-1), as shown in Figure 3, is using "〉" situation under (for example IF A〉B THEN), the fitness function form of getting true branch is FITNESS_FUNCTION (A, B+1).Select (B+1) and A pairing here, because it is and the immediate data of A.Otherwise, if use " IF A<B ", then select (B-1).
Embodiment
The below illustrates embedded basic software code branches coverage test data genetic search process with a simple example, and the control stream tree of tested software and plug-in mounting form are as shown in Figure 4.In this example, the major parameter of genetic algorithm arranges as follows: survival probability Ps=0.5, variation probability P m=0.1, adopt single-point to intersect.
Former tested software IF conditional statement is as follows:
if A≤B then
put(“node 2”);
if A=B then
put(“node 3”);
else
put(“node 4”);
end if;
else
put(“node 5”);
end if;
Tested software IF conditional statement through plug-in mounting is as follows:
if A≤B then
CHECK_BRANCH(2);
LOOKING_BRANCH(5,A,B+1);
if A=B then
CHECK_BRANCH(3);
LOOKING_BRANCH(4,A,B-1);
else
CHECK_BRANCH(4);
LOOKING_BRANCH(3,A,B);
end if;
else
CHECK_BRANCH(5);
LOOKING_BRANCH(2,A,B);
S 3
end if;
(1) first generation
Table 1 has shown 4 members of first generation population, and they are generated at random by the test data Core Generator.P wherein iThe member of expression parent population (Parent Population), A and B are the input variable value, and looking is the numbering of pending node, and Path represents by the node of current test data (A and B) traversal.What chromosome showed is the test data of binary mode, and each test data represents by 5 bits, so chromosome length is 10 bits, and front 5 bits represent to input data A, and rear 5 bits represent to input data B.f iBe the fitness according to test data and node to be traveled through calculating, it is larger that the group member that fitness is higher enters follow-on survival probability, F tRepresent total fitness of this population.
The parent population of table 1 first generation
Figure BDA00002084273700061
First group of test data (P 1) input tested software after, first pending node is that node 2(looking value is 2).For node 2, its fitness function be f=1/ (| A-B|+0.01) 2, because the limit testing data of ergodic condition A≤B are A=B.This fitness function guaranteed A and B numerically test data close to each other have higher fitness.First generation test data has been carried out node 1,2,4,5, only has node 3 not carry out.(node 2 is by first group of test data P in this example after the looking node is carried out by certain test data 1Carry out), still to calculate all the other test datas for the fitness of looking node, but not generate progeny population (Offspring Population).
(2) second generation
First generation population sees Table 2 as the starting point of search spread node 3 test datas.The access control predicate of node 3 is just identical with node 2, so the second generation test data in the table 2 and fitness thereof are identical with table 1.In second generation population, looking node (node 3) is not traversed, so genetic algorithm need to generate the offspring by crossover and mutation, and as shown in table 3, wherein k represents the point of crossing, and the gene of variation (bit) represents with italic.
The parent population of table 2 second generation
Figure BDA00002084273700062
The progeny population of table 3 second generation
In table 3, by intersect, the new filial generation test data that produces of variation is with O iExpression, its parent is with P iExpression.These parents member selects at random.In regrouping process, two parent members generate two filial generation members.In progeny population, O 3Distance and P with node 3 1Identical, the fitness of the two is identical (0.0278) also.In progeny population, O 3Fitness the highest, the probability that enters population of future generation of therefore surviving is also higher.But total fitness F of progeny population tBe lower than the parent population, this explanation does not improve in integral body to next population from a population.
We have two populations (parent population and progeny population) now, and they respectively have 4 members, will produce population of future generation from these 8 members.Because survival probability P sBe 0.5, population of future generation is by each 2 member composition of these two populations on average.Table 4 has shown 4 members' of future generation selection course.Corresponding to each member of population of new generation, the random number between generating 0 to 1 is shown in the second row in the table 4.If random number greater than 0.5(namely greater than Ps), select the parent population, otherwise select progeny population.Finish after the population selection, generate another random number, which member's existence enters the next generation in the selected population.For example, select the process of all group members member1 of future generation as follows, the random number that generates for the first time is 0.678, this means to select the parent population.The next random number that generates is 0.257, therefore selects the P in the parent population 1Repeat this process, obtain other 3 members of population of future generation.A new generation is presented at the top of table 5.
The existence situation of table 4 progeny population
(3) third generation
Whole process repeats, until all nodes all are traversed.Table 5-table 7 has provided third generation population.Pass through F tCan find out that the whole fitness of the parent population in the third generation is higher than the second generation.In the progeny population that generates by crossover and mutation, test data O 1Apart from global optimum's 3 graduation of whole numbers of units (11-8=3) only.O 1Therefore obtain high fitness, being able to survive for twice enters the next generation.
Table 5 third generation population (one)
Figure BDA00002084273700072
Table 6 third generation population (two)
Figure BDA00002084273700073
Figure BDA00002084273700081
Table 7 third generation population (three)
Figure BDA00002084273700082
(4) the 4th generations
Table 8-table 10 provided the 4th generation population, in the progeny population therein, two groups of test data (O 1And O 4) close to reaching target.In fact O 4More near global optimum, therefore also obtain higher fitness.From four generations of the third generation to the, whole fitness F tImproved 280%.
Table 8 the 4th generation population (one)
P i A B looking Path chromosome f i F t
P 1 8 11 3 1,2,4 00010 11010 0.1111 0.27
P 2 8 11 3 1,2,4 00010 11010 0.1111
P 3 8 15 3 1,2,4 00010 11110 0.0204
P 4 0 -6 3 1,5 00000 01101 0.0278
Table 9 the 4th generation population (two)
Figure BDA00002084273700083
Table 10 the 4th generation population (three)
Figure BDA00002084273700084
(5) the 5th generations
Table 11-table 12 provided the 5th generation population.In general, total fitness F tCan progressively improve along with the increase of algebraically.In the 5th generation population, test data O 1(A=B=11) traveled through node 3.Along with last node is traversed, the test data search procedure ends.
Table 11 the 5th generation population (one)
Figure BDA00002084273700091
Table 12 the 5th generation population (two)
Figure BDA00002084273700092
Method provided by the invention is to search for from the colony of a point rather than from a single point, and a single-point of many conventional process search volume, thereby the transfer search that this method falls into the likelihood ratio point-to-point of ghost peak greatly reduced, and has the search efficiency of better convergence and Geng Gao.
Should be noted that at last: above embodiment is only in order to illustrate that technical scheme of the present invention is not intended to limit, although with reference to above-described embodiment the present invention is had been described in detail, those of ordinary skill in the field are to be understood that: still can make amendment or be equal to replacement the specific embodiment of the present invention, and do not break away from any modification of spirit and scope of the invention or be equal to replacement, it all should be encompassed in the middle of the claim scope of the present invention.

Claims (7)

1. an embedded basic software code branches coverage test data genetic searching method is characterized in that described method comprises the steps:
(1) generates random number;
(2) select initial population;
(3) according to the parameter coding mode individuality string of described initial population is mapped to actual parameter value, and passes to tested software;
(4) determine fitness function;
(5) cross and variation is improved test data, forms the more excellent population of a new generation;
(6) loop step (1)-(5), until find the target component value that covers all embedded basic software branches, all branches of test data traversal tested software finish this search procedure.
2. embedded basic software code branches coverage test data genetic searching method as claimed in claim 1 is characterized in that, in the described step (2), according to selecting initial population in the embedded basic software parameter request.
3. embedded basic software code branches coverage test data genetic searching method as claimed in claim 1, it is characterized in that, in the described step (3), when the individuality string of initial population is mapped to actual parameter value, and when passing to tested software, drive the tested software operation; Described tested software refers to embedded basic software.
4. embedded basic software code branches coverage test data genetic searching method as claimed in claim 1, it is characterized in that, in the described step (4), determine fitness function according to tested embedded basic software code, described fitness function is take branch's predicate of embedded basic software code as the basis.
5. embedded basic software code branches coverage test data genetic searching method as claimed in claim 4 is characterized in that, for obtaining embedded basic software code branches coverage test data tested software is carried out plug-in mounting.
6. embedded basic software code branches coverage test data genetic searching method as claimed in claim 1 is characterized in that, in the described step (5), described cross and variation is that the colony since a point carries out.
7. embedded basic software code branches coverage test data genetic searching method as claimed in claim 1 is characterized in that described method is adaptive test data searching method.
CN201210320056.6A 2012-08-31 2012-08-31 Embedded basic software code branch coverage testing data inheritance searching method Expired - Fee Related CN102855191B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210320056.6A CN102855191B (en) 2012-08-31 2012-08-31 Embedded basic software code branch coverage testing data inheritance searching method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210320056.6A CN102855191B (en) 2012-08-31 2012-08-31 Embedded basic software code branch coverage testing data inheritance searching method

Publications (2)

Publication Number Publication Date
CN102855191A true CN102855191A (en) 2013-01-02
CN102855191B CN102855191B (en) 2015-04-15

Family

ID=47401793

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210320056.6A Expired - Fee Related CN102855191B (en) 2012-08-31 2012-08-31 Embedded basic software code branch coverage testing data inheritance searching method

Country Status (1)

Country Link
CN (1) CN102855191B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103198015A (en) * 2013-03-21 2013-07-10 中国人民解放军国防科学技术大学 Embedded software reliability test data generating method based on using probability
CN103729297A (en) * 2013-12-31 2014-04-16 北京理工大学 Test case generation method based on hierarchic genetic algorithm
CN108874656A (en) * 2017-05-16 2018-11-23 北京京东尚科信息技术有限公司 Code test method, device, readable storage medium storing program for executing and computer equipment
CN116627973A (en) * 2023-05-25 2023-08-22 成都融见软件科技有限公司 Data positioning system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103538A (en) * 2011-02-22 2011-06-22 南京航空航天大学 Method for testing palletizing robot control software based on Agent
CN102629229A (en) * 2012-03-02 2012-08-08 南京大学 Co-diversified random testing (CAT) method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102103538A (en) * 2011-02-22 2011-06-22 南京航空航天大学 Method for testing palletizing robot control software based on Agent
CN102629229A (en) * 2012-03-02 2012-08-08 南京大学 Co-diversified random testing (CAT) method

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103198015A (en) * 2013-03-21 2013-07-10 中国人民解放军国防科学技术大学 Embedded software reliability test data generating method based on using probability
CN103729297A (en) * 2013-12-31 2014-04-16 北京理工大学 Test case generation method based on hierarchic genetic algorithm
CN108874656A (en) * 2017-05-16 2018-11-23 北京京东尚科信息技术有限公司 Code test method, device, readable storage medium storing program for executing and computer equipment
CN116627973A (en) * 2023-05-25 2023-08-22 成都融见软件科技有限公司 Data positioning system
CN116627973B (en) * 2023-05-25 2024-02-09 成都融见软件科技有限公司 Data positioning system

Also Published As

Publication number Publication date
CN102855191B (en) 2015-04-15

Similar Documents

Publication Publication Date Title
CN105430707B (en) A kind of wireless sense network multiple-objection optimization method for routing based on genetic algorithm
Yuen et al. A genetic algorithm that adaptively mutates and never revisits
CN102855191B (en) Embedded basic software code branch coverage testing data inheritance searching method
CN107122843A (en) A kind of traveling salesman problem method for solving based on improved adaptive GA-IAGA
CN110347881A (en) A kind of group's discovery method for recalling figure insertion based on path
Bi et al. Use of domain knowledge to increase the convergence rate of evolutionary algorithms for optimizing the cost and resilience of water distribution systems
CN110533096A (en) The DNA of multiverse algorithm based on K-means cluster stores Encoding Optimization
Geng et al. Relational message passing for fully inductive knowledge graph completion
CN103605611A (en) Test case optimization method based on genetic algorithm
CN112035059A (en) Single-point failure recovery method for distributed storage system, electronic equipment and storage medium
CN109217284A (en) A kind of reconstruction method of power distribution network based on immune binary particle swarm algorithm
Wang et al. An Improved Real‐Coded Genetic Algorithm Using the Heuristical Normal Distribution and Direction‐Based Crossover
Srivastava et al. Generation of test data using meta heuristic approach
CN110321116A (en) A kind of effectively optimizing method towards calculating cost restricted problem in compiling optimization
Agarwal et al. Code coverage using intelligent water drop (IWD)
CN105426959B (en) Aluminium electroloysis energy-saving and emission-reduction method based on BP neural network Yu adaptive M BFO algorithms
Ghosh et al. Non-dominated rank based sorting genetic algorithms
Noferesti et al. A hybrid algorithm for solving steiner tree problem
CN110446239A (en) A kind of wireless sensor network cluster-dividing method and system based on multiple magic square
CN103279796A (en) Method for optimizing genetic algorithm evolution quality
CN104732522A (en) Image segmentation method based on polymorphic ant colony algorithm
CN103116805B (en) A kind of segmentation replacement method upgrading genetic groups
CN115963731A (en) Command control system network structure optimization method based on improved genetic algorithm
CN108260193A (en) Federated resource distribution method based on channel aggregation in heterogeneous network
CN105426960B (en) Aluminium electroloysis energy-saving and emission-reduction control method based on BP neural network Yu MBFO algorithms

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
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20150415

Termination date: 20210831