Purpose of the present invention overcomes the above-mentioned deficiency of prior art exactly, and a kind of convenience, method flexibly are provided, can detect in the SDL software various system resources use whether correct, thereby can improve the reliability of software.
The object of the present invention is achieved like this: the usage counter that increases a respective resources in tested SDL software in the correlated process of various resource bids and release, when promptly applying for a certain resource, if this resource was applied for, then a resource of having applied for is applied in expression, write down this mistake, otherwise this counter adds 1; When discharging this resource, if this resource do not apply for, illustrate that then SDL software discharges the resource do not apply for, write down this mistake, otherwise the corresponding counts device subtracts 1.When the SDL state machine migrates to a stable status or before the STOP, check the usage count of all resources,, then illustrate and such resource is used normal,, illustrate then that such resource has been applied for but do not discharge if greater than zero if corresponding counts is zero.Under steady state (SS), the usage count of some resource may be non-vanishing, but its sum should maintain in the metastable scope.
According to the definition of CCITT to SDL, the SDL process generally is divided into two kinds:
(1) process existence always in system.
(2) process stops (STOP) by carrying out an action.
For the process that in system, exists always, generally when this process migration to one stable status, carry out the detection of all resource operating positions; For process that can STOP, should before this process STOP, carry out the detection of all resource operating positions.
In the defined SDL standard of CCITT, a process can have a plurality of examples, and these examples can exist simultaneously, can carry out independently of one another and concomitantly.In addition, for same resource, also have a plurality of processes and all will visit.Therefore, the global variable that is used to write down certain class resource is general to use a two-dimensional structure array, and one dimension is used to represent the example of process, one dimension be used to represent such resource which.Except array, also can adopt methods such as chained list to write down the operating position of resource.
Implement SDL software resource detection method provided by the invention, can effectively detect the operating position of the various system resources that relate in the SDL software, these resources include but not limited to: internal memory, timer, time slot, User Status, interrupt.Promptly comprise needing application before the various uses, need the hardware resource given back after the use, and various and hardware does not have the software resource of direct relation.Specifically, the present invention can solve following problem:
Whether (1) detect the resource that relates in the SDL software correctly discharges after use;
(2) detect the situation whether SDL software exists the resource that application applied for;
(3) detect the situation that whether has the resource that release do not apply in the SDL software;
(4) detect SDL software when discharging resource, whether the parameter whether some parameters relevant with this resource are modified or are brought into is correct.
SDL software resource detection method provided by the invention is not limited to a certain product, it is a kind of general resource detection method, can detect the resource that takes place in programming and the computer program operational process in time and use wrong situation, thereby improve the reliability of software.Prompting exploitation, maintainer follow the tracks of solution.Need in the environment of continuous working procedure at some,, have very practical meaning and good effect as in the Maintenance of Program Control Exchange management.While method provided by the invention implements fairly simple, and it is also fewer that the code that need increase reaches the modification that tested program is done, and therefore has very high practicality.
Below in conjunction with drawings and Examples, further specify technical scheme of the present invention.
Fig. 1 adopts method of the present invention to carry out the job step that the SDL software resource detects.In Fig. 1, at first carry out 101, in the various resource bid processes of tested SDL software, add resource bid detection method as shown in Figure 2; Carry out 102, discharge the resource that adds in the function as shown in Figure 3 in various resources and discharge detection method; Carry out 103 again, add when the SDL state machine migrates to steady state (SS) as shown in Figure 4 or STOP before the detection method of all resources; Then carry out 104, in the master routine of tested program, add the used various initialization of variable processes of resource trace routine; Carry out 105 then, tested program is compiled, links the generation executable program with test procedure, move this program, can obtain error logging, thereby localization of fault realized in the profiling error record.Wherein above-mentioned step includes but not limited to above-mentioned order, as long as step 105 is last steps.
Fig. 2 is the workflow diagram of the resource bid detection method that adds in the resource bid process, and this figure is that example describes with N the resource of applying for certain class resource.Each class resource for SDL software exists all can add detection method shown in Figure 2 in the application process of such resource.
In Fig. 2,201 are used to obtain the process PID (Process ID) of application resource.Because all processes in the system all may be applied for certain resource, in order to distinguish different processes, we adopt the PID of process to identify is for which process application resource.Because in a system, the PID of process is unique; 202 are illustrated in the process of searching the pairing array location of this PID in the array of such resource operating position of record.Use a two-dimensional structure array to preserve the operating position of such resource among the present invention, if find corresponding PID, then can obtain its array first dimension subscript M, if do not find, then specify the unit M of a sky to preserve the usage count of resource, and apply for the process PID of resource; 203 are used to judge whether the resource of the individual unit of [M] [N] applied for; If applied for, represent that then the SDL program applies for the resource of having applied for again, write down this mistake by carrying out 204, then the ending resource testing process.It is pointed out that here some resources may repeatedly apply for also representing it is normal condition, for the second time the time, it just falls the timer that is provided with previously clearly simply, is rearranged into new timing length as the timer resource bid.Therefore to treat with a certain discrimination for some special resources; After carrying out 203, if the resource of the individual unit of [M] [N] was not applied for, then carry out 205, the individual unit of being brought into when preserving the application resource of correlation parameter to the [M] [N], correlation parameter is meant the out of Memory relevant with this resource, as node number, child node number, User Status etc., and these information can not change in program operation process, when discharging such resource, also to check like this this category information, when whether existing in situation about being revised mistakenly in the program operation process or discharging this resource, whether the parameter of being brought into is correct.For some resource, as User Status, when such resource of application, the relevant information of User Status will be brought into, this information will be used by SDL software and preserve, when discharging such resource, trace routine will check and be preserved the User Status of getting off and trace routine by SDL software whether preserve the User Status of getting off consistent, if inconsistent then illustrate that User Status has been revised mistakenly; Also has a class resource in addition, as bringing node relevant and child node number in the application process of time slot into this time slot, when discharging this resource, also can bring node relevant with this time slot and child node number into, trace routine just can detect whether discharge the parameter that parameter that resource method brings into and trace routine preserve consistent like this; Carry out 206 resource usage count values at last and add 1 corresponding units.
Fig. 3 is the workflow diagram that the resource that adds in the resource dispose procedure discharges detection method, and this figure is that example describes with N the resource that discharges certain class resource.Corresponding with Fig. 2, each the class resource for existing in the SDL software all can add detection method shown in Figure 3 in the dispose procedure of such resource.In Fig. 3,301 are used to obtain the process PID that discharges resource; Carry out 302 then and find the pairing array location M of this PID; Carry out 303, judge whether to find the unit M identical with the process PID that discharges resource; If do not find, what then explanation will discharge is the resource that does not also have application, then carries out 305 and writes down this mistake; If find unit M, then carry out 304, judge whether the individual element resources of [M] [N] applied for; If do not apply for, then carry out 305 and write down " discharging the resource of not applying for " mistake; If this resource applied for, then carry out 306 and check whether unanimity of parameter that the correlation parameter brought into and the parameter of being brought into when the application be whether consistent or the inspection trace routine is preserved parameter and SDL program preserved; If inconsistent, parameter error or the correlation parameter brought into when then explanation discharges resource are modified in program operation process, then carry out 307 and write down the mistake of " parameter is inconsistent ".For example: SDL software should discharge N resource of certain class resource, the node number of this resource is N, child node number is N, and bring into and discharge that node number is N in the function parameters, child node number be N, but N+1 resource of SDL program error ground release, and the node number of N+1 resource is N+1, child node number is N+1, and then resource discharges trace routine and finds that the data of the parameter of the resource that discharges and preservation are inconsistent, and trace routine will write down such mistake; Last trace routine is carried out 308 usage counts with respective resources and is subtracted 1, and ending resource discharges testing process.
Fig. 4 is when the SDL state machine migrates to a stable status or before the STOP, the method flow diagram that a certain class resource is detected.For each the class resource that exists in the SDL software, all to during to steady state (SS) or detect the operating position of this resource before the STOP, promptly add detection method as shown in Figure 4 in the SDL migration of programs.In Fig. 4, at first carry out 401 PID that obtain current process; Carry out 402 and search the unit M identical with current process PID; Carry out 403, judge whether to find unit M,, illustrate that then this process do not use such resource, the ending resource trace routine if do not find; If find unit M, then carry out 404, begin to detect from first of such resource; Carry out 405, judge whether the individual usage count of [M] [N] of such resource is zero,, then represented this resource bid but not release, carry out the mistake that 406 records do not discharge resource if non-vanishing; Then carry out the next element resources that 407 preparations detect such resource; Carry out 408 and judge N whether greater than the sum of such resource, if greater than the detection of end process otherwise would get back to 405, continue the detection of the next element resources of such resource, up to all resources of such resource are whole detected till.
In SDL software, there are some resources to take always and do not discharge, for this class situation, when entering steady state (SS), process can not directly judge whether to exist resource not have situation about discharging by the usage count of checking this resource, tackle method of the present invention and use flexibly and can solve such problem this moment, as: for the resource that takies after some applications always, do not count.
Even have after the resource bid occupiedly and do not discharge in addition, its sum that takies also should maintain a metastable number, if the sum of resource occupation increases always, then also represents wrong existence.
Fig. 5 is the structural drawing that method of the present invention is applied to back system in the SDL software test.This system comprises application layer, system layer, hardware platform, wherein 501 of application layer represent tested SDL software, and the tested SDL software of 502 expressions proposes the resource bid request, and this request is sent to 504 of system layer, the application of carrying out respective resources detects, and promptly finishes the function shown in Fig. 2.Resource bid promptly carries out 506 after detecting and finishing, and carries out the resource bid of the reality of hardware platform.The dispose procedure of resource similarly proposes resource release request at SDL software, promptly carry out application layer 503 after, this request is sent to system layer, carries out 505, carries out resource and discharges detection, promptly finish function shown in Figure 3, carry out 507 resources of carrying out the reality of hardware platform then and discharge.
Introduce at last and adopt the inventive method that a larger switch software has been carried out the concrete case study on implementation that resource detects: the SDL software resource trace routine of utilizing method construct of the present invention is a testing tool that has nothing to do with product and operation platform, and its using method is as follows:
There are following system resources in the tested software: as internal memory, T net speech time slot, digit receiver time slot, signal tone time slot, timer etc.For the SDL state machine of being concerned about, at each resource, define an overall array, in the application function of every kind of resource, add the code that detection method flow process as shown in Figure 2 obtains, in the release function of every kind of resource, add the code that detection method flow process as shown in Figure 3 obtains, when state machine migrates to steady state (SS) or before the STOP, add the code that detection method flow process as shown in Figure 4 obtains, and in master routine, add the initialization of variable code, be used for and will detect all global variable zero clearings of usefulness.Compile, link and move this switch software, obtain error logging at last, assist the developer to carry out localization of fault thereby analyze this error logging.