From: Adam Dickmeiss Date: Tue, 11 Mar 2003 11:06:35 +0000 (+0000) Subject: New tool for ODR testing. X-Git-Tag: YAZ.2.0.1~45 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=adcb574176dc52cce8ee299507da91228e2afc1b;hp=30de094a4a567f7fada6d5932e23921770ac671c New tool for ODR testing. --- diff --git a/client/bertorture.c b/client/bertorture.c new file mode 100644 index 0000000..a9a80d2 --- /dev/null +++ b/client/bertorture.c @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2003, Index Data + * See the file LICENSE for details. + * + * $Id: bertorture.c,v 1.1 2003-03-11 11:06:35 adam Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define PACKET_SIZE 64 + +static int stop = 0; + +static int send_packet(const char *host) +{ + char buf[PACKET_SIZE]; + int i; + + void *add; + + COMSTACK cs = cs_create_host(host, 1, &add); + + if (!cs) + return -1; + + if (cs_connect(cs, add) < 0) + return -1; + + for (i = 0; i 0) + { + ssize_t wrote; + wrote = write(fd, buf+off+j, sizeof(buf)-j-off); + if (wrote <= 0) { + yaz_log(LOG_ERRNO|LOG_FATAL, "write %s", fname); + exit (1); + } + off += wrote; + } + if (close(fd) == -1) + { + yaz_log(LOG_ERRNO|LOG_FATAL, "close %s", fname); + exit (1); + } + } + mbuf = malloc(sizeof(buf)-j); + memcpy(mbuf, buf+j, sizeof(buf)-j); + odr_setbuf(odr, mbuf, sizeof(buf)-j, 0); + if (z_GDU(odr, &req, 0, 0)) + estat[99]++; + else + { + int ex; + odr_geterrorx(odr, &ex); + estat[ex]++; + } + if (dumpfile) + odr_dumpBER(dumpfile, buf+j, sizeof(buf)-j); + free(mbuf); + odr_reset(odr); + odr_destroy(odr); + nmem_exit(); + } + if (dumpfile && dumpfile != stdout) + fclose(dumpfile); +} + +void sigint_handler(int x) +{ + stop = 1; +} + +int main(int argc, char **argv) +{ + int start = 0, end = 10000000, ret, i, estat[100]; + char *arg; + char *ber_fname = 0; + char *packet_fname = 0; + + signal(SIGINT, sigint_handler); + signal(SIGTERM, sigint_handler); + for (i = 0; i