Dynamic Symbolic Execution Tao Xie
Test Data Generation Human Brute Force Semi - Random Expensive, incomplete, … Brute Force Pairwise, predefined data, etc… Semi - Random Cheap, Fast “It passed a thousand tests” feeling Dynamic Symbolic Execution: IntelliTest/Pex, SAGE, CUTE, … Automated white-box Not random – Constraint Solving
Assumptions and Assertions void PexAssume.IsTrue(bool c) { if (!c) throw new AssumptionViolationException(); } void PexAssert.IsTrue(bool c) { if (!c) throw new AssertionViolationException(); } Assumptions and assertions induce branches Executions which cause assumption violations are ignored, not reported as errors or test cases
Background: DSE Choose next path Generates test data systematically Solve Execute&Monitor void CoverMe(int[] a) { if (a == null) return; if (a.Length > 0) if (a[0] == 1234567890) throw new Exception("bug"); } Constraints to solve a!=null a!=null && a.Length>0 a.Length>0 && a[0]==123456890 Input null {} {0} {123…} Observed constraints a==null a!=null && !(a.Length>0) a==null && a.Length>0 && a[0]!=1234567890 a[0]==1234567890 a==null F T a.Length>0 F T Done: There is no path left. a[0]==123… F T 4 4 4 4
Pex4Fun 1,857,924 clicked 'Ask Pex!' http://pex4fun.com/ Nikolai Tillmann, Jonathan De Halleux, Tao Xie, Sumit Gulwani and Judith Bishop. Teaching and Learning Programming and Software Engineering via Interactive Gaming. In ICSE 2013, SEE. http://taoxie.cs.illinois.edu/publications/icse13see-pex4fun.pdf
Pex4Fun https://sites.google.com/site/teachpex/Home/pex-usage-tips Click http://pex4fun.com/default.aspx?language=CSharp&sample=_Template Copy and modify the following code snippet in the code editing box (or simply click here) using System; using Microsoft.Pex.Framework; using Microsoft.Pex.Framework.Settings; [PexClass] public class Program { [PexMethod]//[PexMethod(TestEmissionFilter=PexTestEmissionFilter.All)] public static string testMethod(int x, int y) { PexAssume.IsTrue(y >= 0);//replace here with your assumption //... enter your code under test here //if (x == 10000) throw new Exception(); PexAssert.IsTrue(y >= 0);//replace here with your assertion return PexSymbolicValue.GetPathConditionString(); } }
Microsoft Visual Studio 2015/2017 IntelliTest https://msdn.microsoft.com/en-us/library/dn823749.aspx
Microsoft Visual Studio 2015/2017 IntelliTest https://msdn.microsoft.com/en-us/library/dn823749.aspx