]> mj.ucw.cz Git - libucw.git/commitdiff
Libucw: Test for arraysort.h
authorMichal Vaner <vorner@ucw.cz>
Sun, 13 Jul 2008 07:41:22 +0000 (09:41 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 14 Jul 2008 15:28:41 +0000 (17:28 +0200)
Modified existing benchmark to return 1 as return code on failure.
Added a .t file to run from `make tests'.

lib/Makefile
lib/asort-test.c
lib/asort-test.t [new file with mode: 0644]

index 49b6872f47a2e9c48eff5386d9ac2d41d28202b1..d838ab5ef5c958479d62f428322f53eccb333b4d 100644 (file)
@@ -97,7 +97,7 @@ $(o)/lib/trie-test: $(o)/lib/trie-test.o $(LIBUCW)
 
 TESTS+=$(addprefix $(o)/lib/,regex.test unicode.test hash-test.test mempool.test stkstring.test \
     slists.test kmp-test.test bbuf.test getopt.test fastbuf.test ff-unicode.test eltpool.test \
-    fb-socket.test trie-test.test string.test sha1.test)
+    fb-socket.test trie-test.test string.test sha1.test asort-test.test)
 
 $(o)/lib/regex.test: $(o)/lib/regex-t
 $(o)/lib/unicode.test: $(o)/lib/unicode-t
@@ -116,6 +116,7 @@ $(o)/lib/fb-socket.test: $(o)/lib/fb-socket-t
 $(o)/lib/string.test: $(o)/lib/str-hex-t $(o)/lib/str-esc-t
 $(o)/lib/sha1.test: $(o)/lib/sha1-t $(o)/lib/sha1-hmac-t
 $(o)/lib/trie-test.test: $(o)/lib/trie-test
+$(o)/lib/asort-test.test: $(o)/lib/asort-test
 
 ifdef CONFIG_UCW_THREADS
 TESTS+=$(addprefix $(o)/lib/,asio.test)
index 9c6abd47dcd7496cf6153e28d332de0bc487865e..8662e7a36f9906aa5564754d0dab77fca64efa49 100644 (file)
@@ -38,12 +38,17 @@ static void generate(void)
 #endif
 }
 
+int errors = 0;
+
 static void check(void)
 {
   uns i;
   for (i=0; i<N; i++)
     if (ASORT_ELT(i) != i)
+    {
       printf("error at pos %d: %08x != %08x\n", i, ASORT_ELT(i), i);
+      errors = 1;
+    }
 }
 
 static int qs_comp(const struct elt *X, const struct elt *Y)
@@ -73,5 +78,5 @@ int main(void)
   as_sort(N);
   printf("asort: %d ms\n", get_timer(&timer));
   check();
-  return 0;
+  return errors;
 }
diff --git a/lib/asort-test.t b/lib/asort-test.t
new file mode 100644 (file)
index 0000000..f84993d
--- /dev/null
@@ -0,0 +1,3 @@
+# Test for the arraysort module
+
+Run:   ../obj/lib/asort-test