Abstract
Coverage biased random testing of software consists of drawing uniformly at random a large sample of paths from the control graph of a program, or from traces of its specification or model. In order to obtain input values that exercise them, the conditions for following each path/trace are incrementally collected into a formula, which characterises the values that lead to traverse it at run time. A solver is then used for obtaining a test set that ensures the coverage of the sample.
A well-known problem is that not all paths/traces correspond to feasible runs. Such infeasible paths/traces must be rejected and others must be drawn to ensure a sufficiently large number of test inputs. This severely limits the interest of the method when there is a high ratio of infeasible paths or traces, as it is often the case.
The new technique we propose uses knowledge about the shortest infeasible prefixes of infeasible paths that have been drawn to prevent future drawing of extensions of such prefixes. Starting with uniform drawing from all the paths/traces, the new algorithm incrementally shrinks the drawing domain and remains uniform among the paths/traces that do not have a known infeasible prefix. As the number of infeasible paths/traces is often large, their elimination from the subsequent drawings is a drastic improvement with respect to the simple path rejection method above.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
Given the set of unwanted elements, a folk result in probability theory is that such a drawing remains uniform among the non unwanted elements.
- 2.
- 3.
- 4.
- 5.
If we were to use very large numbers, as Rukia can do, we should consider the binary complexity of operations, yielding \(O(n^2 \times q)\) complexity for memory and construction of the table and \(O(n^2)\) for the drawing. For testing we stay beyond such limits as the feasibility of very long paths is unlikely [34, 40].
- 6.
One example is the expectation of the number of drawings for collecting the full collection of paths (“Coupon Collector Problem”), see for instance [18]).
- 7.
Prefixes are never empty, always starting with \(s_0\). The notation \(p.s.s'\), where p can be empty, emphasizes the last arc \(s.s'\), which can lead to an infeasibility.
- 8.
Checking for feasibility is performed by the system that calls Rukia; this additional information provided by Rukia, at no extra cost, can save quantities of computations.
- 9.
In parallel processes, synchronisation may introduce infeasibilities, see [9].
- 10.
For the experiments, Rukia and Auguste have been instrumented to provide the values for parameters K, saved and size.
- 11.
And, if we discard any trailing padding, the numbers of paths per length is the same when drawing in the initial flow graph or in the optimal one.
References
Aïssat, R.: Détection de Chemins Infaisables : un Modèle Formel et un Algorithme. (Infeasible Path Detection : a Formal Model and an Algorithm). Ph.D. thesis, University of Paris-Saclay, France (2017). https://tel.archives-ouvertes.fr/tel-01567093
Aïssat, R., Gaudel, M., Voisin, F., Wolff, B.: A method for pruning infeasible paths via graph transformations and symbolic execution. In: International Conference on Software Quality, Reliability and Security, pp. 144–151. IEEE (2016). https://doi.org/10.1109/QRS.2016.26
Aïssat, R., Voisin, F., Wolff, B.: Infeasible paths elimination by symbolic execution techniques: proof of correctness and preservation of paths. Arch. Formal Proofs 2016 (2016). https://www.isa-afp.org/entries/InfPathElimination.shtml
Barbot, B., Basset, N., Beunardeau, M., Kwiatkowska, M.: Uniform sampling for timed automata with application to language inclusion measurement. In: Agha, G., Van Houdt, B. (eds.) Quantitative Evaluation of Systems. Lecture Notes in Computer Science, vol. 9826, pp. 175–190. Springer, Heidelberg (2016). https://doi.org/10.1007/S00453-016-0136-9
Bardin, S., Kosmatov, N., Marre, B., Mentré, D., Williams, N.: Test case generation with PathCrawler/LTest: how to automate an industrial testing process. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11247, pp. 104–120. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03427-6_12
Basset, N., Mairesse, J., Soria, M.: Uniform sampling for networks of automata. In: CONCUR. LIPIcs, vol. 85, pp. 36:1–36:16. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2017). https://doi.org/10.4230/LIPICS.CONCUR.2017.36
Bernard, J., Héam, P.-C., Kouchnarenko, O.: An approximation-based approach for the random exploration of large models. In: Dubois, C., Wolff, B. (eds.) TAP 2018. LNCS, vol. 10889, pp. 27–43. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-92994-1_2
Bernot, G., Gaudel, M., Marre, B.: Software testing based on formal specifications: a theory and a tool. Softw. Eng. J. 6(6), 387–405 (1991). https://doi.org/10.1049/SEJ.1991.0040
Bodini, O., Dien, M., Genitrini, A., Peschanski, F.: The combinatorics of barrier synchronization. In: Donatelli, S., Haar, S. (eds.) PETRI NETS 2019. LNCS, vol. 11522, pp. 386–405. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-21571-2_21
Burnim, J., Sen, K.: Heuristics for scalable dynamic test generation. In: Automated Software Engineering-ASE, pp. 443–446. IEEE (2008). https://doi.org/10.1109/ASE.2008.69
Cavalcanti, A., Gaudel, M.: Testing for refinement in Circus. Acta Informatica 48(2), 97–147 (2011). https://doi.org/10.1007/S00236-011-0133-Z
Denise, A., Gaudel, M., Gouraud, S.: A generic method for statistical testing. In: International Symposium on Software Reliability Engineering, pp. 25–34. IEEE Computer Society (2004). https://doi.org/10.1109/ISSRE.2004.2
Denise, A., Gaudel, M., Gouraud, S., Lassaigne, R., Oudinet, J., Peyronnet, S.: Coverage-biased random exploration of large models and application to testing. Int. J. Softw. Tools Technol. Transf. 14(1), 73–93 (2012). https://doi.org/10.1007/S10009-011-0190-1
Dick, J., Faivre, A.: Automating the generation and sequencing of test cases from model-based specifications. In: Woodcock, J.C.P., Larsen, P.G. (eds.) FME Symposium. Lecture Notes in Computer Science, vol. 670, pp. 268–284. Springer, Heidelberg (1993).https://doi.org/10.1007/BFB0024651
Do, H., Elbaum, S., Rothermel, G.: Supporting controlled experimentation with testing techniques: an infrastructure and its potential impact. Empir. Softw. Eng. 10(4), 405–435 (2005). https://doi.org/10.1007/s10664-005-3861-2
Duchon, P., Flajolet, P., Louchard, G., Schaeffer, G.: Random sampling from Boltzmann principles. In: Widmayer, P., Eidenbenz, S., Triguero, F., Morales, R., Conejo, R., Hennessy, M. (eds.) ICALP 2002. LNCS, vol. 2380, pp. 501–513. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45465-9_43
Feliachi, A., Gaudel, M.-C., Wenzel, M., Wolff, B.: The Circus testing theory revisited in Isabelle/HOL. In: Groves, L., Sun, J. (eds.) ICFEM 2013. LNCS, vol. 8144, pp. 131–147. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-41202-8_10
Flajolet, P., Gardy, D., Thimonier, L.: Birthday paradox, coupon collectors, caching algorithms and self-organizing search. Disc. Appl. Math. 39(3), 207–229 (1992). https://doi.org/10.1016/0166-218X(92)90177-C
Flajolet, P., Zimmermann, P., Cutsem, B.V.: A calculus for the random generation of labelled combinatorial structures. Theor. Comput. Sci. 132(2), 1–35 (1994). https://doi.org/10.1016/0304-3975(94)90226-7
Godefroid, P., Klarlund, N., Sen, K.: DART: directed automated random testing. In: Conference on Programming Language Design and Implementation - PLDI, pp. 213–223. ACM (2005). https://doi.org/10.1145/1065010.1065036
Godefroid, P., Levin, M.Y., Molnar, D.A.: SAGE: whitebox fuzzing for security testing. Commun. ACM 55(3), 40–44 (2012). https://doi.org/10.1145/2093548.2093564
Grosu, R., Smolka, S.A.: Monte Carlo model checking. In: Halbwachs, N., Zuck, L.D. (eds.) TACAS 2005. LNCS, vol. 3440, pp. 271–286. Springer, Heidelberg (2005). https://doi.org/10.1007/978-3-540-31980-1_18
Gwehenberger, G.: Anwendung einer binären verweiskettenmethode beim aufbau von listen. Elektron. Rechenanlagen 10(5), 223–226 (1968). https://doi.org/10.1524/ITIT.1968.10.16.223
Havelund, K., Visser, W.: Program model checking as a new trend. Int. J. Softw. Tools Technol. Transf. 4(1), 8–20 (2002). https://doi.org/10.1007/S10009-002-0080-7
Henzinger, T.A., Jhala, R., Majumdar, R., Sutre, G.: Lazy abstraction. In: Symposium on Principles of Programming Languages, POPL. pp. 58–70. ACM (2002). https://doi.org/10.1145/503272.503279
Jaffar, J., Murali, V.: A path-sensitively sliced control flow graph. In: Symposium on Foundations of Software Engineering, pp. 133–143. ACM (2014).https://doi.org/10.1145/2635868.2635884
Jaffar, J., Murali, V., Navas, J.A., Santosa, A.E.: TRACER: a symbolic execution tool for verification. In: Madhusudan, P., Seshia, S.A. (eds.) CAV 2012. LNCS, vol. 7358, pp. 758–766. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-31424-7_61
Jones, C., Randell, B.: Dependable pervasive systems. School of Computing Science Technical Report Series (CS-TR-839) (2004). http://www.cs.ncl.ac.uk/publications/trs/papers/839.pdf
Lorenz, W.A., Ponty, Y.: Non-redundant random generation algorithms for weighted context-free grammars. Theor. Comput. Sci. 502, 177–194 (2013). https://doi.org/10.1016/J.TCS.2013.01.006
Miller, B.P., Fredriksen, L., So, B.: An empirical study of the reliability of UNIX utilities. Commun. ACM 33(12), 32–44 (1990). https://doi.org/10.1145/96267.96279
Morrison, D.R.: PATRICIA - practical algorithm to retrieve information coded in alphanumeric. J. ACM 15(4), 514–534 (1968). https://doi.org/10.1145/321479.321481
Oudinet, J.: Approches combinatoires pour le test statistique à grande échelle. Ph.D. thesis, Université Paris-Sud XI (2010). http://www.theses.fr/2010PA112347
Oudinet, J., Denise, A., Gaudel, M.-C., Lassaigne, R., Peyronnet, S.: Uniform Monte-Carlo model checking. In: Giannakopoulou, D., Orejas, F. (eds.) FASE 2011. LNCS, vol. 6603, pp. 127–140. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-19811-3_10
Papadakis, M., Malevris, N.: A symbolic execution tool based on the elimination of infeasible paths. In: Conference on Software Engineering Advances, ICSEA, pp. 435–440. IEEE Computer Society (2010). https://doi.org/10.1109/ICSEA.2010.74
Sen, K., Marinov, D., Agha, G.: CUTE: a concolic unit testing engine for C. In: European Software Engineering Conference - ESEC, pp. 263–272. ACM (2005). https://doi.org/10.1145/1081706.1081750
Thévenod-Fosse, P., Waeselynck, H.: An investigation of statistical software testing. Softw. Test. Verificat. Reliab. 1(2), 5–25 (1991). https://doi.org/10.1002/stvr.4370010203
Wilf, H.S.: A unified setting for sequencing, ranking, and selection algorithms for combinatorial objects. Adv. Math. 24(2), 281–291 (1977). https://doi.org/10.1016/0001-8708(77)90059-7
Williams, N., Kosmatov, N.: Automated structural testing with pathCrawler. a tutorial, examples (2012). http://pathcrawler-online.com:8080/tutorial/tutorial2012examples.pdf
Williams, N., Marre, B., Mouy, P., Roger, M.: PathCrawler: automatic generation of path tests by combining static and dynamic analysis. In: Dal Cin, M., Kaâniche, M., Pataricza, A. (eds.) EDCC 2005. LNCS, vol. 3463, pp. 281–292. Springer, Heidelberg (2005). https://doi.org/10.1007/11408901_21
Yates, D.F., Malevris, N.: Reducing the effects of infeasible paths in branch testing. In: Symposium on Testing, Analysis, and Verification - TAV, pp. 48–54. ACM (1989). https://doi.org/10.1145/75308.75315
Acknowlegdments
We are indebted to Alain Denise, Danièle Gardy and Yann Ponty for interesting and fruitful discussions. We are grateful to the reviewers for their careful reading and numerous useful remarks.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Appendix: Transposition of the method to Boltzmann samplers.
Appendix: Transposition of the method to Boltzmann samplers.
The method can be used to enrich other drawing methods than the classical recursive one considered in this paper, for instance Boltzmann samplers. This would make possible, instead of drawing among bounded paths, to have some probability distributions on the length of the paths. Such samplers exist in two varieties, the ordinary version and the exponential version. In this appendix we explain how our method is applicable to ordinary Boltzmann sampling [16]. The same approach is can be done for exponential Boltzmann sampling.
1.1 Ordinary Boltzmann Samplers in a Nutshell
Instead of using Eq. (1), which is based on the number of paths of a given length from a given vertex, Boltzmann samplers use recursive equations on generating functions of the sets of all paths from a given vertex. In contrast with the recursive method, which allows to uniformly draw objects of a fixed size (or in our context paths of bounded lengths), such samplers return objects of random sizes and ensure uniformity for the objects of the same size. It is possible to tune these samplers to favour objects of a size in the vicinity of a given value. When drawing paths, using such samplers would avoid introducing a bound on their lengths.
Consider the set of paths starting from a given vertex s as a language noted \(\mathcal {L}_s\). The ordinary generating function of parameter z of this language is:
where z is a complex variable and \(l_m\) the number of words of length m. Such a function is defined for values \(0 < z < \rho _L\) where \(\rho _L\) is called the convergence radius of L.
Given a value of z such that \( 0 < z < \rho _L\), an ordinary Boltzmann sampler draws a path p with probability \(z^{|p|}/L(z)\). The choice of the value of z determines the distribution on the lengths of the paths. For more details and complexity results, see [16] and [6].
1.2 Taking into Account Infeasibilities in a Control Flow Graph
The generating functions for the set of vertices of \(\mathcal {G}\) satisfy the following equation:
Similarly to what was done on the base of Eq. (1) in Sect. 2.3, Eq. (2) can be used to recursively define a drawing algorithm: if \(s = s_f\), since \(s_f\) has no successors, the random generation stops, otherwise a successor t of s is drawn with probability \(z L_t(z)/L_s(z)\), then the drawing algorithm is called recursively with t.
We observe that the enrichment of \(\mathcal {G}\) with an edge from \(s_f\) to itself, introduced in Subsect. 2.3 for drawing paths of lengths less or equal to bound n, is no longer necessary: as said above, Boltzmann samplers return paths of different lengths whose distribution, i.e. average value and variance, is adjustable.
One can note that when the aim is to draw only paths of an exact length, the sampler can be tuned via an adequate choice of z to a distribution of the lengths with small variance, and combined with a rejection method to filter unwanted paths, at the cost of a slightly increased complexity.
As noted in [16], a Boltzmann sampler requires as input the value of the parameter z, and the finite collection of the values at z of the generating functions used in the specification. These values need only to be computed once. In our case, it is the vector \(\mathbb {L}(z) = (L_s(z))_{s\in \mathcal {G}}\). It means that the memory requirement is significantly lower than for the recursive method O(q) instead of \(O(n \times q)\).
After detecting the infeasibility of some prefix \(p.s.s'\), the probability of drawing \(s'\) after p.s must become 0, and the probabilities of the vertices of p.s must be decreased, taking into account the size of \(\mathcal {L}_{s'}\), i.e. \(\mathbb {L}(z)_{s'} = L_{s'}(z)\). This can be achieved by complementing vector \(\mathbb {L}(z)\) by the same trie data structure as in Sect. 3. The contents of the vector and of the trie are different since the lengths of the paths, and therefore of the suffixes of the infeasible prefixes, are no longer taken into account. But the principles of algorithms for drawing with the trie, updating it, and pruning it remain unchanged.
We cannot report experiments with such samplers due to the lack of easily available and well documented implementations for the choice of z and the computation of \(\mathbb {L}(z)\).
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this chapter
Cite this chapter
Gaudel, MC., Voisin, F. (2024). Efficient Uniform Sampling of Traces in Presence of Infeasibilities. In: Cavalcanti, A., Baxter, J. (eds) The Practice of Formal Methods. Lecture Notes in Computer Science, vol 14780. Springer, Cham. https://doi.org/10.1007/978-3-031-66676-6_8
Download citation
DOI: https://doi.org/10.1007/978-3-031-66676-6_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-66675-9
Online ISBN: 978-3-031-66676-6
eBook Packages: Computer ScienceComputer Science (R0)