1
0
Fork 0
mirror of git://git.psyc.eu/libpsyc synced 2024-08-15 03:19:02 +00:00
libpsyc/test/test.h

81 lines
3.1 KiB
C
Raw Normal View History

2013-07-16 14:53:51 +00:00
/*
This file is part of libpsyc.
Copyright (C) 2011,2012 Carlo v. Loesch, Gabor X Toth, Mathias L. Baumann,
and other contributing authors.
libpsyc is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version. As a special exception, libpsyc is distributed with additional
permissions to link libpsyc libraries with non-AGPL works.
libpsyc is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
You should have received a copy of the GNU Affero General Public License and
the linking exception along with libpsyc in a COPYING file.
*/
#ifndef TEST_H
# define TEST_H
2011-05-16 18:13:10 +00:00
#ifndef RECV_BUF_SIZE
# define RECV_BUF_SIZE 8 * 1024
2011-05-16 18:13:10 +00:00
#endif
#ifndef CONT_BUF_SIZE
# define CONT_BUF_SIZE 8 * 1024
2011-05-16 18:13:10 +00:00
#endif
#ifndef SEND_BUF_SIZE
# define SEND_BUF_SIZE 8 * 1024
2011-05-16 18:13:10 +00:00
#endif
#ifndef NUM_PARSERS
# define NUM_PARSERS 100
2011-05-16 18:13:10 +00:00
#endif
#define CASE_f case 'f': filename = optarg; break;
#define CASE_p case 'p': port = optarg; check_range(c, optarg, 1, 0); break;
#define CASE_b case 'b': recv_buf_size = atoi(optarg); check_range(c, optarg, 1, 0); break;
#define CASE_c case 'c': count = atoi(optarg); check_range(c, optarg, 1, 0); break;
#define CASE_n case 'n': no_render = 1; break;
#define CASE_m case 'm': multiple = 1; break;
#define CASE_q case 'q': quiet = 1; break;
#define CASE_r case 'r': routing_only = 1; break;
#define CASE_s case 's': stats = 1; break;
#define CASE_v case 'v': verbose++; break;
#define CASE_P case 'P': progress = 1; break;
#define CASE_S case 'S': single = 1; break;
#define HELP_FILE(name, opts) name " -f <filename> [-b <read_buf_size>] [-c <count>] [-" opts "]\n"
#define HELP_PORT(name, opts) name " [-p <port>] [-b <recv_buf_size>] [-" opts "]\n"
#define HELP_f " -f <filename>\tInput file name\n"
#define HELP_p " -p <port>\t\tListen on TCP port, default is %s\n"
#define HELP_b " -b <buf_size>\tRead/receive buffer size, default is %d\n"
#define HELP_c " -c <count>\t\tParse data from file <count> times\n"
#define HELP_m " -m\t\t\tParse multiple packets from file\n"
#define HELP_n " -n\t\t\tNo rendering, only parsing\n"
#define HELP_q " -q\t\t\tQuiet mode, don't output rendered string\n"
#define HELP_r " -r\t\t\tParse routing header only\n"
#define HELP_S " -S\t\t\tSingle packet mode, close connection after parsing one packet\n"
#define HELP_s " -s\t\t\tShow statistics at the end\n"
#define HELP_v " -v\t\t\tVerbose, can be specified multiple times for more verbosity\n"
#define HELP_P " -P\t\t\tShow progress\n"
#define HELP_h " -h\t\t\tShow this help\n"
2011-11-11 21:18:24 +00:00
void
test_init (int i);
2011-11-11 21:18:24 +00:00
int
test_input (int i, char *recvbuf, size_t nbytes);
void
test_file (const char* filename, size_t count, size_t recv_buf_size);
void
test_server (const char* port, size_t count, size_t recv_buf_size);
void
check_range (char c, const char *s, int min, int max);
#endif