"Initial commit to Gerrit"
[profile/ivi/gpsd.git] / valgrind-audit.in
1 #!@PYTHON@
2 #
3 # This is a valgrind torture test for the gpsd daemon.
4 # It's not really expected to spot anything as long as we aren't using
5 # malloc and friends in the daemon.
6 #
7 # This file is Copyright (c) 2010 by the GPSD project
8 # BSD terms apply: see the file COPYING in the distribution root for details.
9 #
10 import sys, gps.fake 
11
12 debuglevel=1
13
14 invocation="valgrind --tool=memcheck --gen-suppressions=yes --leak-check=yes --suppressions=valgrind-suppressions"
15 test = gps.fake.TestSession(prefix=invocation, options="-D %d" % debuglevel)
16 test.progress = sys.stderr.write
17
18 try:
19     test.spawn()
20     print "\n*** Test #1: Normal single-client-session behavior."
21     print "**** Add a GPS.\n"
22     gps1 = test.gps_add("test/daemon/bu303-moving.log")
23
24     print "\n**** Add and remove a client.\n"
25     c1 = test.client_add("w\n")
26     test.gather(3)
27     test.client_remove(c1)
28
29     print "\n**** Remove the GPS."
30     test.gps_remove(gps1)
31     print "*** Test #1 complete.\n"
32     test.wait(3)
33
34     ######################################################################
35
36     print "\n*** Test #2: Successive non-overlapping client sessions."
37     print "**** Add a GPS.\n"
38     gps1 = test.gps_add("test/daemon/bu303-climbing.log")
39
40     print "\n**** Add and remove first client.\n"
41     c1 = test.client_add("w\n")
42     test.gather(3)
43     test.client_remove(c1)
44     test.wait(3)
45
46     print "\n**** Add and remove second client.\n"
47     c2 = test.client_add("w\n")
48     test.gather(3)
49     test.client_remove(c2)
50     test.wait(3)
51
52     print "\n**** Remove the GPS."
53     test.gps_remove(gps1)
54     print "*** Test #2 complete.\n"
55     test.wait(3)
56
57     ######################################################################
58
59     print "\n*** Test #3: Overlapping client sessions."
60     print "**** Add a GPS.\n"
61     gps1 = test.gps_add("test/daemon/bu303-climbing.log")
62
63     print "\n**** Add first client.\n"
64     c1 = test.client_add("w\n")
65     test.gather(2)
66     print "\n**** Add second client.\n"
67     c2 = test.client_add("w\n")
68     test.gather(3)
69     print "\n**** Remove first client.\n"
70     test.client_remove(c1)
71     test.gather(2)
72     print "\n**** Remove second client.\n"
73     test.client_remove(c2)
74
75     print "\n**** Remove the GPS."
76     test.gps_remove(gps1)
77     print "*** Test #3 complete.\n"
78
79     ######################################################################
80
81     print "\n*** Test #4: GPS removed while client still active."
82     print "**** Add a GPS.\n"
83     gps1 = test.gps_add("test/daemon/bu303-moving.log")
84
85     print "\n**** Add a client.\n"
86     c1 = test.client_add("w\n")
87     test.gather(3)
88     print "\n**** Remove the GPS."
89     test.gps_remove(gps1)
90     test.wait(3)
91     print "\n**** Remove the client.\n"
92     test.client_remove(c1)
93
94     print "*** Test #4 complete.\n"
95 finally:
96     test.cleanup();
97
98 # The following sets edit modes for GNU EMACS
99 # Local Variables:
100 # mode:python
101 # End: