From: Jelte Jansen Date: Tue, 22 Mar 2005 13:36:18 +0000 (+0000) Subject: moved all obsolete tests to test/ X-Git-Tag: release-0.50~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=461bb0a83346d52f62496bcc67a694c2db08ce9f;p=thirdparty%2Fldns.git moved all obsolete tests to test/ --- diff --git a/Makefile.in b/Makefile.in index 3171008a..289ae26f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,11 +49,7 @@ PROG_TARGETS = $(PROG_SOURCES:.c=) LIBDNS_OBJECTS = $(LIBDNS_SOURCES:.c=.o) -TEST_SOURCES = run-test0.c run-test1.c run-test2.c run-test3.c \ - run-test4.c run-test5.c run-test6.c run-test7.c \ - run-test8.c run-test9.c run-test10.c run-test11.c \ - run-test13.c run-test14.c run-test15.c run-test16.c \ - run-test17.c run-test18.c +TEST_SOURCES = run-test7.c run-test11.c run-test18.c #ALL_SOURCES = $(TEST_SOURCES) $(LIBDNS_SOURCES) $(PROG_SOURCES) ALL_SOURCES = $(LIBDNS_SOURCES) $(PROG_SOURCES) @@ -90,42 +86,10 @@ mx: mx.o $(LIBDNS_OBJECTS) $(LIBOBJS) # tests -run-test0: run-test0.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test1: run-test1.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test2: run-test2.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test3: run-test3.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test4: run-test4.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test5: run-test5.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test6: run-test6.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ run-test7: run-test7.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ -run-test8: run-test8.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test9: run-test9.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test10: run-test10.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ run-test11: run-test11.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ -run-test12: run-test12.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) -lpcap ${LIBS} -o $@ $+ -run-test13: run-test13.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test14: run-test14.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test15: run-test15.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test16: run-test16.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ -run-test17: run-test17.o $(LIBDNS_OBJECTS) $(LIBOBJS) - $(LINK) ${LIBS} -o $@ $+ run-test18: run-test18.o $(LIBDNS_OBJECTS) $(LIBOBJS) $(LINK) ${LIBS} -o $@ $+ @@ -162,47 +126,14 @@ docclean: rm -rf doc/man/ rm -rf doc/latex/ -test0: run-test0 - ./run-test0 -test1: run-test1 - ./run-test1 -test2: run-test2 - ./run-test2 -test3: run-test3 - ./run-test3 -test4: run-test4 - ./run-test4 -test5: run-test5 - ./run-test5 -test6: run-test6 - ./run-test6 test7: run-test7 ./run-test7 -test8: run-test8 - ./run-test8 -test9: run-test9 - ./run-test9 -test10: run-test10 - ./run-test10 test11: run-test11 ./run-test11 -test12: run-test12 - ./run-test11 -test13: run-test13 - ./run-test11 -test14: run-test14 - ./run-test11 -test15: run-test15 - ./run-test15 -test16: run-test16 - ./run-test16 -test17: run-test17 - ./run-test17 test18: run-test18 ./run-test18 -test: test0 test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 \ - test13 test14 test15 test16 test17 test18 +test: test7 test11 test18 ## No need for changes here diff --git a/test/run-test-trace.c b/test/run-test-trace.c new file mode 100644 index 00000000..058c33a9 --- /dev/null +++ b/test/run-test-trace.c @@ -0,0 +1,47 @@ +/** + * An example ldns program + * + * + * Get a name + * Setup a resolver + * trace the result from the root down to the name + * Print the result along the way + */ + +#include +#include + +void +print_usage(char *file) +{ + printf("Usage: %s [initial NS]\n", file); + printf(" if [initial NS] is not given 127.0.0.1 is used\n"); + exit(0); +} + +int +main(int argc, char **argv) +{ + ldns_resolver *res; + ldns_rdf *qname; + ldns_rdf *nameserver; + ldns_pkt *pkt; + char *name; + char *init_ns; + + if (argc < 2) { + print_usage(argv[0]); + } else if (argc == 2) { + name = argv[1]; + init_ns = "127.0.0.1"; + } else { + name = argv[1]; + init_ns = argv[2]; + } + + /* init */ + res = ldns_resolver_new(); + if (!res) + return 1; + +} diff --git a/test/run-test0.c b/test/run-test0.c new file mode 100644 index 00000000..ec7f0aca --- /dev/null +++ b/test/run-test0.c @@ -0,0 +1,122 @@ +/* + * test main.c + * + */ + +#include + + +#include + +#include "util.h" + +/* + 0xc2, 0xb4, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x02, 0x03, 0x77, 0x77, 0x77, + 0x0b, 0x6b, 0x61, 0x6e, 0x61, 0x72, 0x69, 0x65, + 0x70, 0x69, 0x65, 0x74, 0x03, 0x63, 0x6f, 0x6d, + 0x00, 0x00, 0x01, 0x00, 0x01 +}; +*/ +/* +static const uint8_t wire[] = { + 0xd0, 0x0e, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, + 0x02, 0x03, 0x77, 0x77, 0x77, 0x0b, 0x6b, 0x61, 0x6e, 0x61, 0x72, + 0x69, 0x65, 0x70, 0x69, 0x65, 0x74, 0x03, 0x63, 0x6f, 0x6d, 0x00, + 0x00, 0x01, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, + 0x01, 0x45, 0xf2, 0x00, 0x04, 0xd5, 0x85, 0x27, 0xcf, 0xc0, 0x10, + 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x45, 0xf2, 0x00, 0x11, 0x03, + 0x6e, 0x73, 0x32, 0x08, 0x68, 0x65, 0x78, 0x6f, 0x6e, 0x2d, 0x69, + 0x73, 0x02, 0x6e, 0x6c, 0x00, 0xc0, 0x10, 0x00, 0x02, 0x00, 0x01, + 0x00, 0x01, 0x45, 0xf2, 0x00, 0x06, 0x03, 0x6e, 0x73, 0x31, 0xc0, + 0x45, 0xc0, 0x5e, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xfb, 0x2e, + 0x00, 0x04, 0xd5, 0x85, 0x27, 0xcb, 0xc0, 0x41, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x00, 0xfb, 0x2c, 0x00, 0x04, 0xd4, 0xcc, 0xdb, 0x5b +}; +*/ +static const uint8_t wire[] = { +0x4c, 0xf2, 0x81, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x05 +, 0x6a, 0x65, 0x6c, 0x74, 0x65, 0x09, 0x6e, +0x6c, 0x6e, 0x65, 0x74, 0x6c, 0x61, 0x62, 0x73, 0x02, 0x6e, 0x6c, 0x00, 0x00, 0x0f, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x0f, +0x00, 0x01, 0x00, 0x00, 0x02, 0x54, 0x00, 0x08, 0x00, 0x0a, 0x03, 0x73, 0x6f, 0x6c, 0xc0, 0x12, 0xc0, 0x0c, 0x00, 0x02, +0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x00, 0x06, 0x03, 0x6e, 0x73, 0x32, 0xc0, 0x0c, 0xc0, 0x0c, 0x00, 0x02, 0x00, 0x01, +0x00, 0x00, 0x00, 0x73, 0x00, 0x06, 0x03, 0x6e, 0x73, 0x31, 0xc0, 0x0c, 0xc0, 0x56, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, +0x00, 0x73, 0x00, 0x04, 0xc3, 0xa9, 0xd7, 0x9b, 0xc0, 0x44, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x00, 0x04, +0xc3, 0xa9, 0xd7, 0x9b +}; + +int +main(void) +{ + ldns_rdf *rd_f; + ldns_rr *rr; + ldns_pkt *packet; + ldns_status status; + char *rdfstr; + uint8_t *rdf_data; + + rr = ldns_rr_new(); + + rdf_data = (uint8_t *) XMALLOC(char, MAX_DOMAINLEN); + rdf_data[0] = 3; + memcpy(rdf_data+1, "www", 3); + rdf_data[4] = 4; + memcpy(rdf_data+5, "test", 4); + rdf_data[9] = 3; + memcpy(rdf_data+10, "net", 3); + rdf_data[13] = 0; + rd_f = ldns_rdf_new(LDNS_RDF_TYPE_DNAME, 20, rdf_data); + + ldns_rr_push_rdf(rr, rd_f); + status = ldns_wire2pkt(&packet, wire, sizeof(wire)); + if (status == LDNS_STATUS_OK) { + printf("packet id: %d\n", (int) ldns_pkt_id(packet)); + printf("qr bit: %d\n", (int) ldns_pkt_qr(packet)); + printf("opcode: %d\n",(int) ldns_pkt_opcode(packet)); + printf("aa bit: %d\n",(int) ldns_pkt_aa(packet)); + printf("tc bit: %d\n",(int) ldns_pkt_tc(packet)); + printf("rd bit: %d\n",(int) ldns_pkt_rd(packet)); + printf("cd bit: %d\n",(int) ldns_pkt_cd(packet)); + printf("ra bit: %d\n",(int) ldns_pkt_ra(packet)); + printf("ad bit: %d\n",(int) ldns_pkt_ad(packet)); + printf("rcode: %d\n",(int) ldns_pkt_rcode(packet)); + printf("qdcount: %d\n",(int) ldns_pkt_qdcount(packet)); + printf("ancount: %d\n",(int) ldns_pkt_ancount(packet)); + printf("nscount: %d\n",(int) ldns_pkt_nscount(packet)); + printf("arcount: %d\n",(int) ldns_pkt_arcount(packet)); + printf("pkt2str:\n"); + rdfstr = ldns_pkt2str(packet); + if (rdfstr) { + printf("%s\n", rdfstr); + } else { + printf("error\n"); + } + ldns_pkt_free(packet); + } else { + printf("error in wire2packet: %d\n", status); + } + +/* + printf("host2str:\n"); + rdfstr = ldns_rdf2str(rr->_rdata_fields[0]); + if (rdfstr) { + printf("%s\n", rdfstr); + } else { + printf("error\n"); + } + + printf("rr2str:\n"); + rdfstr = ldns_rr2str(rr); + if (rdfstr) { + printf("%s\n", rdfstr); + } else { + printf("error\n"); + } + + +*/ + + + return 0; +} + diff --git a/run-test1.c b/test/run-test1.c similarity index 100% rename from run-test1.c rename to test/run-test1.c diff --git a/run-test10.c b/test/run-test10.c similarity index 100% rename from run-test10.c rename to test/run-test10.c diff --git a/run-test12.c b/test/run-test12.c similarity index 100% rename from run-test12.c rename to test/run-test12.c diff --git a/run-test13.c b/test/run-test13.c similarity index 100% rename from run-test13.c rename to test/run-test13.c diff --git a/run-test14.c b/test/run-test14.c similarity index 100% rename from run-test14.c rename to test/run-test14.c diff --git a/run-test15.c b/test/run-test15.c similarity index 100% rename from run-test15.c rename to test/run-test15.c diff --git a/run-test16.c b/test/run-test16.c similarity index 100% rename from run-test16.c rename to test/run-test16.c diff --git a/run-test17.c b/test/run-test17.c similarity index 100% rename from run-test17.c rename to test/run-test17.c diff --git a/run-test2.c b/test/run-test2.c similarity index 100% rename from run-test2.c rename to test/run-test2.c diff --git a/run-test3.c b/test/run-test3.c similarity index 100% rename from run-test3.c rename to test/run-test3.c diff --git a/run-test4.c b/test/run-test4.c similarity index 100% rename from run-test4.c rename to test/run-test4.c diff --git a/run-test5.c b/test/run-test5.c similarity index 100% rename from run-test5.c rename to test/run-test5.c diff --git a/run-test6.c b/test/run-test6.c similarity index 100% rename from run-test6.c rename to test/run-test6.c diff --git a/run-test8.c b/test/run-test8.c similarity index 100% rename from run-test8.c rename to test/run-test8.c diff --git a/run-test9.c b/test/run-test9.c similarity index 100% rename from run-test9.c rename to test/run-test9.c