Testing List Deletion in C with Erlang: A Case Study from Quviq and Chalmers
This study explores the principles of debugging and testing C functions using Erlang in the context of list deletion. We investigate the properties of `gdsl_list_delete` and validate its behavior against the standard list operations in Erlang. Through randomized testing, we demonstrate how to ensure that the deletion of elements from a list maintains integrity. Our exploration also touches on real-world challenges, including a known GCC bug related to complex data types. Join us as we detail our findings and methodologies in software testing.
Testing List Deletion in C with Erlang: A Case Study from Quviq and Chalmers
E N D
Presentation Transcript
Debugging C with Erlang John Hughes Quviq AB/Chalmers University
Testing gdsl_list_delete prop_list_delete() -> ?FORALL(L,non_empty(list(int()), ?FORALL(X,elements(L), equals(from_gdsl_list( gdsl_list_delete(X,to_gdsl_list(L))), lists:delete(X,L) )). prop_list_delete() -> ?FORALL(L,non_empty(list(int()), ?FORALL(X,elements(L), begin New = from_gdsl_list( gdsl_list_delete(X,to_gdsl_list(L))), New == lists:delete(X,L) orelse New == reverse(lists:delete(X,reverse(L))) end)). reverse(lists:delete(X,reverse(L))) Failed! [0,10,0,10] 10 [0,10,0] /= [0,0,10] Failed! [6,0,6] 6 [0,6] /= [6,0]
Testing the link to C • For a randomtype T, generate • …and test identity(x)==x T identity(T x) { return x; } struct s {int a; complexfloat b;}
GCC Bugzilla Bug 39678 • Summary: ”complex type isn't passed correctly” • Reported: 7 April 2009 • Our counterexample found: 9 April • Patch posted: 9 April • 818 lines of comments in Bugzilla • Once the bug was simplified, a patch was quick to write
Want to try? quviq-licencer.com/promotion.html