diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-18 23:13:19 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-10-18 23:13:19 +0000 |
commit | ee34e30d52f46b6a90578bd48172536392d2d5bf (patch) | |
tree | 2050c6befda04274c666d5ca5072150ee7e9b570 /src/scalarproduct | |
parent | 36a80c833a5d5eb8f30460bb484cac01bdd9b65c (diff) | |
download | gnunet-ee34e30d52f46b6a90578bd48172536392d2d5bf.tar.gz gnunet-ee34e30d52f46b6a90578bd48172536392d2d5bf.zip |
removed final non functional dead leftover code from gaurav... may that code be forgotten
testcases now do better logging together with make check
made testcases a bit more tolerat for really slow systems (5 seconds should suffice even on older systems)
activated new checks in Makefile
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/Makefile.am | 51 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_testing.h | 150 | ||||
-rwxr-xr-x | src/scalarproduct/test_scalarproduct.sh | 25 | ||||
-rwxr-xr-x | src/scalarproduct/test_scalarproduct_negative.sh | 26 | ||||
-rwxr-xr-x | src/scalarproduct/test_scalarproduct_negativezero.sh | 28 |
5 files changed, 38 insertions, 242 deletions
diff --git a/src/scalarproduct/Makefile.am b/src/scalarproduct/Makefile.am index c4c56a802..4bfdfcd7d 100644 --- a/src/scalarproduct/Makefile.am +++ b/src/scalarproduct/Makefile.am | |||
@@ -53,46 +53,15 @@ libgnunetscalarproduct_la_LIBADD = \ | |||
53 | libgnunetscalarproduct_la_LDFLAGS = \ | 53 | libgnunetscalarproduct_la_LDFLAGS = \ |
54 | $(GN_LIB_LDFLAGS) | 54 | $(GN_LIB_LDFLAGS) |
55 | 55 | ||
56 | #check_PROGRAMS = \ | 56 | EXTRA_DIST = \ |
57 | # test_scalarproduct_api_regression \ | 57 | test_scalarproduct.conf \ |
58 | # test_scalarproduct_api \ | 58 | $(check_SCRIPTS) |
59 | # test_scalarproduct_api_4peers | 59 | |
60 | #FIXME unfinished | 60 | check_SCRIPTS = \ |
61 | #test_scalarproduct_api_regression2 | 61 | test_scalarproduct.sh \ |
62 | 62 | test_scalarproduct_negative.sh \ | |
63 | test_scalarproduct_negativezero.sh | ||
64 | |||
63 | if ENABLE_TEST_RUN | 65 | if ENABLE_TEST_RUN |
64 | TESTS = $(check_PROGRAMS) | 66 | TESTS = $(check_SCRIPTS) |
65 | endif | 67 | endif |
66 | |||
67 | test_scalarproduct_api_SOURCES = \ | ||
68 | test_scalarproduct_api.c | ||
69 | test_scalarproduct_api_LDADD = \ | ||
70 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
71 | $(top_builddir)/src/scalarproduct/libgnunetscalarproduct.la \ | ||
72 | -lgcrypt | ||
73 | |||
74 | #FIXME unfinished | ||
75 | #test_scalarproduct_api_regression2_SOURCES = \ | ||
76 | # test_scalarproduct_api_regression2.c | ||
77 | #test_scalarproduct_api_regression2_LDADD = \ | ||
78 | # $(top_builddir)/src/scalarproduct/libgnunetscalarproduct.la \ | ||
79 | # $(top_builddir)/src/util/libgnunetutil.la \ | ||
80 | # -lgcrypt | ||
81 | |||
82 | test_scalarproduct_api_regression_SOURCES = \ | ||
83 | test_scalarproduct_api_regression.c | ||
84 | test_scalarproduct_api_regression_LDADD = \ | ||
85 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
86 | $(top_builddir)/src/scalarproduct/libgnunetscalarproduct.la \ | ||
87 | -lgcrypt | ||
88 | |||
89 | test_scalarproduct_api_4peers_SOURCES = \ | ||
90 | test_scalarproduct_api_4peers.c | ||
91 | test_scalarproduct_api_4peers_LDADD = \ | ||
92 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
93 | $(top_builddir)/src/scalarproduct/libgnunetscalarproduct.la \ | ||
94 | -lgcrypt | ||
95 | |||
96 | EXTRA_DIST = \ | ||
97 | test_scalarproduct.conf | ||
98 | |||
diff --git a/src/scalarproduct/scalarproduct_testing.h b/src/scalarproduct/scalarproduct_testing.h deleted file mode 100644 index 5e7baa235..000000000 --- a/src/scalarproduct/scalarproduct_testing.h +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file scalarproduct/scalarproduct_testing.h | ||
22 | * @brief VectorProduct testcase common declarations | ||
23 | * @author Gaurav Kukreja | ||
24 | * @author Christian Fuchs | ||
25 | * | ||
26 | * Created on June 29, 2013, 7:39 PM | ||
27 | */ | ||
28 | |||
29 | #ifndef SCALARPRODUCT_TESTING_H | ||
30 | #define SCALARPRODUCT_TESTING_H | ||
31 | |||
32 | #ifdef __cplusplus | ||
33 | extern "C" { | ||
34 | #endif | ||
35 | |||
36 | struct GNUNET_SCALARPRODUCT_TESTING_handle | ||
37 | { | ||
38 | /** | ||
39 | * Testing library system handle | ||
40 | */ | ||
41 | struct GNUNET_TESTING_System *tl_system; | ||
42 | |||
43 | /** | ||
44 | * head DLL of peers | ||
45 | */ | ||
46 | struct PeerContext *p_head; | ||
47 | |||
48 | /** | ||
49 | * tail DLL of peers | ||
50 | */ | ||
51 | struct PeerContext *p_tail; | ||
52 | }; | ||
53 | |||
54 | struct PeerContext | ||
55 | { | ||
56 | /** | ||
57 | * Next element in the DLL | ||
58 | */ | ||
59 | struct PeerContext *next; | ||
60 | |||
61 | /** | ||
62 | * Previous element in the DLL | ||
63 | */ | ||
64 | struct PeerContext *prev; | ||
65 | |||
66 | /** | ||
67 | * Peer's testing handle | ||
68 | */ | ||
69 | struct GNUNET_TESTING_Peer *peer; | ||
70 | |||
71 | /** | ||
72 | * Peer identity | ||
73 | */ | ||
74 | struct GNUNET_PeerIdentity id; | ||
75 | |||
76 | /** | ||
77 | * Handle for the peer's ARM process | ||
78 | */ | ||
79 | struct GNUNET_OS_Process *arm_proc; | ||
80 | |||
81 | /** | ||
82 | * Pointer to Vector Product Handle | ||
83 | */ | ||
84 | struct GNUNET_SCALARPRODUCT_Handle *vh; | ||
85 | |||
86 | /** | ||
87 | * Closure for the callbacks | ||
88 | */ | ||
89 | void *cb_cls; | ||
90 | |||
91 | /** | ||
92 | * An unique number to identify the peer | ||
93 | */ | ||
94 | unsigned int no; | ||
95 | |||
96 | /** | ||
97 | * Peer's configuration | ||
98 | */ | ||
99 | struct GNUNET_CONFIGURATION_Handle *cfg; | ||
100 | |||
101 | /** | ||
102 | * Pointer to the master testing handle | ||
103 | */ | ||
104 | struct GNUNET_SCALARPRODUCT_TESTING_handle * vth; | ||
105 | |||
106 | /** | ||
107 | * Callback when two peers are connected and both have called the connect callback | ||
108 | * to notify clients about a new peer | ||
109 | */ | ||
110 | void (*start_cb) (struct PeerContext * p, void *cls); | ||
111 | |||
112 | // /** | ||
113 | // * Pointer to function where the test occurs | ||
114 | // */ | ||
115 | // GNUNET_SCALARPRODUCT_TESTING_start_cb start_cb; | ||
116 | }; | ||
117 | |||
118 | /** | ||
119 | * Callback when two peers are connected and both have called the connect callback | ||
120 | * to notify clients about a new peer | ||
121 | */ | ||
122 | typedef void (*GNUNET_SCALARPRODUCT_TESTING_start_cb) (struct PeerContext * p, | ||
123 | void *cls); | ||
124 | |||
125 | struct GNUNET_SCALARPRODUCT_TESTING_handle * | ||
126 | GNUNET_SCALARPRODUCT_TESTING_init(); | ||
127 | |||
128 | static void | ||
129 | GNUNET_SCALARPRODUCT_TESTING_done(struct GNUNET_SCALARPRODUCT_TESTING_handle * vth); | ||
130 | |||
131 | struct PeerContext * | ||
132 | GNUNET_SCALARPRODUCT_TESTING_start_peer (struct GNUNET_SCALARPRODUCT_TESTING_handle * vth, | ||
133 | const char *cfgname, int peer_id, | ||
134 | GNUNET_SCALARPRODUCT_TESTING_start_cb start_cb, | ||
135 | void *cb_cls); | ||
136 | |||
137 | static void | ||
138 | GNUNET_SCALARPRODUCT_TESTING_stop_peer | ||
139 | (struct GNUNET_SCALARPRODUCT_TESTING_handle * vth, | ||
140 | struct PeerContext *p); | ||
141 | |||
142 | |||
143 | |||
144 | |||
145 | #ifdef __cplusplus | ||
146 | } | ||
147 | #endif | ||
148 | |||
149 | #endif /* SCALARPRODUCT_TESTING_H */ | ||
150 | |||
diff --git a/src/scalarproduct/test_scalarproduct.sh b/src/scalarproduct/test_scalarproduct.sh index 82b42e992..7b183d0b5 100755 --- a/src/scalarproduct/test_scalarproduct.sh +++ b/src/scalarproduct/test_scalarproduct.sh | |||
@@ -16,34 +16,27 @@ CFGBOB="-c $PREFIX/1/config" | |||
16 | # interactive mode would terminate the test immediately | 16 | # interactive mode would terminate the test immediately |
17 | # because the rest of the script is already in stdin, | 17 | # because the rest of the script is already in stdin, |
18 | # thus redirecting stdin does not suffice) | 18 | # thus redirecting stdin does not suffice) |
19 | GNUNET_LOG='scalarproduct;;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log & | 19 | GNUNET_LOG=';;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 & |
20 | PID=$! | 20 | PID=$! |
21 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe | ||
21 | sleep 5 | 22 | sleep 5 |
22 | 23 | ||
23 | # get bob's peer ID, necessary for alice | 24 | # get bob's peer ID, necessary for alice |
24 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` | 25 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` |
25 | 26 | ||
26 | GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log & | 27 | GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB & |
27 | RESULT=`GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log` | 28 | RESULT=`GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` |
28 | |||
29 | cat alice.log bob.log service.log >> test_scalarproduct.log | ||
30 | rm -f alice.log bob.log service.log | ||
31 | ISSUES=$((`grep scalarproduct test_scalarproduct.log | grep -c ERROR` + `grep scalarproduct test_scalarproduct.log | grep -c WARNING`)) | ||
32 | 29 | ||
33 | # terminate the testbed | 30 | # terminate the testbed |
34 | kill $PID | 31 | kill $PID |
35 | 32 | ||
36 | EXPECTED="0CCC" | 33 | EXPECTED="0CCC" |
37 | if [ "$ISSUES" -eq "0" ] | 34 | if [ "$RESULT" == "$EXPECTED" ] |
38 | then | 35 | then |
39 | if [ "$RESULT" == "$EXPECTED" ] | 36 | echo "OK" |
40 | then | 37 | exit 0 |
41 | echo "OK" | ||
42 | rm -f test_scalarproduct.log | ||
43 | exit 0 | ||
44 | fi | ||
45 | else | 38 | else |
46 | echo "Result $RESULT NOTOK, see $PWD/test_scalarproduct.log for details" | 39 | echo "Result $RESULT NOTOK" |
47 | exit 1 | 40 | exit 1 |
48 | fi | 41 | fi |
49 | 42 | ||
diff --git a/src/scalarproduct/test_scalarproduct_negative.sh b/src/scalarproduct/test_scalarproduct_negative.sh index 27fd345cc..1267a41ca 100755 --- a/src/scalarproduct/test_scalarproduct_negative.sh +++ b/src/scalarproduct/test_scalarproduct_negative.sh | |||
@@ -16,34 +16,26 @@ CFGBOB="-c $PREFIX/1/config" | |||
16 | # interactive mode would terminate the test immediately | 16 | # interactive mode would terminate the test immediately |
17 | # because the rest of the script is already in stdin, | 17 | # because the rest of the script is already in stdin, |
18 | # thus redirecting stdin does not suffice) | 18 | # thus redirecting stdin does not suffice) |
19 | GNUNET_LOG='scalarproduct;;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log & | 19 | GNUNET_LOG=';;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 & |
20 | PID=$! | 20 | PID=$! |
21 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe | ||
21 | sleep 5 | 22 | sleep 5 |
22 | 23 | ||
23 | # get bob's peer ID, necessary for alice | 24 | # get bob's peer ID, necessary for alice |
24 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` | 25 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` |
25 | 26 | ||
26 | GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log & | 27 | GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB & |
27 | RESULT=`GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log` | 28 | RESULT=`GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` |
28 | |||
29 | cat alice.log bob.log service.log >> test_scalarproduct.log | ||
30 | rm -f alice.log bob.log service.log | ||
31 | ISSUES=$((`grep scalarproduct test_scalarproduct.log | grep -c ERROR` + `grep scalarproduct test_scalarproduct.log | grep -c WARNING`)) | ||
32 | 29 | ||
33 | # terminate the testbed | 30 | # terminate the testbed |
34 | kill $PID | 31 | kill $PID |
35 | 32 | ||
36 | EXPECTED="-0CCC" | 33 | EXPECTED="-0CCC" |
37 | if [ "$ISSUES" -eq "0" ] | 34 | if [ "$RESULT" == "$EXPECTED" ] |
38 | then | 35 | then |
39 | if [ "$RESULT" == "$EXPECTED" ] | 36 | echo "OK" |
40 | then | 37 | exit 0 |
41 | echo "OK" | ||
42 | rm -f test_scalarproduct.log | ||
43 | exit 0 | ||
44 | fi | ||
45 | else | 38 | else |
46 | echo "Result $RESULT NOTOK, see $PWD/test_scalarproduct.log for details" | 39 | echo "Result $RESULT NOTOK" |
47 | exit 1 | 40 | exit 1 |
48 | fi | 41 | fi |
49 | |||
diff --git a/src/scalarproduct/test_scalarproduct_negativezero.sh b/src/scalarproduct/test_scalarproduct_negativezero.sh index 5035bdffd..196c46782 100755 --- a/src/scalarproduct/test_scalarproduct_negativezero.sh +++ b/src/scalarproduct/test_scalarproduct_negativezero.sh | |||
@@ -1,7 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # compute a simple scalar product | 2 | # compute a simple scalar product |
3 | # payload for this test: | 3 | # payload for this test: |
4 | INPUTALICE="-k CCC -e -1,1,-1" | 4 | INPUTALICE="-k CCC -e -1,1,1" |
5 | INPUTBOB="-k CCC -e 1,1,0" | 5 | INPUTBOB="-k CCC -e 1,1,0" |
6 | 6 | ||
7 | # necessary to make the testing prefix deterministic, so we can access the config files | 7 | # necessary to make the testing prefix deterministic, so we can access the config files |
@@ -16,34 +16,26 @@ CFGBOB="-c $PREFIX/1/config" | |||
16 | # interactive mode would terminate the test immediately | 16 | # interactive mode would terminate the test immediately |
17 | # because the rest of the script is already in stdin, | 17 | # because the rest of the script is already in stdin, |
18 | # thus redirecting stdin does not suffice) | 18 | # thus redirecting stdin does not suffice) |
19 | GNUNET_LOG='scalarproduct;;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 2>service.log & | 19 | GNUNET_LOG=';;;;DEBUG' GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c test_scalarproduct.conf -p 2 & |
20 | PID=$! | 20 | PID=$! |
21 | # sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe | ||
21 | sleep 5 | 22 | sleep 5 |
22 | 23 | ||
23 | # get bob's peer ID, necessary for alice | 24 | # get bob's peer ID, necessary for alice |
24 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` | 25 | PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB` |
25 | 26 | ||
26 | GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB 2>bob.log & | 27 | GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGBOB $INPUTBOB & |
27 | RESULT=`GNUNET_LOG='scalarproduct;;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB 2>alice.log` | 28 | RESULT=`GNUNET_LOG=';;;;DEBUG' gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB` |
28 | |||
29 | cat alice.log bob.log service.log >> test_scalarproduct.log | ||
30 | rm -f alice.log bob.log service.log | ||
31 | ISSUES=$((`grep scalarproduct test_scalarproduct.log | grep -c ERROR` + `grep scalarproduct test_scalarproduct.log | grep -c WARNING`)) | ||
32 | 29 | ||
33 | # terminate the testbed | 30 | # terminate the testbed |
34 | kill $PID | 31 | kill $PID |
35 | 32 | ||
36 | EXPECTED="00" | 33 | EXPECTED="00" |
37 | if [ "$ISSUES" -eq "0" ] | 34 | if [ "$RESULT" == "$EXPECTED" ] |
38 | then | 35 | then |
39 | if [ "$RESULT" == "$EXPECTED" ] | 36 | echo "OK" |
40 | then | 37 | exit 0 |
41 | echo "OK" | ||
42 | rm -f test_scalarproduct.log | ||
43 | exit 0 | ||
44 | fi | ||
45 | else | 38 | else |
46 | echo "Result $RESULT NOTOK, see $PWD/test_scalarproduct.log for details" | 39 | echo "Result $RESULT NOTOK" |
47 | exit 1 | 40 | exit 1 |
48 | fi | 41 | fi |
49 | |||