From ad415322eb8b1d9e738b500f0a3f06034af8d872 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Tue, 26 Apr 2011 00:10:02 +0200 Subject: [PATCH] not automatic yet, but at least it exits cleanly --- test/Makefile | 4 ++-- test/packets/enter_leave_context.txt | 1 - test/packets/fake_dns.txt | 1 - test/packets/invalid_dns.txt | 1 - test/packets/test-1 | 1 - test/packets/test-1-length | 1 - test/packets/test-1-length-error | 1 - test/packets/test-1-utf8 | 1 - test/packets/test-2-list | 1 - test/packets/test-2-list-error | 1 - test/packets/test-3-list | 1 - test/packets/test-4-circuit | 1 - test/packets/test-5-message-private | 1 - test/packets/test-6-message-private-remote | 1 - test/testParser.c | 20 ++++++++++++-------- 15 files changed, 14 insertions(+), 23 deletions(-) diff --git a/test/Makefile b/test/Makefile index 4de85e1..58118ee 100644 --- a/test/Makefile +++ b/test/Makefile @@ -8,8 +8,8 @@ all: $(TARGETS) ./testMatch ./isRoutingVar -test: - for f in packets/*; do echo -e "\n>> $$f"; ./testParser $$f; done +test: $(TARGETS) + for f in packets/*; do echo "\n>> $$f"; ./testParser $$f; done clean: rm -f $(TARGETS) diff --git a/test/packets/enter_leave_context.txt b/test/packets/enter_leave_context.txt index b201ad9..b17078e 100644 --- a/test/packets/enter_leave_context.txt +++ b/test/packets/enter_leave_context.txt @@ -1,4 +1,3 @@ -| :_target psyc://p5B084547.dip.t-dialin.net/@test :_source something diff --git a/test/packets/fake_dns.txt b/test/packets/fake_dns.txt index 78deab0..066e28e 100644 --- a/test/packets/fake_dns.txt +++ b/test/packets/fake_dns.txt @@ -1,4 +1,3 @@ -| :_source psyc://heise.de/~user _request_some_things diff --git a/test/packets/invalid_dns.txt b/test/packets/invalid_dns.txt index 689e8d7..18e195d 100644 --- a/test/packets/invalid_dns.txt +++ b/test/packets/invalid_dns.txt @@ -1,4 +1,3 @@ -| :_source psyc://nonexisting.dns.tld/~user _request_some_things diff --git a/test/packets/test-1 b/test/packets/test-1 index 376237c..02ea1a6 100644 --- a/test/packets/test-1 +++ b/test/packets/test-1 @@ -1,4 +1,3 @@ -| :_source psyc://foo/~bar :_target psyc://bar/~baz :_tag sch1828hu3r2cm diff --git a/test/packets/test-1-length b/test/packets/test-1-length index 2c84573..6bbd234 100644 --- a/test/packets/test-1-length +++ b/test/packets/test-1-length @@ -1,4 +1,3 @@ -| :_source psyc://foo/~bar :_target psyc://bar/~baz :_tag sch1828hu3r2cm diff --git a/test/packets/test-1-length-error b/test/packets/test-1-length-error index 98a6bf6..21c91fe 100644 --- a/test/packets/test-1-length-error +++ b/test/packets/test-1-length-error @@ -1,4 +1,3 @@ -| :_source psyc://foo/~bar :_target psyc://bar/~baz :_tag sch1828hu3r2cm diff --git a/test/packets/test-1-utf8 b/test/packets/test-1-utf8 index b054c27..e1de776 100644 --- a/test/packets/test-1-utf8 +++ b/test/packets/test-1-utf8 @@ -1,4 +1,3 @@ -| :_source psyc://foo/~bar :_target psyc://bar/~baz :_tag sch1828hu3r2cm diff --git a/test/packets/test-2-list b/test/packets/test-2-list index ebff895..02202d2 100644 --- a/test/packets/test-2-list +++ b/test/packets/test-2-list @@ -1,4 +1,3 @@ -| =_source psyc://foo/~bar :_target psyc://bar/~baz =_list_foo |foo|bar|baz diff --git a/test/packets/test-2-list-error b/test/packets/test-2-list-error index cbae3e6..b6ce6d5 100644 --- a/test/packets/test-2-list-error +++ b/test/packets/test-2-list-error @@ -1,4 +1,3 @@ -| =_source psyc://foo/~bar :_target psyc://bar/~baz =_list_foo foo|bar|baz diff --git a/test/packets/test-3-list b/test/packets/test-3-list index 4776f47..222c726 100644 --- a/test/packets/test-3-list +++ b/test/packets/test-3-list @@ -1,4 +1,3 @@ -| =_source psyc://foo/~bar :_target psyc://bar/~baz =_list_foo |foo|bar|baz diff --git a/test/packets/test-4-circuit b/test/packets/test-4-circuit index 024937f..a9d3aec 100644 --- a/test/packets/test-4-circuit +++ b/test/packets/test-4-circuit @@ -1,4 +1,3 @@ -| :_list_understand_modules _state|_fragments|_context _request_features diff --git a/test/packets/test-5-message-private b/test/packets/test-5-message-private index 6cfb1bb..4ea0f79 100644 --- a/test/packets/test-5-message-private +++ b/test/packets/test-5-message-private @@ -1,4 +1,3 @@ -| :_source psyc://nb.tgbit.net/~foo :_target psyc://nb.tgbit.net/~bar :_tag f00b4rb4z diff --git a/test/packets/test-6-message-private-remote b/test/packets/test-6-message-private-remote index 28d9641..2c2464d 100644 --- a/test/packets/test-6-message-private-remote +++ b/test/packets/test-6-message-private-remote @@ -1,4 +1,3 @@ -| :_source psyc://nb.tgbit.net/~foo :_target psyc://nb2.tgbit.net/~bar :_tag f00b4rb4z diff --git a/test/testParser.c b/test/testParser.c index d039a72..9d86126 100644 --- a/test/testParser.c +++ b/test/testParser.c @@ -17,16 +17,18 @@ int main(int argc, char** argv) return -1; indx = read(file,(void*)buffer,sizeof(buffer)); - write(1, ">> INPUT\n", 9); - write(1, buffer, indx); - write(1, ">> PARSE\n", 9); +// write(1, ">> INPUT\n", 9); +// write(1, buffer, indx); +// write(1, ">> PARSE\n", 9); psyc_initParseState(&state); psyc_nextParseBuffer(&state, psyc_newString(buffer, indx)); // try parsing that now - while ((ret = psyc_parse(&state, &oper, &name, &value))) - { +// while ((ret = psyc_parse(&state, &oper, &name, &value))) +// { + do { + ret = psyc_parse(&state, &oper, &name, &value); switch (ret) { case PSYC_PARSE_ROUTING: @@ -67,15 +69,17 @@ int main(int argc, char** argv) } break; case PSYC_PARSE_COMPLETE: - printf("Done parsing.\n"); + // printf("Done parsing.\n"); + ret = 0; continue; case PSYC_PARSE_INSUFFICIENT: printf("Insufficient data.\n"); - return 0; + return -1; default: printf("Error while parsing: %i\n", ret); return 1; } - } + } while (ret); + return 0; }