aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet_dht_profiler.c4
-rw-r--r--src/dht/plugin_block_dht.c15
-rw-r--r--src/dht/test_dht_2dtorus.conf4
-rw-r--r--src/dht/test_dht_api_data.conf4
-rw-r--r--src/dht/test_dht_api_peer1.conf4
-rw-r--r--src/dht/test_dht_line.conf4
-rw-r--r--src/dht/test_dht_monitor.conf4
-rw-r--r--src/dht/test_dht_multipeer.conf4
-rw-r--r--src/dht/test_dht_tools.py.in184
9 files changed, 120 insertions, 107 deletions
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index 403deb38a..5341e7d61 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -45,7 +45,7 @@ static unsigned int put_probability = 100;
45/** 45/**
46 * Configuration 46 * Configuration
47 */ 47 */
48static struct GNUNET_CONFIGURATION_Handle *cfg; 48static const struct GNUNET_CONFIGURATION_Handle *cfg;
49 49
50/** 50/**
51 * Name of the file with the hosts to run the test over 51 * Name of the file with the hosts to run the test over
@@ -917,7 +917,7 @@ run (void *cls,
917 num_peers); 917 num_peers);
918 return; 918 return;
919 } 919 }
920 cfg = GNUNET_CONFIGURATION_dup (config); 920 cfg = config;
921 event_mask = 0; 921 event_mask = 0;
922 GNUNET_TESTBED_run (hosts_file, 922 GNUNET_TESTBED_run (hosts_file,
923 cfg, 923 cfg,
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 24f8b21b2..9f2861b50 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -66,7 +66,8 @@ block_plugin_dht_create_group (void *cls,
66 guard = va_arg (va, const char *); 66 guard = va_arg (va, const char *);
67 if (0 == strcmp (guard, 67 if (0 == strcmp (guard,
68 "seen-set-size")) 68 "seen-set-size"))
69 bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int), 69 bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va,
70 unsigned int),
70 BLOOMFILTER_K); 71 BLOOMFILTER_K);
71 else if (0 == strcmp (guard, 72 else if (0 == strcmp (guard,
72 "filter-size")) 73 "filter-size"))
@@ -183,14 +184,17 @@ block_plugin_dht_get_key (void *cls,
183 return GNUNET_SYSERR; 184 return GNUNET_SYSERR;
184 if (block_size < sizeof (struct GNUNET_MessageHeader)) 185 if (block_size < sizeof (struct GNUNET_MessageHeader))
185 { 186 {
186 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", 187 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
187 _("Block not of type %u\n"), GNUNET_BLOCK_TYPE_DHT_HELLO); 188 "block-dht",
189 _("Block not of type %u\n"),
190 GNUNET_BLOCK_TYPE_DHT_HELLO);
188 return GNUNET_NO; 191 return GNUNET_NO;
189 } 192 }
190 msg = block; 193 msg = block;
191 if (block_size != ntohs (msg->size)) 194 if (block_size != ntohs (msg->size))
192 { 195 {
193 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", 196 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
197 "block-dht",
194 _("Size mismatch for block\n"), 198 _("Size mismatch for block\n"),
195 GNUNET_BLOCK_TYPE_DHT_HELLO); 199 GNUNET_BLOCK_TYPE_DHT_HELLO);
196 return GNUNET_NO; 200 return GNUNET_NO;
@@ -200,7 +204,8 @@ block_plugin_dht_get_key (void *cls,
200 pid = (struct GNUNET_PeerIdentity *) key; 204 pid = (struct GNUNET_PeerIdentity *) key;
201 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid)) 205 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, pid))
202 { 206 {
203 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "block-dht", 207 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR,
208 "block-dht",
204 _("Block of type %u is malformed\n"), 209 _("Block of type %u is malformed\n"),
205 GNUNET_BLOCK_TYPE_DHT_HELLO); 210 GNUNET_BLOCK_TYPE_DHT_HELLO);
206 return GNUNET_NO; 211 return GNUNET_NO;
diff --git a/src/dht/test_dht_2dtorus.conf b/src/dht/test_dht_2dtorus.conf
index de138e537..a541e8443 100644
--- a/src/dht/test_dht_2dtorus.conf
+++ b/src/dht/test_dht_2dtorus.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3[PATHS] 3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_2dtorus/ 4GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_2dtorus/
5 5
diff --git a/src/dht/test_dht_api_data.conf b/src/dht/test_dht_api_data.conf
index 6f5bf8525..a2c1829c6 100644
--- a/src/dht/test_dht_api_data.conf
+++ b/src/dht/test_dht_api_data.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3 3
4[PATHS] 4[PATHS]
5GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-api/ 5GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-api/
diff --git a/src/dht/test_dht_api_peer1.conf b/src/dht/test_dht_api_peer1.conf
index b563f5096..b4164077f 100644
--- a/src/dht/test_dht_api_peer1.conf
+++ b/src/dht/test_dht_api_peer1.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3 3
4[dhtcache] 4[dhtcache]
5QUOTA = 1 MB 5QUOTA = 1 MB
diff --git a/src/dht/test_dht_line.conf b/src/dht/test_dht_line.conf
index 81ce94390..5368b0baf 100644
--- a/src/dht/test_dht_line.conf
+++ b/src/dht/test_dht_line.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3[PATHS] 3[PATHS]
4GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_line/ 4GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_line/
5 5
diff --git a/src/dht/test_dht_monitor.conf b/src/dht/test_dht_monitor.conf
index e33563746..c0d457e89 100644
--- a/src/dht/test_dht_monitor.conf
+++ b/src/dht/test_dht_monitor.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3 3
4 4
5[dhtcache] 5[dhtcache]
diff --git a/src/dht/test_dht_multipeer.conf b/src/dht/test_dht_multipeer.conf
index 5251883aa..4296d783e 100644
--- a/src/dht/test_dht_multipeer.conf
+++ b/src/dht/test_dht_multipeer.conf
@@ -1,5 +1,5 @@
1@INLINE@ ../../contrib/no_forcestart.conf 1@INLINE@ ../../contrib/conf/gnunet/no_forcestart.conf
2@INLINE@ ../../contrib/no_autostart_above_core.conf 2@INLINE@ ../../contrib/conf/gnunet/no_autostart_above_core.conf
3 3
4[dht] 4[dht]
5AUTOSTART = YES 5AUTOSTART = YES
diff --git a/src/dht/test_dht_tools.py.in b/src/dht/test_dht_tools.py.in
index 2d4ab9adc..05582cbd0 100644
--- a/src/dht/test_dht_tools.py.in
+++ b/src/dht/test_dht_tools.py.in
@@ -21,105 +21,113 @@ import subprocess
21import time 21import time
22import tempfile 22import tempfile
23 23
24os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"]; 24os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"]
25 25
26if os.name == "nt": 26if os.name == "nt":
27 tmp = os.getenv ("TEMP") 27 tmp = os.getenv("TEMP")
28else: 28else:
29 tmp = "/tmp" 29 tmp = "/tmp"
30 30
31if os.name == 'nt': 31if os.name == 'nt':
32 get = './gnunet-dht-get.exe' 32 get = './gnunet-dht-get.exe'
33 put = './gnunet-dht-put.exe' 33 put = './gnunet-dht-put.exe'
34 arm = 'gnunet-arm.exe' 34 arm = 'gnunet-arm.exe'
35else: 35else:
36 get = './gnunet-dht-get' 36 get = './gnunet-dht-get'
37 put = './gnunet-dht-put' 37 put = './gnunet-dht-put'
38 arm = 'gnunet-arm' 38 arm = 'gnunet-arm'
39 39
40cfgfile = 'test_dht_api_peer1.conf' 40cfgfile = 'test_dht_api_peer1.conf'
41
42run_get = [get, '-c', cfgfile] 41run_get = [get, '-c', cfgfile]
43run_put = [put, '-c', cfgfile] 42run_put = [put, '-c', cfgfile]
44run_arm = [arm, '-c', cfgfile] 43run_arm = [arm, '-c', cfgfile]
45debug = os.getenv ('DEBUG') 44debug = os.getenv('DEBUG')
46if debug: 45if debug:
47 run_arm += [debug.split (' ')] 46 run_arm += [debug.split(' ')]
48 47
49def cleanup (exitcode): 48
50 sys.exit (exitcode) 49def cleanup(exitcode):
51 50 sys.exit(exitcode)
52def sub_run (args, want_stdo = True, want_stde = False, nofail = False): 51
53 if want_stdo: 52
54 stdo = subprocess.PIPE 53def sub_run(args, want_stdo=True, want_stde=False, nofail=False):
55 else: 54 if want_stdo:
56 stdo = None 55 stdo = subprocess.PIPE
57 if want_stde: 56 else:
58 stde = subprocess.PIPE 57 stdo = None
59 else: 58 if want_stde:
60 stde = None 59 stde = subprocess.PIPE
61 p = subprocess.Popen (args, stdout = stdo, stderr = stde) 60 else:
62 stdo, stde = p.communicate () 61 stde = None
63 if not nofail: 62 p = subprocess.Popen(args, stdout=stdo, stderr=stde)
64 if p.returncode != 0: 63 stdo, stde = p.communicate()
65 sys.exit (p.returncode) 64 if not nofail:
66 return (p.returncode, stdo, stde) 65 if p.returncode != 0:
67 66 sys.exit(p.returncode)
68def fail (result): 67 return (p.returncode, stdo, stde)
69 print (result) 68
70 r_arm (['-e'], want_stdo = False) 69
71 cleanup (1) 70def fail(result):
72 71 print(result)
73def r_something (to_run, extra_args, failer = None, normal = True, **kw): 72 r_arm(['-e'], want_stdo=False)
74 rc, stdo, stde = sub_run (to_run + extra_args, nofail = True, **kw) 73 cleanup(1)
75 if failer is not None: 74
76 failer (to_run + extra_args, rc, stdo, stde, normal) 75
77 return (rc, stdo, stde) 76def r_something(to_run, extra_args, failer=None, normal=True, **kw):
78 77 rc, stdo, stde = sub_run(to_run + extra_args, nofail=True, **kw)
79def r_arm (extra_args, **kw): 78 if failer is not None:
80 return r_something (run_arm, extra_args, **kw) 79 failer(to_run + extra_args, rc, stdo, stde, normal)
81 80 return (rc, stdo, stde)
82def r_get (extra_args, **kw): 81
83 return r_something (run_get, extra_args, **kw) 82
84 83def r_arm(extra_args, **kw):
85def r_put (extra_args, **kw): 84 return r_something(run_arm, extra_args, **kw)
86 return r_something (run_put, extra_args, **kw) 85
87 86
88def end_arm_failer (command, rc, stdo, stde, normal): 87def r_get(extra_args, **kw):
89 if normal: 88 return r_something(run_get, extra_args, **kw)
90 if rc != 0: 89
91 fail ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) 90
92 else: 91def r_put(extra_args, **kw):
93 if rc == 0: 92 return r_something(run_put, extra_args, **kw)
94 fail ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) 93
95 94
96def print_only_failer (command, rc, stdo, stde, normal): 95def end_arm_failer(command, rc, stdo, stde, normal):
97 if normal: 96 if normal:
98 if rc != 0: 97 if rc != 0:
99 print ("FAIL: error running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) 98 fail("FAIL: error running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde))
100 cleanup (1) 99 else:
101 else: 100 if rc == 0:
102 if rc == 0: 101 fail("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde))
103 print ("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format (command, stdo, stde)) 102
104 cleanup (1) 103
105 104def print_only_failer(command, rc, stdo, stde, normal):
106 105 if normal:
107print ("TEST: Starting ARM...", end='') 106 if rc != 0:
108r_arm (['-s'], failer = end_arm_failer, want_stdo = False, want_stde = False) 107 print("FAIL: error running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde))
109print ("PASS") 108 cleanup(1)
110time.sleep (1) 109 else:
111 110 if rc == 0:
112print ("TEST: Testing put...", end='') 111 print("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde))
113r_put (['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer = end_arm_failer) 112 cleanup(1)
114print ("PASS") 113
115time.sleep (1) 114
116 115print("TEST: Starting ARM...", end='')
117print ("TEST: Testing get...", end='') 116r_arm(['-s'], failer=end_arm_failer, want_stdo=False, want_stde=False)
118rc, stdo, stde = r_get (['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo = True, failer = end_arm_failer) 117print("PASS")
119stdo = stdo.replace ('\r', '').splitlines () 118time.sleep(1)
119
120print("TEST: Testing put...", end='')
121r_put(['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer=end_arm_failer)
122print("PASS")
123time.sleep(1)
124
125print("TEST: Testing get...", end='')
126rc, stdo, stde = r_get(['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo=True, failer=end_arm_failer)
127stdo = stdo.replace('\r', '').splitlines()
120expect = "Result 0, type 8:\ntestdata".splitlines() 128expect = "Result 0, type 8:\ntestdata".splitlines()
121if len (stdo) != 2 or len (expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]: 129if len(stdo) != 2 or len(expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]:
122 fail ("output `{}' differs from expected `{}'".format (stdo, expect)) 130 fail("output `{}' differs from expected `{}'".format(stdo, expect))
123print ("PASS") 131print("PASS")
124 132
125r_arm (['-e', '-d'], failer = print_only_failer) 133r_arm(['-e', '-d'], failer=print_only_failer)