CN113672508A - Simulink test method based on risk strategy and diversity strategy - Google Patents
Simulink test method based on risk strategy and diversity strategy Download PDFInfo
- Publication number
- CN113672508A CN113672508A CN202110944362.6A CN202110944362A CN113672508A CN 113672508 A CN113672508 A CN 113672508A CN 202110944362 A CN202110944362 A CN 202110944362A CN 113672508 A CN113672508 A CN 113672508A
- Authority
- CN
- China
- Prior art keywords
- simulink
- risk
- test case
- keyword
- strategy
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a Simulink testing method based on a risk strategy and a diversity strategy, which comprises the following specific steps of: collecting test cases; and processing the generated test case: counting the names and the occurrence times of the Simulink modules appearing in each test case; modeling the keyword vector: constructing a keyword dictionary by the Simulink module names appearing in all test cases, recording the occurrence frequency of each keyword, and deleting the keywords with the occurrence frequency lower than a set threshold value; constructing a keyword matrix KV, a risk vector RV and a distance matrix DM; the Simulink test cases are prioritized using a risk strategy Dan based on a risk vector RV, a diversity strategy Var based on a distance matrix DM, and a diversity risk hybrid strategy VarDan combining the two strategies.
Description
Technical Field
The invention relates to the field of selection and sequencing of test cases, in particular to a Simulink test method based on a risk strategy and a diversity strategy.
Background
The chip is called "industrial grain" and is the core technology of manufacturing industry. With the continuous emphasis of the chip industry in China, the chip design industry is under vigorous development. EDA is a necessary and most important software tool for chip design, so how to realize efficient and stable EDA is very important. Simulink, a widely used set of EDAs for circuit design, is increasingly required to perform properly and achieve its intended result.
In recent years, several approaches have been proposed to facilitate automated Simulink testing. These techniques rely on some test case generation tools (e.g., SLforge) to generate a large number of test programs, and the Simulink errors are detected by running these generated test programs. The common method is that new test cases are generated in batch by LSTM learning SLforge rule-based generated test cases, and the learning-based generated test cases are more random than the rule-based generated test cases and are more likely to find Simulink errors. There have also been studies to perform SLEMI mutation on existing Simulink models to generate new test cases by processing zombie blocks in the test cases. The specific method is that firstly, coverage information of each block is obtained through preprocessing, and nested dynamic zombie blocks are identified. Then, the following three processing modes are available for different situations: (1) for nested zombie blocks, the block is deleted and the front and back of the block are connected. (2) The top level zombie blocks are replaced and the replaced blocks are guaranteed to have the same sampling time. (3) Otherwise, mutation is performed on the activity level. And finally, carrying out differential test on the test case before mutation and the newly generated test case to detect the Simulink error. The Simulink testing techniques present significant efficiency problems because they typically require a large number of Simulink models to be generated and tested on a continual basis, requiring a long time to discover a Simulink error. Although the Simulink error can be searched only by performing EMI mutation on the existing test case, the mutation method is single, and more various error types cannot be found.
Disclosure of Invention
According to the problems in the prior art, the invention discloses a Simulink test method based on a risk strategy and a diversity strategy, which specifically comprises the following steps:
collecting test cases, randomly generating a tool Slforge by adopting a Simulink program to generate the test cases, judging whether Simulink crash is caused or not by an error detection program, and marking the Simulink as fault if a Simulink error is found;
and processing the generated test case: counting the names and the occurrence times of the Simulink modules appearing in each test case;
modeling the keyword vector: constructing a keyword dictionary by the Simulink module names appearing in all test cases, recording the occurrence frequency of each keyword, and deleting the keywords with the occurrence frequency lower than a set threshold value;
constructing a keyword matrix KV, a risk vector RV and a distance matrix DM;
carrying out prioritization treatment on the test cases: the Simulink test cases are prioritized using a risk strategy Dan based on a risk vector RV, a diversity strategy Var based on a distance matrix DM, and a diversity risk hybrid strategy VarDan combining the two strategies.
When the keyword matrix KV is constructed:
constructing a keyword vector tr for each test casei=(ei,1,ei,2,...,ei,m) Wherein m is the number of keywords in the keyword dictionary; if the ith test case contains the jth keyword in the keyword dictionary, e i,j1, otherwise ei,jKV is an n × m matrix, where n denotes n test cases and m denotes m keywords in the keyword dictionary.
When the risk vector RV is constructed: statistical keyword vector triThe number of 1 in the test case is used as a risk valueThe risk value of each test case is calculated, so that a risk vector RV formed by n error reports is constructed.
When the distance matrix DM is constructed: calculating the distance of each pair of test cases based on the keyword matrix KV, and aiming at two keyword vectors triAnd trkWill correspond to e in the position ji,jAnd ek,jThe number of different values is counted as distance D (tr)i,trk) And calculating the distance of each pair of test cases to construct a distance matrix DM.
When the risk strategy Dan is adopted to carry out the prioritization and the sequencing on the Simulink test cases: selecting the test case tr with the highest risk value RV (i)iPutting the test cases into an ordered queue QTR, deleting the test case from tr, and selecting the test case tr with the highest risk value RV (i) from the rest test cases of triThe above operation is repeated until tr is 0 in length.
When the diversity strategy Var is adopted to prioritize the Simulink test cases: selecting the test case tr with the highest risk valueiPutting into QTR, deleting it from tr, and selecting the test case tr which is farthest from QTR, i.e. the test case tr with the largest D (tr, QTR) from trjPut into QTR, delete it from TR too, repeat the above operation until TR length is 0.
When the diversity risk mixing strategy Vardan is adopted to carry out the prioritization and the ordering on the Simulink test cases: selecting the test case with the largest risk value to be checked, putting the test case into the QTR and deleting the test case from tr, and selecting tr and the top n with the largest D (tr, QTR) in the QTRcConstructing a candidate set CTR by using the untested cases, and selecting the test case tr with the highest risk in the CTRjCheck is made, add it to the QTR queue and remove it from tr if the test case is marked as a fault and δ>And 0, updating the keyword vector KV, updating the risk value RV, and repeating the operation until the tr length is 0.
Due to the adoption of the technical scheme, the Simulink test method based on the risk strategy and the diversity strategy provided by the invention utilizes two key strategies: the diversity strategy Var is used for helping to check various test cases and avoiding the repeated error classification of the test; the risk policy Dan helps identify test cases that are more likely to reveal errors. By combining the two strategies, errors are discovered as early as possible and as many as possible.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart of the method of the present invention
FIG. 2 is a schematic diagram of a Simulink model file in the present invention
FIG. 3 is a schematic diagram of the Simulink model of the present invention
FIG. 4 is a schematic diagram of a common Simulink module of the present invention
FIG. 5 is a diagram of an exemplary keyword dictionary in accordance with the present invention
FIG. 6 is a schematic diagram of an exemplary keyword matrix in the present invention
FIG. 7 is a schematic diagram of an exemplary distance matrix in the present invention
Detailed Description
In order to make the technical solutions and advantages of the present invention clearer, the following describes the technical solutions in the embodiments of the present invention clearly and completely with reference to the drawings in the embodiments of the present invention:
as shown in fig. 1, a Simulink test method based on a risk policy and a diversity policy specifically includes the following steps:
collecting test cases, and randomly generating a tool Slforge by using a Simulink program to generate the test cases, wherein FIG. 2 is a generated Simulink model file, and FIG. 3 is a corresponding Simulink model. Judging whether Simulink crash is caused or not through an error detection program, and marking the Simulink as 'fault' if the Simulink error is found;
and processing the generated test case: the Simulink test cases record modules appearing in corresponding Simulink models and connection relations among the modules, and the name and the frequency of the Simulink modules appearing in each test case are counted; as shown in fig. 4, is a common Simulink module.
Modeling the keyword vector: constructing a keyword dictionary by the Simulink module names appearing in all test cases, recording the occurrence frequency of each keyword, and removing some keywords with the occurrence frequency lower than a threshold value epsilon by setting the threshold value epsilon, as shown in FIG. 5;
constructing a keyword matrix KV: constructing a keyword vector tr for each test casei=(ei,1,ei,2,...,ei,m) Where m is the number of keywords in the keyword dictionary. If the ith test case contains the jth keyword in the keyword dictionary, e i,j1, otherwise e i,j0; KV is an n × m matrix, n represents that there are n test cases, and m represents that there are m keywords in the keyword dictionary, as shown in FIG. 6;
constructing a risk vector RV: statistical keyword vector triThe number of the middle 1 is used as a risk value in the test caseRepresenting, calculating a risk value of each test case, and constructing a risk vector RV formed by n error reports;
constructing a distance matrix DM: calculating the distance of each pair of test cases based on the keyword matrix KV, and aiming at two keyword vectors triAnd trkWill correspond to e in the position ji,jAnd ek,jThe number of different values is counted as distance D (tr)i,trk). Calculating the distance of each pair of test cases to construct a distance matrix DM, as shown in fig. 7;
carrying out prioritization treatment on the test cases: the Simulink test cases are prioritized using a risk strategy Dan based on a risk vector RV, a diversity strategy Var based on a distance matrix DM, and a diversity risk hybrid strategy VarDan combining the two strategies.
Further, the risk strategy Dan is that the test case tr with the highest risk value RV (i) is selected each timeiPut it into the ordered queue QTR and delete the test case from tr. Then selecting the test case tr with the highest risk value RV (i) from the rest test cases of triRepeating the above operations until tr is 0;
and adopting a dynamic prioritization strategy according to the risk vector RV and the inspection result. I.e. if the test case trkIs determined to find an error, tr in KVkThe weights of all the keywords are increased by delta, and the risk vector RV is changed along with the delta;
the diversity strategy Var is implemented by firstly selecting the test case tr with the highest risk valueiPutting into QTR, deleting it from tr, and selecting the test case tr which is farthest from QTR, i.e. the test case tr with the largest D (tr, QTR) from trjPutting into QTR, deleting the QTR from TR, and repeating the operation until the length of TR is 0;
further, the diversity risk hybrid strategy VarDan approach is to combine the risk strategy and the diversity strategy into one hybrid strategy. Selecting the test case with the largest risk value to be checked, putting the test case into the QTR and deleting the test case from tr, and selecting tr and the top n with the largest D (tr, QTR) in the QTRcConstructing a candidate set CTR by using the untested cases, and selecting the test case tr with the highest risk in the CTRjA check is made to add it to the QTR queue and remove it from tr if the test case is marked as "fault" and δ>0, updating the keyword vector KV, updating the risk value RV, and repeating the operation until the tr length is 0;
the above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be considered to be within the technical scope of the present invention, and the technical solutions and the inventive concepts thereof according to the present invention should be equivalent or changed within the scope of the present invention.
Claims (7)
1. A Simulink test method based on a risk strategy and a diversity strategy is characterized by comprising the following steps:
collecting test cases, randomly generating a tool Slforge by adopting a Simulink program to generate the test cases, judging whether Simulink crash is caused or not by an error detection program, and marking the Simulink as fault if a Simulink error is found;
and processing the generated test case: counting the names and the occurrence times of the Simulink modules appearing in each test case;
modeling the keyword vector: constructing a keyword dictionary by the Simulink module names appearing in all test cases, recording the occurrence frequency of each keyword, and deleting the keywords with the occurrence frequency lower than a set threshold value;
constructing a keyword matrix KV, a risk vector RV and a distance matrix DM;
carrying out prioritization treatment on the test cases: the Simulink test cases are prioritized using a risk strategy Dan based on a risk vector RV, a diversity strategy Var based on a distance matrix DM, and a diversity risk hybrid strategy VarDan combining the two strategies.
2. The method of claim 1, wherein: when the keyword matrix KV is constructed: constructing a keyword vector tr for each test casei=(ei,1,ei,2,...,ei,m) Wherein m is the number of keywords in the keyword dictionary; if the ith test case contains the jth keyword in the keyword dictionary, ei,j1, otherwise ei,jKV is an n × m matrix, where n denotes n test cases and m denotes m keywords in the keyword dictionary.
4. The method of claim 2, wherein: when the distance matrix DM is constructed: calculating the distance of each pair of test cases based on the keyword matrix KV, and aiming at two keyword vectors triAnd trkWill correspond to e in the position ji,jAnd ek,jThe number of different values is counted as distance D (tr)i,trk) And calculating the distance of each pair of test cases to construct a distance matrix DM.
5. The method of claim 1, wherein: when the risk strategy Dan is adopted to carry out the prioritization and the sequencing on the Simulink test cases: selecting the test case tr with the highest risk value RV (i)iPutting the test cases into an ordered queue QTR, deleting the test case from tr, and selecting the test case tr with the highest risk value RV (i) from the rest test cases of triThe above operation is repeated until tr is 0 in length.
6. The method of claim 1, wherein: when the diversity strategy Var is adopted to prioritize the Simulink test cases: selecting the test case tr with the highest risk valueiPutting into QTR, deleting it from tr, and selecting the test case tr which is farthest from QTR, i.e. the test case tr with the largest D (tr, QTR) from trjPut into QTR, delete it from TR too, repeat the above operation until TR length is 0.
7. The method of claim 1, wherein: when the diversity risk mixing strategy Vardan is adopted to carry out the prioritization and the ordering on the Simulink test cases: selectingSelecting the test case with the largest risk value to be checked, putting the test case into the QTR and deleting the test case from tr, and selecting tr and the top n with the largest D (tr, QTR) in the QTRcConstructing a candidate set CTR by using the untested cases, and selecting the test case tr with the highest risk in the CTRjCheck is made, add it to the QTR queue and remove it from tr if the test case is marked as a fault and δ>And 0, updating the keyword vector KV, updating the risk value RV, and repeating the operation until the tr length is 0.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110944362.6A CN113672508B (en) | 2021-08-17 | 2021-08-17 | Simulink testing method based on risk strategy and diversity strategy |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110944362.6A CN113672508B (en) | 2021-08-17 | 2021-08-17 | Simulink testing method based on risk strategy and diversity strategy |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113672508A true CN113672508A (en) | 2021-11-19 |
CN113672508B CN113672508B (en) | 2023-09-22 |
Family
ID=78543477
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110944362.6A Active CN113672508B (en) | 2021-08-17 | 2021-08-17 | Simulink testing method based on risk strategy and diversity strategy |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113672508B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114896144A (en) * | 2022-04-26 | 2022-08-12 | 大连海事大学 | Knowledge base-based CPS model equivalent modulus input variation test method |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050246207A1 (en) * | 2004-03-31 | 2005-11-03 | Noonan Scott A | Method for risk based testing |
US7506312B1 (en) * | 2008-01-31 | 2009-03-17 | International Business Machines Corporation | Method and system for automatically determining risk areas to retest |
JP2009294846A (en) * | 2008-06-04 | 2009-12-17 | Denso Corp | Test case generator, and test case generation program and method |
US8849626B1 (en) * | 2010-06-23 | 2014-09-30 | Iowa State University Research Foundation, Inc. | Semantic translation of stateflow diagrams into input/output extended finite automata and automated test generation for simulink/stateflow diagrams |
CN104536881A (en) * | 2014-11-28 | 2015-04-22 | 南京慕测信息科技有限公司 | Public testing error report priority sorting method based on natural language analysis |
CN111651722A (en) * | 2020-04-08 | 2020-09-11 | 西窗科技(苏州)有限公司 | Risk assessment method and platform for advertisement putting effect of advertiser |
-
2021
- 2021-08-17 CN CN202110944362.6A patent/CN113672508B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050246207A1 (en) * | 2004-03-31 | 2005-11-03 | Noonan Scott A | Method for risk based testing |
US7506312B1 (en) * | 2008-01-31 | 2009-03-17 | International Business Machines Corporation | Method and system for automatically determining risk areas to retest |
JP2009294846A (en) * | 2008-06-04 | 2009-12-17 | Denso Corp | Test case generator, and test case generation program and method |
US8849626B1 (en) * | 2010-06-23 | 2014-09-30 | Iowa State University Research Foundation, Inc. | Semantic translation of stateflow diagrams into input/output extended finite automata and automated test generation for simulink/stateflow diagrams |
CN104536881A (en) * | 2014-11-28 | 2015-04-22 | 南京慕测信息科技有限公司 | Public testing error report priority sorting method based on natural language analysis |
CN111651722A (en) * | 2020-04-08 | 2020-09-11 | 西窗科技(苏州)有限公司 | Risk assessment method and platform for advertisement putting effect of advertiser |
Non-Patent Citations (1)
Title |
---|
张德平;查日军;: "划分测试用例选择的风险决策方法", 计算机应用研究, no. 12 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114896144A (en) * | 2022-04-26 | 2022-08-12 | 大连海事大学 | Knowledge base-based CPS model equivalent modulus input variation test method |
Also Published As
Publication number | Publication date |
---|---|
CN113672508B (en) | 2023-09-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102135979B (en) | Data cleaning method and device | |
EP4075281A1 (en) | Ann-based program test method and test system, and application | |
CN114936158B (en) | Software defect positioning method based on graph convolution neural network | |
CN105871879A (en) | Automatic network element abnormal behavior detection method and device | |
CN111338950A (en) | Software defect feature selection method based on spectral clustering | |
CN115587543A (en) | Federal learning and LSTM-based tool residual life prediction method and system | |
CN115098292B (en) | Method and device for identifying root cause of application program crash and electronic equipment | |
CN111833310A (en) | Surface defect classification method based on neural network architecture search | |
CN111177135B (en) | Landmark-based data filling method and device | |
CN112184679A (en) | YOLOv 3-based wine bottle flaw automatic detection method | |
CN113672508A (en) | Simulink test method based on risk strategy and diversity strategy | |
CN114910795A (en) | Battery micro-short circuit judgment method and system in constant current charging, storage medium and terminal | |
CN114596302A (en) | PCB defect detection method, system, medium, equipment and terminal | |
CN112948193B (en) | FPGA comprehensive tool defect detection method based on difference test | |
CN113408804A (en) | Electricity stealing behavior detection method, system, terminal equipment and storage medium | |
CN110929301B (en) | Hardware Trojan horse detection method based on lifting algorithm | |
CN112966964A (en) | Product matching method, device, equipment and storage medium based on design requirements | |
CN108830302B (en) | Image classification method, training method, classification prediction method and related device | |
CN113610350B (en) | Complex working condition fault diagnosis method, equipment, storage medium and device | |
CN112416920B (en) | MES-oriented data cleaning method and system | |
CN113076451B (en) | Abnormal behavior identification and risk model library establishment method and device and electronic equipment | |
CN110177006B (en) | Node testing method and device based on interface prediction model | |
CN113656354A (en) | Log classification method, system, computer device and readable storage medium | |
CN112597699A (en) | Social network rumor source identification method integrated with objective weighting method | |
CN112416789B (en) | Process metric element evaluation method for evolution software |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |