From 0b172c4b146b0ba50c4c7e17c77c4e2281dd179b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 25 Jun 2005 05:32:57 +0000 Subject: First version of valgrind torture test. --- gpsfake | 1 + gpsfake.py | 12 +++--------- valgrind-audit | 23 +++++++++++++++++++++++ valgrind-suppressions | 15 ++------------- 4 files changed, 29 insertions(+), 22 deletions(-) create mode 100755 valgrind-audit diff --git a/gpsfake b/gpsfake index 9fe13649..a2004958 100755 --- a/gpsfake +++ b/gpsfake @@ -115,6 +115,7 @@ except OSError: test.client_add("w+r+\n") test.cleanup(); +test.killall() if progress: baton.end() diff --git a/gpsfake.py b/gpsfake.py index db10537d..cceedf2c 100644 --- a/gpsfake.py +++ b/gpsfake.py @@ -245,10 +245,11 @@ class TestSession: newgps.go_predicate = self.default_predicate self.fakegpslist[newgps.slave] = newgps self.daemon.add_device(newgps.slave) + return newgps.slave def gps_remove(self, name): "Remove a simulated GPS from the daeon's search list." self.fakegpslist[name].stop() - self.daemon.remove_device(newgps.slave) + self.daemon.remove_device(name) def client_add(self, commands): "Initiate a client session and force connection to a fake GPS." newclient = gps.gps() @@ -261,7 +262,7 @@ class TestSession: newclient.set_thread_hook(lambda x: self.reporter(x)) if commands: newclient.query(commands) - return newclient + return newclient.id def client_order(self, id, commands): "Ship a command down a client channel, accept a response." for client in self.clients: @@ -296,11 +297,4 @@ class TestSession: if fakegps.thread.isAlive(): fakegps.stop() -if __name__ == "__main__": - #prefix="valgrind --tool=memcheck", - test = TestSession(options="-D 4") - test.gps_add("test/bu303-moving.log") - test.client_add("w\n") - time.sleep(5) - # End diff --git a/valgrind-audit b/valgrind-audit new file mode 100755 index 00000000..f5cd56d6 --- /dev/null +++ b/valgrind-audit @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# +# This is a valgrind torture test for the daemon. +# +import gpsfake + +invocation="valgrind --tool=memcheck --gen-suppressions=yes --suppressions=valgrind-suppressions" +test = gpsfake.TestSession(prefix=invocation, options="-D 3") + +try: + print "*** Add a GPS." + gps1 = test.gps_add("test/bu303-moving.log") + + print "*** Add and remove a client." + c1 = test.client_add("w\n") + test.wait(3) + test.client_remove(c1) + + print "*** Remove a GPS." + test.gps_remove(gps1) +finally: + test.cleanup(); + test.killall() diff --git a/valgrind-suppressions b/valgrind-suppressions index eee8281c..90be3a5f 100644 --- a/valgrind-suppressions +++ b/valgrind-suppressions @@ -1,14 +1,3 @@ # Suppress known C library errors in valgrind. -# This is good under gcc 3.4.2, glibc 2.3.4 -{ - strlen1 - Memcheck:Value8 - fun:vfprintf - fun:vsnprintf - fun:gpsd_report - fun:sirf_parse - fun:sirfbin_parse_input - fun:handle_packet - fun:gpsd_poll - fun:main -} +# This is good under gcc 3.4.2, glibc 2.3.4, using -g and -O2 + -- cgit v1.2.1