diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-30 10:28:51 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-30 10:28:51 +0200 |
commit | 30fb422df59da0e650eb790933dadbd4bb189658 (patch) | |
tree | b37f7529e275671ce3e640b4064a8945f658d442 /src/dht | |
parent | 0a0ac96d8be21130ccbb885537b0b179b16842e4 (diff) | |
parent | a46fff931d631a176f56547692b16ae32c89299b (diff) | |
download | gnunet-30fb422df59da0e650eb790933dadbd4bb189658.tar.gz gnunet-30fb422df59da0e650eb790933dadbd4bb189658.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet_dht_profiler.c | 4 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 15 | ||||
-rw-r--r-- | src/dht/test_dht_2dtorus.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_api_data.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_api_peer1.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_line.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_monitor.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_multipeer.conf | 4 | ||||
-rw-r--r-- | src/dht/test_dht_tools.py.in | 184 |
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 | */ |
48 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 48 | static 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] |
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_2dtorus/ | 4 | GNUNET_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] |
5 | GNUNET_TEST_HOME = $GNUNET_TMP/test-dht-api/ | 5 | GNUNET_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] |
5 | QUOTA = 1 MB | 5 | QUOTA = 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] |
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test_dht_line/ | 4 | GNUNET_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] |
5 | AUTOSTART = YES | 5 | AUTOSTART = 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 | |||
21 | import time | 21 | import time |
22 | import tempfile | 22 | import tempfile |
23 | 23 | ||
24 | os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"]; | 24 | os.environ["PATH"] = "@bindir@" + ":" + os.environ["PATH"] |
25 | 25 | ||
26 | if os.name == "nt": | 26 | if os.name == "nt": |
27 | tmp = os.getenv ("TEMP") | 27 | tmp = os.getenv("TEMP") |
28 | else: | 28 | else: |
29 | tmp = "/tmp" | 29 | tmp = "/tmp" |
30 | 30 | ||
31 | if os.name == 'nt': | 31 | if 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' |
35 | else: | 35 | else: |
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 | ||
40 | cfgfile = 'test_dht_api_peer1.conf' | 40 | cfgfile = 'test_dht_api_peer1.conf' |
41 | |||
42 | run_get = [get, '-c', cfgfile] | 41 | run_get = [get, '-c', cfgfile] |
43 | run_put = [put, '-c', cfgfile] | 42 | run_put = [put, '-c', cfgfile] |
44 | run_arm = [arm, '-c', cfgfile] | 43 | run_arm = [arm, '-c', cfgfile] |
45 | debug = os.getenv ('DEBUG') | 44 | debug = os.getenv('DEBUG') |
46 | if debug: | 45 | if debug: |
47 | run_arm += [debug.split (' ')] | 46 | run_arm += [debug.split(' ')] |
48 | 47 | ||
49 | def cleanup (exitcode): | 48 | |
50 | sys.exit (exitcode) | 49 | def cleanup(exitcode): |
51 | 50 | sys.exit(exitcode) | |
52 | def sub_run (args, want_stdo = True, want_stde = False, nofail = False): | 51 | |
53 | if want_stdo: | 52 | |
54 | stdo = subprocess.PIPE | 53 | def 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) | |
68 | def fail (result): | 67 | return (p.returncode, stdo, stde) |
69 | print (result) | 68 | |
70 | r_arm (['-e'], want_stdo = False) | 69 | |
71 | cleanup (1) | 70 | def fail(result): |
72 | 71 | print(result) | |
73 | def 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) | 76 | def 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) | |
79 | def 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) | |
82 | def r_get (extra_args, **kw): | 81 | |
83 | return r_something (run_get, extra_args, **kw) | 82 | |
84 | 83 | def r_arm(extra_args, **kw): | |
85 | def 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 | ||
88 | def end_arm_failer (command, rc, stdo, stde, normal): | 87 | def 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: | 91 | def 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 | ||
96 | def print_only_failer (command, rc, stdo, stde, normal): | 95 | def 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 | 104 | def print_only_failer(command, rc, stdo, stde, normal): | |
106 | 105 | if normal: | |
107 | print ("TEST: Starting ARM...", end='') | 106 | if rc != 0: |
108 | r_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)) |
109 | print ("PASS") | 108 | cleanup(1) |
110 | time.sleep (1) | 109 | else: |
111 | 110 | if rc == 0: | |
112 | print ("TEST: Testing put...", end='') | 111 | print("FAIL: expected error while running {}\nCommand output was:\n{}\n{}".format(command, stdo, stde)) |
113 | r_put (['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer = end_arm_failer) | 112 | cleanup(1) |
114 | print ("PASS") | 113 | |
115 | time.sleep (1) | 114 | |
116 | 115 | print("TEST: Starting ARM...", end='') | |
117 | print ("TEST: Testing get...", end='') | 116 | r_arm(['-s'], failer=end_arm_failer, want_stdo=False, want_stde=False) |
118 | rc, stdo, stde = r_get (['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo = True, failer = end_arm_failer) | 117 | print("PASS") |
119 | stdo = stdo.replace ('\r', '').splitlines () | 118 | time.sleep(1) |
119 | |||
120 | print("TEST: Testing put...", end='') | ||
121 | r_put(['-k', 'testkey', '-d', 'testdata', '-t', '8'], failer=end_arm_failer) | ||
122 | print("PASS") | ||
123 | time.sleep(1) | ||
124 | |||
125 | print("TEST: Testing get...", end='') | ||
126 | rc, stdo, stde = r_get(['-k', 'testkey', '-T', '50 ms', '-t', '8'], want_stdo=True, failer=end_arm_failer) | ||
127 | stdo = stdo.replace('\r', '').splitlines() | ||
120 | expect = "Result 0, type 8:\ntestdata".splitlines() | 128 | expect = "Result 0, type 8:\ntestdata".splitlines() |
121 | if len (stdo) != 2 or len (expect) != 2 or stdo[0] != expect[0] or stdo[1] != expect[1]: | 129 | if 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)) |
123 | print ("PASS") | 131 | print("PASS") |
124 | 132 | ||
125 | r_arm (['-e', '-d'], failer = print_only_failer) | 133 | r_arm(['-e', '-d'], failer=print_only_failer) |