summaryrefslogtreecommitdiff
path: root/test/regress.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-01-31 18:36:37 +0000
committerNick Mathewson <nickm@torproject.org>2009-01-31 18:36:37 +0000
commit5831d11a4251eea6e63eb1bb5a63979c10600997 (patch)
treebd09ad7b116eff394e648fe3f7c4b1fd343f32f7 /test/regress.c
parentfa6ae16992c95632afea1b9c24669a48f2688f3b (diff)
downloadlibevent-5831d11a4251eea6e63eb1bb5a63979c10600997.tar.gz
Move rpc_test to regress_rpc.
svn:r1084
Diffstat (limited to 'test/regress.c')
-rw-r--r--test/regress.c176
1 files changed, 0 insertions, 176 deletions
diff --git a/test/regress.c b/test/regress.c
index 488af2ac..20ffb9b3 100644
--- a/test/regress.c
+++ b/test/regress.c
@@ -2101,180 +2101,6 @@ evtag_test(void)
}
static void
-rpc_test(void)
-{
-#ifndef WIN32
- struct msg *msg, *msg2;
- struct kill *attack;
- struct run *run;
- struct evbuffer *tmp = evbuffer_new();
- struct timeval tv_start, tv_end;
- ev_uint32_t tag;
- int i;
-
- fprintf(stdout, "Testing RPC: ");
-
- msg = msg_new();
- EVTAG_ASSIGN(msg, from_name, "niels");
- EVTAG_ASSIGN(msg, to_name, "phoenix");
-
- if (EVTAG_GET(msg, attack, &attack) == -1) {
- fprintf(stderr, "Failed to set kill message.\n");
- exit(1);
- }
-
- EVTAG_ASSIGN(attack, weapon, "feather");
- EVTAG_ASSIGN(attack, action, "tickle");
- for (i = 0; i < 3; ++i) {
- if (EVTAG_ADD(attack, how_often, i) == NULL) {
- fprintf(stderr, "Failed to add how_often.\n");
- exit(1);
- }
- }
-
- evutil_gettimeofday(&tv_start, NULL);
- for (i = 0; i < 1000; ++i) {
- run = EVTAG_ADD(msg, run);
- if (run == NULL) {
- fprintf(stderr, "Failed to add run message.\n");
- exit(1);
- }
- EVTAG_ASSIGN(run, how, "very fast but with some data in it");
- EVTAG_ASSIGN(run, fixed_bytes,
- (ev_uint8_t*)"012345678901234567890123");
-
- if (EVTAG_ADD(run, notes, "this is my note") == NULL) {
- fprintf(stderr, "Failed to add note.\n");
- exit(1);
- }
- if (EVTAG_ADD(run, notes, "pps") == NULL) {
- fprintf(stderr, "Failed to add note.\n");
- exit(1);
- }
-
- EVTAG_ASSIGN(run, large_number, 0xdead0a0bcafebeefLL);
- EVTAG_ADD(run, other_numbers, 0xdead0a0b);
- EVTAG_ADD(run, other_numbers, 0xbeefcafe);
- }
-
- if (msg_complete(msg) == -1) {
- fprintf(stderr, "Failed to make complete message.\n");
- exit(1);
- }
-
- evtag_marshal_msg(tmp, 0xdeaf, msg);
-
- if (evtag_peek(tmp, &tag) == -1) {
- fprintf(stderr, "Failed to peak tag.\n");
- exit (1);
- }
-
- if (tag != 0xdeaf) {
- fprintf(stderr, "Got incorrect tag: %0x.\n", (unsigned)tag);
- exit (1);
- }
-
- msg2 = msg_new();
- if (evtag_unmarshal_msg(tmp, 0xdeaf, msg2) == -1) {
- fprintf(stderr, "Failed to unmarshal message.\n");
- exit(1);
- }
-
- evutil_gettimeofday(&tv_end, NULL);
- evutil_timersub(&tv_end, &tv_start, &tv_end);
- fprintf(stdout, "(%.1f us/add) ",
- (float)tv_end.tv_sec/(float)i * 1000000.0 +
- tv_end.tv_usec / (float)i);
-
- if (!EVTAG_HAS(msg2, from_name) ||
- !EVTAG_HAS(msg2, to_name) ||
- !EVTAG_HAS(msg2, attack)) {
- fprintf(stderr, "Missing data structures.\n");
- exit(1);
- }
-
- if (EVTAG_GET(msg2, attack, &attack) == -1) {
- fprintf(stderr, "Could not get attack.\n");
- exit(1);
- }
-
- if (EVTAG_LEN(msg2, run) != i) {
- fprintf(stderr, "Wrong number of run messages.\n");
- exit(1);
- }
-
- /* get the very first run message */
- if (EVTAG_GET(msg2, run, 0, &run) == -1) {
- fprintf(stderr, "Failed to get run msg.\n");
- exit(1);
- } else {
- /* verify the notes */
- char *note_one, *note_two;
- ev_uint64_t large_number;
- ev_uint32_t short_number;
-
- if (EVTAG_LEN(run, notes) != 2) {
- fprintf(stderr, "Wrong number of note strings.\n");
- exit(1);
- }
-
- if (EVTAG_GET(run, notes, 0, &note_one) == -1 ||
- EVTAG_GET(run, notes, 1, &note_two) == -1) {
- fprintf(stderr, "Could not get note strings.\n");
- exit(1);
- }
-
- if (strcmp(note_one, "this is my note") ||
- strcmp(note_two, "pps")) {
- fprintf(stderr, "Incorrect note strings encoded.\n");
- exit(1);
- }
-
- if (EVTAG_GET(run, large_number, &large_number) == -1 ||
- large_number != 0xdead0a0bcafebeefLL) {
- fprintf(stderr, "Incorrrect large_number.\n");
- exit(1);
- }
-
- if (EVTAG_LEN(run, other_numbers) != 2) {
- fprintf(stderr, "Wrong number of other_numbers.\n");
- exit(1);
- }
-
- if (EVTAG_GET(run, other_numbers, 0, &short_number) == -1) {
- fprintf(stderr, "Could not get short number.\n");
- exit(1);
- }
- assert(short_number == 0xdead0a0b);
-
- }
- if (EVTAG_LEN(attack, how_often) != 3) {
- fprintf(stderr, "Wrong number of how_often ints.\n");
- exit(1);
- }
-
- for (i = 0; i < 3; ++i) {
- ev_uint32_t res;
- if (EVTAG_GET(attack, how_often, i, &res) == -1) {
- fprintf(stderr, "Cannot get %dth how_often msg.\n", i);
- exit(1);
- }
- if (res != i) {
- fprintf(stderr, "Wrong message encoded %d != %d\n", i, res);
- exit(1);
- }
- }
-
- msg_free(msg);
- msg_free(msg2);
-
- evbuffer_free(tmp);
-
- fprintf(stdout, "OK\n");
-#endif
-}
-
-static void
test_methods(void *ptr)
{
const char **methods = event_get_supported_methods();
@@ -2391,8 +2217,6 @@ legacy_main(void)
evtag_test();
- rpc_test();
-
return (0);
}