diff options
author | Julius Bünger <buenger@mytum.de> | 2015-07-23 18:23:39 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-07-23 18:23:39 +0000 |
commit | 7dbd265deef8168ebffe6b8ee15c34533f702bfc (patch) | |
tree | 8ceee0887f3f98df09cb2aacad86b98f34411778 /src/rps/test_rps.c | |
parent | e8402a125af3aa4d9451654f09d4a57bd58ec3d2 (diff) | |
download | gnunet-7dbd265deef8168ebffe6b8ee15c34533f702bfc.tar.gz gnunet-7dbd265deef8168ebffe6b8ee15c34533f702bfc.zip |
get indices for evaluation with diehard
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r-- | src/rps/test_rps.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 9e78148a1..a430f4a83 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -159,6 +159,11 @@ struct RPSPeer | |||
159 | static struct RPSPeer *rps_peers; | 159 | static struct RPSPeer *rps_peers; |
160 | 160 | ||
161 | /** | 161 | /** |
162 | * Peermap to get the index of a given peer ID quick. | ||
163 | */ | ||
164 | static struct GNUNET_CONTAINER_MultiPeerMap *peer_map; | ||
165 | |||
166 | /** | ||
162 | * IDs of the peers. | 167 | * IDs of the peers. |
163 | */ | 168 | */ |
164 | static struct GNUNET_PeerIdentity *rps_peer_ids; | 169 | static struct GNUNET_PeerIdentity *rps_peer_ids; |
@@ -326,6 +331,7 @@ tofile_ (const char *file_name, char *line) | |||
326 | tofile_(file_name,tmp_buf);\ | 331 | tofile_(file_name,tmp_buf);\ |
327 | } while (0); | 332 | } while (0); |
328 | 333 | ||
334 | |||
329 | /** | 335 | /** |
330 | * Write the ids and their according index in the given array to a file | 336 | * Write the ids and their according index in the given array to a file |
331 | * Unused | 337 | * Unused |
@@ -529,6 +535,11 @@ info_cb (void *cb_cls, | |||
529 | rps_peers[entry->index].rec_ids = NULL; | 535 | rps_peers[entry->index].rec_ids = NULL; |
530 | rps_peers[entry->index].num_rec_ids = 0; | 536 | rps_peers[entry->index].num_rec_ids = 0; |
531 | 537 | ||
538 | GNUNET_CONTAINER_multipeermap_put (peer_map, | ||
539 | &rps_peer_ids[entry->index], | ||
540 | &rps_peers[entry->index], | ||
541 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | ||
542 | |||
532 | tofile ("/tmp/rps/peer_ids", | 543 | tofile ("/tmp/rps/peer_ids", |
533 | "%u\t%s\n", | 544 | "%u\t%s\n", |
534 | entry->index, | 545 | entry->index, |
@@ -962,10 +973,13 @@ profiler_reply_handle (void *cls, | |||
962 | const struct GNUNET_PeerIdentity *recv_peers) | 973 | const struct GNUNET_PeerIdentity *recv_peers) |
963 | { | 974 | { |
964 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | 975 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; |
976 | struct RPSPeer *rcv_rps_peer; | ||
965 | char *file_name; | 977 | char *file_name; |
978 | char *file_name_dh; | ||
966 | unsigned int i; | 979 | unsigned int i; |
967 | 980 | ||
968 | file_name = "/tmp/rps/received_ids"; | 981 | file_name = "/tmp/rps/received_ids"; |
982 | file_name_dh = "/tmp/rps/diehard_input"; | ||
969 | 983 | ||
970 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 984 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
971 | "[%s] got %" PRIu64 " peers:\n", | 985 | "[%s] got %" PRIu64 " peers:\n", |
@@ -983,6 +997,12 @@ profiler_reply_handle (void *cls, | |||
983 | tofile (file_name, | 997 | tofile (file_name, |
984 | "%s\n", | 998 | "%s\n", |
985 | GNUNET_i2s_full (&recv_peers[i])); | 999 | GNUNET_i2s_full (&recv_peers[i])); |
1000 | |||
1001 | rcv_rps_peer = GNUNET_CONTAINER_multipeermap_get (peer_map, &recv_peers[i]); | ||
1002 | |||
1003 | tofile (file_name_dh, | ||
1004 | "%" PRIu32 "\n", | ||
1005 | (uint32_t) rcv_rps_peer->index); | ||
986 | } | 1006 | } |
987 | } | 1007 | } |
988 | 1008 | ||
@@ -1153,6 +1173,8 @@ run (void *cls, | |||
1153 | int | 1173 | int |
1154 | main (int argc, char *argv[]) | 1174 | main (int argc, char *argv[]) |
1155 | { | 1175 | { |
1176 | int ret_value; | ||
1177 | |||
1156 | cur_test_run.name = "test-rps-default"; | 1178 | cur_test_run.name = "test-rps-default"; |
1157 | cur_test_run.pre_test = NULL; | 1179 | cur_test_run.pre_test = NULL; |
1158 | cur_test_run.reply_handle = default_reply_handle; | 1180 | cur_test_run.reply_handle = default_reply_handle; |
@@ -1259,6 +1281,7 @@ main (int argc, char *argv[]) | |||
1259 | 1281 | ||
1260 | rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); | 1282 | rps_peers = GNUNET_new_array (num_peers, struct RPSPeer); |
1261 | rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); | 1283 | rps_peer_ids = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); |
1284 | peer_map = GNUNET_CONTAINER_multipeermap_create (num_peers, GNUNET_NO); | ||
1262 | 1285 | ||
1263 | ok = 1; | 1286 | ok = 1; |
1264 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, | 1287 | (void) GNUNET_TESTBED_test_run (cur_test_run.name, |
@@ -1267,7 +1290,13 @@ main (int argc, char *argv[]) | |||
1267 | 0, NULL, NULL, | 1290 | 0, NULL, NULL, |
1268 | &run, NULL); | 1291 | &run, NULL); |
1269 | 1292 | ||
1270 | return cur_test_run.eval_cb(); | 1293 | ret_value = cur_test_run.eval_cb(); |
1294 | |||
1295 | GNUNET_free (rps_peers ); | ||
1296 | GNUNET_free (rps_peer_ids); | ||
1297 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | ||
1298 | |||
1299 | return ret_value; | ||
1271 | } | 1300 | } |
1272 | 1301 | ||
1273 | /* end of test_rps_multipeer.c */ | 1302 | /* end of test_rps_multipeer.c */ |