chiark / gitweb /
Synchronize with disorder.dev
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 3 May 2008 19:15:50 +0000 (20:15 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 3 May 2008 19:15:50 +0000 (20:15 +0100)
43 files changed:
.bzrignore
lib/Makefile.am
lib/t-addr.c
lib/t-basen.c
lib/t-bits.c
lib/t-cache.c
lib/t-casefold.c
lib/t-cookies.c
lib/t-filepart.c
lib/t-hash.c
lib/t-heap.c
lib/t-hex.c
lib/t-kvp.c
lib/t-mime.c
lib/t-printf.c
lib/t-regsub.c
lib/t-selection.c
lib/t-signame.c
lib/t-sink.c
lib/t-split.c
lib/t-syscalls.c
lib/t-trackname.c
lib/t-unicode.c
lib/t-url.c
lib/t-utf8.c
lib/t-vector.c
lib/t-words.c
lib/t-wstat.c
lib/test.c
lib/test.h
server/server.c
tests/Makefile.am
tests/alltests [deleted file]
tests/cookie.py
tests/dbversion.py
tests/dump.py
tests/files.py
tests/play.py
tests/queue.py
tests/recode.py
tests/search.py
tests/user-upgrade.py
tests/user.py

index e4a97a8c7440969e28d3db446214a11d949c2dd9..420efc67b2651f0a780c6401f3b50d9163e8ad4b 100644 (file)
@@ -68,7 +68,6 @@ examples/disorder.init
 images/Makefile
 lib/Makefile
 lib/definitions.h
-lib/test
 plugins/Makefile
 python/Makefile
 python/disorder.py
@@ -147,3 +146,29 @@ scripts/teardown
 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
index 91a2bf177e7fac94926e938c49927fc0663fb389..5320060101d180924ee7a76a3ec8bbe3042f72a6 100644 (file)
 # 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
@@ -115,17 +120,109 @@ definitions.h: Makefile
 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-report: before-check check make-coverage-reports
 before-check:
index e609cd9465ebf44f6f8405441e412cb6cb1340a7..0e495d8158a561242b012764910ca8c6440980b4 100644 (file)
@@ -19,7 +19,7 @@
  */
 #include "test.h"
 
-void test_addr(void) {
+static void test_addr(void) {
   struct stringlist a;
   const char *s[3];
   struct addrinfo *ai;
@@ -58,8 +58,6 @@ void test_addr(void) {
     .ai_addr = (struct sockaddr *)&a2,
   };
 
-  printf("test_addr\n");
-
   insist(addrinfocmp(&p1, &p2) < 0);
 
   a.n = 1;
@@ -132,6 +130,8 @@ void test_addr(void) {
   check_integer(multicast((struct sockaddr *)&su), 0);
 }
 
+TEST(addr);
+
 /*
 Local Variables:
 c-basic-offset:2
index 751d4b0ee67cd6588125a1a21ab03baddf191927..99b52f992445c70836f67b50cf4c59d4e320ef46 100644 (file)
  */
 #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");
@@ -53,6 +52,8 @@ void test_basen(void) {
   insist(basen(v, 4, buffer, 10, 16) == -1);
 }
 
+TEST(basen);
+
 /*
 Local Variables:
 c-basic-offset:2
index 846abb87af90dff70bb391b6ae6ba6ef0ff6523f..80bfdf58a407832c048f4c2fa44f0c69c40f6569 100644 (file)
 #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);
@@ -36,6 +35,8 @@ void test_bits(void) {
   }
 }
 
+TEST(bits);
+
 /*
 Local Variables:
 c-basic-offset:2
index 02da8d66b51e00af906eced210f7ab30068121d3..3cdb4003401f8eb55b0bf9196b35f4b771456443 100644 (file)
  */
 #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);
@@ -47,6 +47,8 @@ void test_cache(void) {
   insist(cache_get(&t2, "2") == 0); 
 }
 
+TEST(cache);
+
 /*
 Local Variables:
 c-basic-offset:2
index f86738e5a001793d1372c868c184966833b26d73..449eaffb7583e12ed37a21a4cea2a396c028b16d 100644 (file)
  */
 #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. */
   
@@ -75,6 +73,8 @@ void test_casefold(void) {
   check_string(utf8_casefold_canon("", 0, 0), "");
 }
 
+TEST(casefold);
+
 /*
 Local Variables:
 c-basic-offset:2
index 7fdde3272d58b3a94386720e21e039c64acecd90..c8ec504c9eb2bdb8a13c8142cc1136fe74e407e0 100644 (file)
  */
 #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"));
@@ -72,6 +70,8 @@ void test_cookies(void) {
   insist(cd->cookies[0].domain == 0);
 }
 
+TEST(cookies);
+
 /*
 Local Variables:
 c-basic-offset:2
index 1bf55f34f6fa8f221fc2addb858cfc641bba98e7..d2e741b4c009365f038d53915fb47e4511576fcf 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * This file is part of DisOrder.
  * Copyright (C) 2005, 2007, 2008 Richard Kettlewell
@@ -19,8 +20,7 @@
  */
 #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"), "/");
@@ -47,6 +47,8 @@ void test_filepart(void) {
   check_string(strip_extension("foo.bar/wibble.spong"), "foo.bar/wibble");
 }
 
+TEST(filepart);
+
 /*
 Local Variables:
 c-basic-offset:2
index b5c0094a79e159c8fed96a27941a2e394521ed9d..d9e833689dfa5d5d20c2c4f1918765945d7858b8 100644 (file)
  */
 #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);
@@ -44,6 +43,8 @@ void test_hash(void) {
   check_integer(hash_count(h), 0);
 }
 
+TEST(hash);
+
 /*
 Local Variables:
 c-basic-offset:2
index c3e4a03f934f1bcfec6bf67e8af996bca6ae6ca7..54d052a5dd9226adf8ceecbf31136b421a5f52ad 100644 (file)
@@ -28,13 +28,11 @@ HEAP_TYPE(iheap, int, int_lt);
 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);
@@ -45,9 +43,10 @@ void test_heap(void) {
     insist(last <= latest);
     last = latest;
   }
-  putchar('\n');
 }
 
+TEST(heap);
+
 /*
 Local Variables:
 c-basic-offset:2
index 3f6ba99717349d783f6b90e25ee0cd665459819e..966d22666234ba3d7f2c72f92960747908173e6c 100644 (file)
  */
 #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);
@@ -69,6 +67,8 @@ void test_hex(void) {
   fprintf(stderr, "}\n");
 }
 
+TEST(hex);
+
 /*
 Local Variables:
 c-basic-offset:2
index b6bcc3dfd679a0cc7f10c9f476493267dc227a78..ce01a84c1d5efc6e108494dcb164f93945e0c78b 100644 (file)
  */
 #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);
@@ -58,6 +59,8 @@ void test_kvp(void) {
                "abc%25%20%2b%0a");
 }
 
+TEST(kvp);
+
 /*
 Local Variables:
 c-basic-offset:2
index 5c3152a0c7d3ff6d421798afeab214e1055e9576..65000c7b0e9d9e0e2d704985e5b2c07cf6694ff0 100644 (file)
@@ -34,15 +34,13 @@ static int header_callback(const char *name, const char *value,
   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));
@@ -337,6 +335,8 @@ void test_mime(void) {
   check_string(enc, "quoted-printable");
 }
 
+TEST(mime);
+
 /*
 Local Variables:
 c-basic-offset:2
index be57bc81de876637612ce85a81e48a5cad77c0f0..85b85c911447051765effbe0726dab15303419a1 100644 (file)
@@ -19,7 +19,7 @@
  */
 #include "test.h"
 
-void test_printf(void) {
+static void test_printf(void) {
   char c;
   short s;
   int i;
@@ -32,7 +32,6 @@ void test_printf(void) {
   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");
@@ -132,6 +131,8 @@ void test_printf(void) {
   fclose(fp);
 }
 
+TEST(printf);
+
 /*
 Local Variables:
 c-basic-offset:2
index bff05dccf3aa64aaa8b624c120848bae935135b4..1497db2da5b732fe842a1b305e928596360f5985 100644 (file)
  */
 #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);
@@ -65,6 +63,8 @@ void test_regsub(void) {
                "foo-x:bBb$aAaA:y-bar");
 }
 
+TEST(regsub);
+
 /*
 Local Variables:
 c-basic-offset:2
index 975f9305c8b765992bd7f239de0c3debbe58a27c..0992efe7083ddda2777a67702e99471bf37ab10b 100644 (file)
@@ -19,9 +19,9 @@
  */
 #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);
@@ -57,6 +57,8 @@ void test_selection(void) {
   insist(hash_count(h) == 0);
 }
 
+TEST(selection);
+
 /*
 Local Variables:
 c-basic-offset:2
index 72f1d0fadee8a2a074637a30dda911c5a088c272..95f06b8ec5df4615fd4d05061cb87b2f233dbbbc 100644 (file)
@@ -19,8 +19,7 @@
  */
 #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);
@@ -29,6 +28,8 @@ void test_signame(void) {
   insist(find_signal("SIGYOURMUM") == -1);
 }
 
+TEST(signame);
+
 /*
 Local Variables:
 c-basic-offset:2
index ad7b23c890d5dffb3ab3bcdf618676afc7f2f547..68816b3318d4f342b7a3b001ec20caa3f961d768 100644 (file)
  */
 #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);
@@ -58,6 +56,8 @@ void test_sink(void) {
   check_string(d->vec, "test: 999\nwibble: foobar\n");
 }
 
+TEST(sink);
+
 /*
 Local Variables:
 c-basic-offset:2
index 1b8aa18e2d801a37b3f435cc5f326b0ad89ca888..3737d0c7d216634d2f4c4a1658d728d423d53631 100644 (file)
  */
 #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);
@@ -88,6 +87,8 @@ void test_split(void) {
   check_string(quoteutf8("wibble'wobble"), "\"wibble'wobble\"");
 }
 
+TEST(split);
+
 /*
 Local Variables:
 c-basic-offset:2
index 6fcf413b12cd872a6551f1dc8f760d1bb639a917..a4ab19bdeabbf78b41554f0a5aa624e812d39e3c 100644 (file)
  */
 #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]);
@@ -70,6 +68,10 @@ void test_syscalls(void) {
   insist(e != 0);
   check_string(e, "xyzzy");
 
+#ifdef LLONG_MAX
+  /* Debian's gcc 2.95 cannot easily be persuaded to define LLONG_MAX even in
+   * extensions modes.  If your compiler is this broken you just don't get the
+   * full set of tests.  Deal. */
   nn = 0;
   e = 0;
   sprintf(buf, "%lld", LLONG_MAX);
@@ -90,9 +92,12 @@ void test_syscalls(void) {
   insist(xstrtoll(&nn, buf, &e, 0) == 0);
   insist(nn == LLONG_MAX);
   insist(e != 0);
-  check_string(e, "xyzzy");  
+  check_string(e, "xyzzy");
+#endif
 }
 
+TEST(syscalls);
+
 /*
 Local Variables:
 c-basic-offset:2
index 23674edef9fe906b107dc4753d61a41eff2fc6cb..29103aee123ebcd4744b50eededd2463087c9008 100644 (file)
@@ -28,8 +28,7 @@
                          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);
@@ -38,6 +37,8 @@ void test_trackname(void) {
   CHECK_PATH_ORDER("/", "/", 0);
 }
 
+TEST(trackname);
+
 /*
 Local Variables:
 c-basic-offset:2
index 2d7c81c5060a7ca302a75578bfae3d64a68f3414..f50454e0a304ba07d84176098a15150a14188b14 100644 (file)
@@ -100,7 +100,7 @@ static void breaktest(const char *path,
 }
 
 /** @brief Tests for @ref lib/unicode.h */
-void test_unicode(void) {
+static void test_unicode(void) {
   FILE *fp;
   int lineno = 0;
   char *l, *lp;
@@ -108,7 +108,6 @@ void test_unicode(void) {
   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;
@@ -189,6 +188,8 @@ void test_unicode(void) {
   insist(utf32_combining_class(0xE0000) == 0);
 }
 
+TEST(unicode);
+
 /*
 Local Variables:
 c-basic-offset:2
index 89fb3457369e1679ec888986766cab4435235f6e..aa83940529e006bd9171c0c142a244b3d5021337 100644 (file)
  */
 #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");
@@ -50,6 +48,8 @@ void test_url(void) {
   insist(parse_url("http://www.example.com/example%2zpath", &p) == -1);
 }
 
+TEST(url);
+
 /*
 Local Variables:
 c-basic-offset:2
index de2f8b379697f740337acee4daf3f5b590636885..a98f956f5bc269ea0ceebab7e03a9cb782b5aa26 100644 (file)
@@ -19,7 +19,7 @@
  */
 #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 {                  \
@@ -36,7 +36,6 @@ void test_utf8(void) {
   check_string(u8, CHARS);                     \
 } while(0)
 
-  fprintf(stderr, "test_utf8\n");
 #define validutf8(S) utf8_valid((S), strlen(S))
 
   /* empty string */
@@ -134,6 +133,8 @@ void test_utf8(void) {
   insist(!validutf8("\xF8"));
 }
 
+TEST(utf8);
+
 /*
 Local Variables:
 c-basic-offset:2
index 685f2130d578662058a05f95bbeb3c33689448fe..137ea608334371904b497b8040fc18bbfcdc2d26 100644 (file)
  */
 #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);
 
@@ -55,6 +54,7 @@ void test_vector(void) {
   insist(v->vec[12] == 0);
 }
 
+TEST(vector);
 
 /*
 Local Variables:
index 4b3ee5523d79dc79cd2155cd48aa0184d0cf6305..30730c929110c24716b8192dc222e36d74e62576 100644 (file)
@@ -49,11 +49,10 @@ struct {
 };
 #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);
 
@@ -82,6 +81,8 @@ void test_words(void) {
   }
 }
 
+TEST(words);
+
 /*
 Local Variables:
 c-basic-offset:2
index 0d87472416bb00784f4e52671fea296cba8e487c..a6746cda42831f43a8072092a8e6a87ad83b979d 100644 (file)
  */
 #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);
   }
@@ -39,6 +38,8 @@ void test_wstat(void) {
   check_string_prefix(wstat(w), "terminated by signal 15");
 }
 
+TEST(wstat);
+
 /*
 Local Variables:
 c-basic-offset:2
index 0682979e3323e01304c3209f45d267a058286422..63d726010410ce33ffac79e5ed18f64367f22666 100644 (file)
@@ -90,82 +90,6 @@ const char *do_printf(const char *fmt, ...) {
   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
index 4fbde0b69c18a9a526d761250efcb145e6082c7e..3c43da087bb222f0f0a775e5af1561de9066ca7d 100644 (file)
@@ -131,32 +131,18 @@ const char *format_utf32(const uint32_t *s);
 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 */
 
index 90aaa7749a4aae9fbbabf2bd19fb2b96135462f7..3d593987264018a1b0a9e6b4aafa62f83a1ee0b1 100644 (file)
@@ -1097,6 +1097,7 @@ static int c_adduser(struct conn *c,
   const char *rights;
 
   if(!config->remote_userman && !(c->rights & RIGHT__LOCAL)) {
+    error(0, "S%x: remote adduser", c->tag);
     sink_writes(ev_writer_sink(c->w), "550 Remote user management is disabled\n");
     return 1;
   }
@@ -1122,6 +1123,7 @@ static int c_deluser(struct conn *c,
   struct conn *d;
 
   if(!config->remote_userman && !(c->rights & RIGHT__LOCAL)) {
+    error(0, "S%x: remote deluser", c->tag);
     sink_writes(ev_writer_sink(c->w), "550 Remote user management is disabled\n");
     return 1;
   }
@@ -1143,6 +1145,7 @@ static int c_edituser(struct conn *c,
   struct conn *d;
 
   if(!config->remote_userman && !(c->rights & RIGHT__LOCAL)) {
+    error(0, "S%x: remote edituser", c->tag);
     sink_writes(ev_writer_sink(c->w), "550 Remote user management is disabled\n");
     return 1;
   }
@@ -1184,7 +1187,12 @@ static int c_userinfo(struct conn *c,
   struct kvp *k;
   const char *value;
 
-  if(!config->remote_userman && !(c->rights & RIGHT__LOCAL)) {
+  /* We allow remote querying of rights so that clients can figure out what
+   * they're allowed to do */
+  if(!config->remote_userman
+     && !(c->rights & RIGHT__LOCAL)
+     && strcmp(vec[1], "rights")) {
+    error(0, "S%x: remote userinfo %s %s", c->tag, vec[0], vec[1]);
     sink_writes(ev_writer_sink(c->w), "550 Remote user management is disabled\n");
     return 1;
   }
index ff6253d30ca2438c5c88df48a8e99dd007bbbc15..6795672a9a23909e8656319306b5b232a15ff68f 100644 (file)
@@ -26,11 +26,11 @@ disorder_udplog_SOURCES=udplog.c
 disorder_udplog_LDADD=$(LIBOBJS) ../lib/libdisorder.a
 disorder_udplog_DEPENDENCIES=../lib/libdisorder.a
 
-check:
-       ${PYTHON} -u ${srcdir}/alltests
+TESTS=cookie.py dbversion.py dump.py files.py play.py queue.py \
+       recode.py search.py user-upgrade.py user.py
 
 clean-local:
        rm -rf testroot *.log *.pyc
 
-EXTRA_DIST=alltests dtest.py dbversion.py search.py \
+EXTRA_DIST=dtest.py dbversion.py search.py \
        queue.py dump.py play.py cookie.py user-upgrade.py user.py recode.py
diff --git a/tests/alltests b/tests/alltests
deleted file mode 100755 (executable)
index 812b53a..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#! /usr/bin/env python
-#
-# This file is part of DisOrder.
-# Copyright (C) 2007 Richard Kettlewell
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-#
-import sys,re,os.path,os
-
-# Parse the makefile in the current directory to identify the source directory
-top_srcdir = None
-for l in file("Makefile"):
-    r = re.search("^top_srcdir *= *(.*)$",  l)
-    if r:
-        top_srcdir = r.group(1)
-        break
-if not top_srcdir:
-    fatal("cannot identify source directory")
-
-# Make sure that the test directory is on the module search path (so we can
-# find dtest and the tests themselves)
-testdir = os.path.join(top_srcdir, "tests")
-sys.path.insert(0, testdir)
-import dtest
-
-# The tests are all the *.py files in the test source directory that
-# call dtest.run
-tests = []
-for f in os.listdir(testdir):
-    if f == 'dtest.py':                 # special case
-        continue
-    r = re.search("^(.*)\\.py$", f)
-    if r is not None:
-        isTest = False
-        base = r.group(1)
-        for l in file(os.path.join(testdir, f)):
-            r = re.search("dtest\\.run", l)
-            if r is not None:
-                isTest = True
-                break
-        if isTest:
-            tests.append(base)
-tests.sort()                            # let's have a consistent order
-
-for test in tests:
-    print "-------- Test '%s' --------" % test
-    dtest.run(test, report=False)
-
-print "%d tests" % dtest.tests
-if dtest.failures:
-    print "%d failures" % dtest.failures
-    sys.exit(1)
-else:
-    print "All tests OK"
index 8a9182977286011d0d67fc1ee03295f607f889d1..21353b08a8eeb24dff9d53f8805147c6c7c8ed3b 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007 Richard Kettlewell
index 218e0c9023056442f3cad13539c2859e5fb185c9..c93e1e8e4d33f1f470086f41c6c516e0ca6a3679 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007, 2008 Richard Kettlewell
index ff28a0ffc32001c3187f723dbd546f22e4a1dd41..c935f204d46bf4d8d52d25f92b9d141212d00343 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007, 2008 Richard Kettlewell
index 984c6cca89dd839d05e26f10112aada72b96a592..65211dc16d6ee24e5389c4a6fea6c9cae7dfa883 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007, 2008 Richard Kettlewell
index 0013d7e3e62b420d4c0b496ffa3d598e1a2c0000..35cc7a3fa384881d57db1d21c48796bdb1a5d7f5 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007, 2008 Richard Kettlewell
index dae37b47d473206d825940eb4e7c55796a6e5dbe..a1ddedfe8217f8656ff6a88b4d90e2eb45a671d6 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2007, 2008 Richard Kettlewell
index 1539da0ea871d7ee84750ddbc380782d4c06c04b..d57db022445ac10811b3ab3ef1136186ecd676b9 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
 # Copyright (C) 2008 Richard Kettlewell
@@ -42,7 +42,7 @@ def test():
     if sys.platform == "darwin":
       print "Sorry, cannot run this test on Darwin"
       # ...because local fs is always UTF-8
-      return
+      sys.exit(77)
     dtest.start_daemon()
     dtest.create_user()
     dtest.rescan()
index 1b86bea25b89402866b7babf76130794ef3f2329..556a24c4ad798809f1fdbd7835e638caf8c30dae 100755 (executable)
@@ -1,7 +1,7 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
-# Copyright (C) 2007 Richard Kettlewell
+# Copyright (C) 2007, 2008 Richard Kettlewell
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
index 3bab5816aab1dd79c70a76e2788110819157c54c..ffd30ea2d15ad46810302c86d5662701ea80c86a 100755 (executable)
@@ -1,7 +1,7 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
-# Copyright (C) 2007 Richard Kettlewell
+# Copyright (C) 2007, 2008 Richard Kettlewell
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
index 1f3a39fe568775f767ed7b2ee74d512fd7cc6c4c..4c4fa4884cd1051938e6d1f361972b857eb639f4 100755 (executable)
@@ -1,7 +1,7 @@
-#! /usr/bin/env python
+#! /usr/bin/env python -u
 #
 # This file is part of DisOrder.
-# Copyright (C) 2007 Richard Kettlewell
+# Copyright (C) 2007, 2008 Richard Kettlewell
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by