multiple executables.
images/Makefile
lib/Makefile
lib/definitions.h
-lib/test
plugins/Makefile
python/Makefile
python/disorder.py
sounds/long.ogg
sounds/slap.raw
server/disorder-choose
+lib/t-addr
+lib/t-basen
+lib/t-bits
+lib/t-cache
+lib/t-casefold
+lib/t-cookies
+lib/t-filepart
+lib/t-hash
+lib/t-heap
+lib/t-hex
+lib/t-kvp
+lib/t-mime
+lib/t-printf
+lib/t-regsub
+lib/t-selection
+lib/t-signame
+lib/t-sink
+lib/t-split
+lib/t-syscalls
+lib/t-trackname
+lib/t-unicode
+lib/t-url
+lib/t-utf8
+lib/t-vector
+lib/t-words
+lib/t-wstat
# USA
#
+TESTS=t-addr t-basen t-bits t-cache t-casefold t-cookies \
+ t-filepart t-hash t-heap t-hex t-kvp t-mime t-printf \
+ t-regsub t-selection t-signame t-sink t-split t-syscalls \
+ t-trackname t-unicode t-url t-utf8 t-vector t-words t-wstat
+
noinst_LIBRARIES=libdisorder.a
include_HEADERS=disorder.h
-noinst_PROGRAMS=test
+noinst_PROGRAMS=$(TESTS)
if SERVER
TRACKDB=trackdb.c
defs.o: definitions.h versionstring.h
defs.lo: definitions.h versionstring.h
-test_SOURCES=test.c memgc.c test.h t-addr.c t-basen.c t-cache.c \
- t-casefold.c t-cookies.c t-filepart.c t-hash.c t-heap.c \
- t-hex.c t-kvp.c t-mime.c t-printf.c t-regsub.c t-selection.c \
- t-signame.c t-sink.c t-split.c t-unicode.c t-url.c t-utf8.c \
- t-words.c t-wstat.c t-bits.c t-vector.c t-syscalls.c \
- t-trackname.c
-test_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
-test_DEPENDENCIES=libdisorder.a
-
-check: test #test.i
- ./test
+t_addr_SOURCES=t-addr.c test.c test.h
+t_addr_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_addr_DEPENDENCIES=libdisorder.a
+
+t_basen_SOURCES=t-basen.c test.c test.h
+t_basen_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_basen_DEPENDENCIES=libdisorder.a
+
+t_bits_SOURCES=t-bits.c test.c test.h
+t_bits_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_bits_DEPENDENCIES=libdisorder.a
+
+t_cache_SOURCES=t-cache.c test.c test.h
+t_cache_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_cache_DEPENDENCIES=libdisorder.a
+
+t_casefold_SOURCES=t-casefold.c test.c test.h
+t_casefold_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_casefold_DEPENDENCIES=libdisorder.a
+
+t_cookies_SOURCES=t-cookies.c test.c test.h
+t_cookies_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_cookies_DEPENDENCIES=libdisorder.a
+
+t_filepart_SOURCES=t-filepart.c test.c test.h
+t_filepart_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_filepart_DEPENDENCIES=libdisorder.a
+
+t_hash_SOURCES=t-hash.c test.c test.h
+t_hash_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_hash_DEPENDENCIES=libdisorder.a
+
+t_heap_SOURCES=t-heap.c test.c test.h
+t_heap_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_heap_DEPENDENCIES=libdisorder.a
+
+t_hex_SOURCES=t-hex.c test.c test.h
+t_hex_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_hex_DEPENDENCIES=libdisorder.a
+
+t_kvp_SOURCES=t-kvp.c test.c test.h
+t_kvp_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_kvp_DEPENDENCIES=libdisorder.a
+
+t_mime_SOURCES=t-mime.c test.c test.h
+t_mime_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_mime_DEPENDENCIES=libdisorder.a
+
+t_printf_SOURCES=t-printf.c test.c test.h
+t_printf_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_printf_DEPENDENCIES=libdisorder.a
+
+t_regsub_SOURCES=t-regsub.c test.c test.h
+t_regsub_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_regsub_DEPENDENCIES=libdisorder.a
+
+t_selection_SOURCES=t-selection.c test.c test.h
+t_selection_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_selection_DEPENDENCIES=libdisorder.a
+
+t_signame_SOURCES=t-signame.c test.c test.h
+t_signame_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_signame_DEPENDENCIES=libdisorder.a
+
+t_sink_SOURCES=t-sink.c test.c test.h
+t_sink_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_sink_DEPENDENCIES=libdisorder.a
+
+t_split_SOURCES=t-split.c test.c test.h
+t_split_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_split_DEPENDENCIES=libdisorder.a
+
+t_syscalls_SOURCES=t-syscalls.c test.c test.h
+t_syscalls_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_syscalls_DEPENDENCIES=libdisorder.a
+
+t_trackname_SOURCES=t-trackname.c test.c test.h
+t_trackname_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_trackname_DEPENDENCIES=libdisorder.a
+
+t_unicode_SOURCES=t-unicode.c test.c test.h
+t_unicode_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_unicode_DEPENDENCIES=libdisorder.a
+
+t_url_SOURCES=t-url.c test.c test.h
+t_url_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_url_DEPENDENCIES=libdisorder.a
+
+t_utf8_SOURCES=t-utf8.c test.c test.h
+t_utf8_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_utf8_DEPENDENCIES=libdisorder.a
+
+t_vector_SOURCES=t-vector.c test.c test.h
+t_vector_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_vector_DEPENDENCIES=libdisorder.a
+
+t_words_SOURCES=t-words.c test.c test.h
+t_words_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_words_DEPENDENCIES=libdisorder.a
+
+t_wstat_SOURCES=t-wstat.c test.c test.h
+t_wstat_LDADD=libdisorder.a $(LIBPCRE) $(LIBICONV) $(LIBGC)
+t_wstat_DEPENDENCIES=libdisorder.a
+
+
+#check: test #test.i
+# ./test
check-report: before-check check make-coverage-reports
before-check:
*/
#include "test.h"
-void test_addr(void) {
+static void test_addr(void) {
struct stringlist a;
const char *s[3];
struct addrinfo *ai;
.ai_addr = (struct sockaddr *)&a2,
};
- printf("test_addr\n");
-
insist(addrinfocmp(&p1, &p2) < 0);
a.n = 1;
check_integer(multicast((struct sockaddr *)&su), 0);
}
+TEST(addr);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_basen(void) {
+static void test_basen(void) {
unsigned long v[64];
char buffer[1024];
- fprintf(stderr, "test_basen\n");
v[0] = 999;
insist(basen(v, 1, buffer, sizeof buffer, 10) == 0);
check_string(buffer, "999");
insist(basen(v, 4, buffer, 10, 16) == -1);
}
+TEST(basen);
+
/*
Local Variables:
c-basic-offset:2
#include "test.h"
#include "bits.h"
-void test_bits(void) {
+static void test_bits(void) {
int n;
- printf("test_bits\n");
check_integer(leftmost_bit(0), -1);
check_integer(leftmost_bit(0x80000000), 31);
check_integer(leftmost_bit(0xffffffff), 31);
}
}
+TEST(bits);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_cache(void) {
+static void test_cache(void) {
const struct cache_type t1 = { 1 }, t2 = { 10 };
const char v11[] = "spong", v12[] = "wibble", v2[] = "blat";
- fprintf(stderr, "test_cache\n");
+
cache_put(&t1, "1_1", v11);
cache_put(&t1, "1_2", v12);
cache_put(&t2, "2", v2);
insist(cache_get(&t2, "2") == 0);
}
+TEST(cache);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_casefold(void) {
+static void test_casefold(void) {
uint32_t c, l;
const char *input, *canon_folded, *compat_folded, *canon_expected, *compat_expected;
- fprintf(stderr, "test_casefold\n");
-
/* This isn't a very exhaustive test. Unlike for normalization, there don't
* seem to be any public test vectors for these algorithms. */
check_string(utf8_casefold_canon("", 0, 0), "");
}
+TEST(casefold);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_cookies(void) {
+static void test_cookies(void) {
struct cookiedata cd[1];
- fprintf(stderr, "test_cookies\n");
-
/* These are the examples from RFC2109 */
insist(!parse_cookie("$Version=\"1\"; Customer=\"WILE_E_COYOTE\"; $Path=\"/acme\"", cd));
insist(!strcmp(cd->version, "1"));
insist(cd->cookies[0].domain == 0);
}
+TEST(cookies);
+
/*
Local Variables:
c-basic-offset:2
+
/*
* This file is part of DisOrder.
* Copyright (C) 2005, 2007, 2008 Richard Kettlewell
*/
#include "test.h"
-void test_filepart(void) {
- fprintf(stderr, "test_filepart\n");
+static void test_filepart(void) {
check_string(d_dirname("/"), "/");
check_string(d_dirname("////"), "/");
check_string(d_dirname("/spong"), "/");
check_string(strip_extension("foo.bar/wibble.spong"), "foo.bar/wibble");
}
+TEST(filepart);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_hash(void) {
+static void test_hash(void) {
hash *h;
int i, *ip;
char **keys;
- fprintf(stderr, "test_hash\n");
h = hash_new(sizeof(int));
for(i = 0; i < 10000; ++i)
insist(hash_add(h, do_printf("%d", i), &i, HASH_INSERT) == 0);
check_integer(hash_count(h), 0);
}
+TEST(hash);
+
/*
Local Variables:
c-basic-offset:2
HEAP_DEFINE(iheap, int, int_lt);
/** @brief Tests for @ref heap.h */
-void test_heap(void) {
+static void test_heap(void) {
struct iheap h[1];
int n;
int last = -1;
- fprintf(stderr, "test_heap\n");
-
iheap_init(h);
for(n = 0; n < 1000; ++n)
iheap_insert(h, random() % 100);
insist(last <= latest);
last = latest;
}
- putchar('\n');
}
+TEST(heap);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_hex(void) {
+static void test_hex(void) {
unsigned n;
static const unsigned char h[] = { 0x00, 0xFF, 0x80, 0x7F };
uint8_t *u;
size_t ul;
- fprintf(stderr, "test_hex\n");
-
for(n = 0; n <= UCHAR_MAX; ++n) {
if(!isxdigit(n))
insist(unhexdigitq(n) == -1);
fprintf(stderr, "}\n");
}
+TEST(hex);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_kvp(void) {
+static void test_kvp(void) {
struct kvp *k;
size_t n;
- fprintf(stderr, "test_kvp\n");
/* decoding */
#define KVP_URLDECODE(S) kvp_urldecode((S), strlen(S))
+ fprintf(stderr, "5 ERROR reports expected {\n");
insist(KVP_URLDECODE("=%zz") == 0);
insist(KVP_URLDECODE("=%0") == 0);
insist(KVP_URLDECODE("=%0z") == 0);
insist(KVP_URLDECODE("=%%") == 0);
insist(KVP_URLDECODE("==%") == 0);
+ fprintf(stderr, "}\n");
insist(KVP_URLDECODE("wibble") == 0);
insist(KVP_URLDECODE("") == 0);
insist(KVP_URLDECODE("wibble&") == 0);
"abc%25%20%2b%0a");
}
+TEST(kvp);
+
/*
Local Variables:
c-basic-offset:2
return 0;
}
-void test_mime(void) {
+static void test_mime(void) {
char *t, *n, *v;
struct vector parts[1];
struct kvp *k;
const char *s, *cs, *enc;
hash *h;
- fprintf(stderr, "test_mime\n");
-
t = 0;
k = 0;
insist(!mime_content_type("text/plain", &t, &k));
check_string(enc, "quoted-printable");
}
+TEST(mime);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_printf(void) {
+static void test_printf(void) {
char c;
short s;
int i;
char buffer[16];
FILE *fp;
- fprintf(stderr, "test_printf\n");
check_string(do_printf("%d", 999), "999");
check_string(do_printf("%d", -999), "-999");
check_string(do_printf("%i", 999), "999");
fclose(fp);
}
+TEST(printf);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_regsub(void) {
+static void test_regsub(void) {
pcre *re;
const char *errstr;
int erroffset;
- printf("test_regsub\n");
-
check_integer(regsub_flags(""), 0);
check_integer(regsub_flags("g"), REGSUB_GLOBAL);
check_integer(regsub_flags("i"), REGSUB_CASE_INDEPENDENT);
"foo-x:bBb$aAaA:y-bar");
}
+TEST(regsub);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_selection(void) {
+static void test_selection(void) {
hash *h;
- fprintf(stderr, "test_selection\n");
+
insist((h = selection_new()) != 0);
selection_set(h, "one", 1);
selection_set(h, "two", 1);
insist(hash_count(h) == 0);
}
+TEST(selection);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_signame(void) {
- fprintf(stderr, "test_signame\n");
+static void test_signame(void) {
insist(find_signal("SIGTERM") == SIGTERM);
insist(find_signal("SIGHUP") == SIGHUP);
insist(find_signal("SIGINT") == SIGINT);
insist(find_signal("SIGYOURMUM") == -1);
}
+TEST(signame);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_sink(void) {
+static void test_sink(void) {
struct sink *s;
struct dynstr d[1];
FILE *fp;
char *l;
-
- fprintf(stderr, "test_sink\n");
fp = tmpfile();
assert(fp != 0);
check_string(d->vec, "test: 999\nwibble: foobar\n");
}
+TEST(sink);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_split(void) {
+static void test_split(void) {
char **v;
int nv;
- fprintf(stderr, "test_split\n");
insist(split("\"misquoted", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
insist(split("\'misquoted", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
insist(split("\'misquoted\\", &nv, SPLIT_COMMENTS|SPLIT_QUOTES, 0, 0) == 0);
check_string(quoteutf8("wibble'wobble"), "\"wibble'wobble\"");
}
+TEST(split);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_syscalls(void) {
+static void test_syscalls(void) {
int p[2];
char buf[128], *e;
long n;
long long nn;
-
- printf("test_syscalls\n");
xpipe(p);
nonblock(p[1]);
#endif
}
+TEST(syscalls);
+
/*
Local Variables:
c-basic-offset:2
a, (sizeof a) - 1) == -(EXPECTED)); \
} while(0)
-void test_trackname(void) {
- printf("test_trackname\n");
+static void test_trackname(void) {
CHECK_PATH_ORDER("/a/b", "/aa/", -1);
CHECK_PATH_ORDER("/a/b", "/a", 1);
CHECK_PATH_ORDER("/ab", "/a", 1);
CHECK_PATH_ORDER("/", "/", 0);
}
+TEST(trackname);
+
/*
Local Variables:
c-basic-offset:2
}
/** @brief Tests for @ref lib/unicode.h */
-void test_unicode(void) {
+static void test_unicode(void) {
FILE *fp;
int lineno = 0;
char *l, *lp;
uint32_t *c[6], *NFD_c[6], *NFKD_c[6], *NFC_c[6], *NFKC_c[6]; /* 1-indexed */
int cn, bn;
- fprintf(stderr, "test_unicode\n");
fp = open_unicode_test("NormalizationTest.txt");
while(!inputline("NormalizationTest.txt", fp, &l, '\n')) {
++lineno;
insist(utf32_combining_class(0xE0000) == 0);
}
+TEST(unicode);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_url(void) {
+static void test_url(void) {
struct url p;
-
- printf("test_url\n");
insist(parse_url("http://www.example.com/example/path", &p) == 0);
check_string(p.scheme, "http");
insist(parse_url("http://www.example.com/example%2zpath", &p) == -1);
}
+TEST(url);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_utf8(void) {
+static void test_utf8(void) {
/* Test validutf8, convert to UCS-4, check the answer is right,
* convert back to UTF-8, check we got to where we started */
#define U8(CHARS, WORDS) do { \
check_string(u8, CHARS); \
} while(0)
- fprintf(stderr, "test_utf8\n");
#define validutf8(S) utf8_valid((S), strlen(S))
/* empty string */
insist(!validutf8("\xF8"));
}
+TEST(utf8);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_vector(void) {
+static void test_vector(void) {
struct vector v[1];
static const char *s[10] = { "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve" };
int n;
- printf("test_vector\n");
vector_init(v);
insist(v->nvec == 0);
insist(v->vec[12] == 0);
}
+TEST(vector);
/*
Local Variables:
};
#define NWTEST (sizeof wtest / sizeof *wtest)
-void test_words(void) {
+static void test_words(void) {
size_t t, nexpect, ngot, i;
int right;
- fprintf(stderr, "test_words\n");
for(t = 0; t < NWTEST; ++t) {
char **got = utf8_word_split(wtest[t].in, strlen(wtest[t].in), &ngot, 0);
}
}
+TEST(words);
+
/*
Local Variables:
c-basic-offset:2
*/
#include "test.h"
-void test_wstat(void) {
+static void test_wstat(void) {
pid_t pid;
int w;
- fprintf(stderr, "test_wstat\n");
if(!(pid = xfork())) {
_exit(1);
}
check_string_prefix(wstat(w), "terminated by signal 15");
}
+TEST(wstat);
+
/*
Local Variables:
c-basic-offset:2
return s;
}
-int main(void) {
- mem_init();
- fail_first = !!getenv("FAIL_FIRST");
- insist('\n' == 0x0A);
- insist('\r' == 0x0D);
- insist(' ' == 0x20);
- insist('0' == 0x30);
- insist('9' == 0x39);
- insist('A' == 0x41);
- insist('Z' == 0x5A);
- insist('a' == 0x61);
- insist('z' == 0x7A);
- /* addr.c */
- test_addr();
- /* asprintf.c */
- /* authhash.c */
- /* basen.c */
- test_basen();
- /* charset.c */
- /* client.c */
- /* configuration.c */
- /* event.c */
- /* filepart.c */
- test_filepart();
- /* fprintf.c */
- /* heap.c */
- test_heap();
- /* hex.c */
- test_hex();
- /* inputline.c */
- /* kvp.c */
- test_kvp();
- /* log.c */
- /* mem.c */
- /* mime.c */
- test_mime();
- test_cookies();
- /* mixer.c */
- /* plugin.c */
- /* printf.c */
- test_printf();
- /* queue.c */
- /* sink.c */
- test_sink();
- /* snprintf.c */
- /* split.c */
- test_split();
- /* syscalls.c */
- /* table.c */
- /* unicode.c */
- test_unicode();
- /* utf8.c */
- test_utf8();
- /* vector.c */
- /* words.c */
- test_casefold();
- test_words();
- /* wstat.c */
- test_wstat();
- /* signame.c */
- test_signame();
- /* cache.c */
- test_cache();
- /* selection.c */
- test_selection();
- test_hash();
- test_url();
- test_regsub();
- test_bits();
- test_vector();
- test_syscalls();
- test_trackname();
- fprintf(stderr, "%lld errors out of %lld tests\n", errors, tests);
- return !!errors;
-}
-
/*
Local Variables:
c-basic-offset:2
uint32_t *ucs4parse(const char *s);
const char *do_printf(const char *fmt, ...);
-void test_addr(void);
-void test_basen(void);
-void test_cache(void);
-void test_casefold(void);
-void test_cookies(void);
-void test_filepart(void);
-void test_hash(void);
-void test_heap(void);
-void test_hex(void);
-void test_kvp(void);
-void test_mime(void);
-void test_printf(void);
-void test_regsub(void);
-void test_selection(void);
-void test_signame(void);
-void test_sink(void);
-void test_split(void);
-void test_unicode(void);
-void test_url(void);
-void test_utf8(void);
-void test_words(void);
-void test_wstat(void);
-void test_bits(void);
-void test_vector(void);
-void test_syscalls(void);
-void test_trackname(void);
+#define TEST(name) \
+ int main(void) { \
+ mem_init(); \
+ fail_first = !!getenv("FAIL_FIRST"); \
+ test_##name(); \
+ if(errors) \
+ fprintf(stderr, "test_"#name": %lld errors out of %lld tests\n", \
+ errors, tests); \
+ return !!errors; \
+ } \
+ \
+ struct swallow_semicolon
#endif /* TEST_H */