[638] in BarnOwl Developers
[D-O-H] r738 - in trunk/owl: . t
daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:08:11 2009
Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Sat, 7 Jul 2007 17:42:46 -0400 (EDT)
Author: nelhage
Date: 2007-07-07 17:42:45 -0400 (Sat, 07 Jul 2007)
New Revision: 738
Added:
trunk/owl/t/
trunk/owl/t/00-core-tests.t
Modified:
trunk/owl/Makefile.in
trunk/owl/dict.c
trunk/owl/test.h
trunk/owl/tester.c
trunk/owl/util.c
trunk/owl/variable.c
Log:
Make the built-in regression tests output TAP and add a perl wrapper
to call it.
Modified: trunk/owl/Makefile.in
===================================================================
--- trunk/owl/Makefile.in 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/Makefile.in 2007-07-07 21:42:45 UTC (rev 738)
@@ -44,7 +44,7 @@
AUTOGEN=$(GEN_C) $(GEN_H)
#AUTOGEN=$(GEN_C)
-HEADERS=$(GEN_H) owl.h config.h
+HEADERS=$(GEN_H) owl.h config.h test.h
%.o: %.c $(HEADERS)
$(CC) -c $(CFLAGS) $< -o $@
Modified: trunk/owl/dict.c
===================================================================
--- trunk/owl/dict.c 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/dict.c 2007-07-07 21:42:45 UTC (rev 738)
@@ -151,7 +151,7 @@
int numfailed=0;
char *av="aval", *bv="bval", *cv="cval", *dv="dval";
- printf("BEGIN testing owl_dict\n");
+ printf("# BEGIN testing owl_dict\n");
FAIL_UNLESS("create", 0==owl_dict_create(&d));
FAIL_UNLESS("insert b", 0==owl_dict_insert_element(&d, "b", (void*)bv, owl_dict_noop_free));
FAIL_UNLESS("insert d", 0==owl_dict_insert_element(&d, "d", (void*)dv, owl_dict_noop_free));
@@ -178,8 +178,8 @@
owl_list_free_all(&l, owl_free);
owl_dict_free_all(&d, NULL);
- if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n");
- printf("END testing owl_dict (%d failures)\n", numfailed);
+ // if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n");
+ printf("# END testing owl_dict (%d failures)\n", numfailed);
return(numfailed);
}
Added: trunk/owl/t/00-core-tests.t
===================================================================
--- trunk/owl/t/00-core-tests.t (rev 0)
+++ trunk/owl/t/00-core-tests.t 2007-07-07 21:42:45 UTC (rev 738)
@@ -0,0 +1,3 @@
+#!/usr/bin/env perl
+use File::Basename;
+system(dirname($0) . "/../tester");
Modified: trunk/owl/test.h
===================================================================
--- trunk/owl/test.h 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/test.h 2007-07-07 21:42:45 UTC (rev 738)
@@ -2,7 +2,7 @@
#define __OWL_TEST_H__
#define FAIL_UNLESS(desc,pred) do { int __pred = (pred); \
- printf("\t%-4s: %s", (__pred)?"ok":(numfailed++,"FAIL"), desc); \
+ printf("%s %s", (__pred)?"ok":(numfailed++,"not ok"), desc); \
if(!(__pred)) printf("\t(%s:%d)", __FILE__, __LINE__); printf("%c", '\n'); } while(0)
#endif
Modified: trunk/owl/tester.c
===================================================================
--- trunk/owl/tester.c 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/tester.c 2007-07-07 21:42:45 UTC (rev 738)
@@ -142,20 +142,28 @@
}
+#define OWL_DICT_NTESTS 20
+#define OWL_UTIL_NTESTS 9
+#define OWL_OBARRAY_NTESTS 5
+#define OWL_VARIABLE_NTESTS 52
+#define OWL_FILTER_NTESTS 23
+
int main(int argc, char **argv, char **env)
{
owl_errqueue_init(owl_global_get_errqueue(&g));
owl_obarray_init(&(g.obarray));
int numfailures=0;
- if (argc==2 && 0==strcmp(argv[1],"reg")) {
+ if (argc==1 || (argc==2 && 0==strcmp(argv[1],"reg"))) {
+ printf("1..%d\n", OWL_UTIL_NTESTS+OWL_DICT_NTESTS+OWL_VARIABLE_NTESTS
+ +OWL_FILTER_NTESTS+OWL_OBARRAY_NTESTS);
numfailures += owl_util_regtest();
numfailures += owl_dict_regtest();
numfailures += owl_variable_regtest();
numfailures += owl_filter_regtest();
numfailures += owl_obarray_regtest();
if (numfailures) {
- fprintf(stderr, "*** WARNING: %d failures total\n", numfailures);
+ fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
}
return(numfailures);
} else if (argc==2 && 0==strcmp(argv[1],"test1")) {
Modified: trunk/owl/util.c
===================================================================
--- trunk/owl/util.c 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/util.c 2007-07-07 21:42:45 UTC (rev 738)
@@ -788,7 +788,7 @@
{
int numfailed=0;
- printf("BEGIN testing owl_util\n");
+ printf("# BEGIN testing owl_util\n");
FAIL_UNLESS("owl_util_substitute 1",
!strcmp("foo", owl_text_substitute("foo", "", "Y")));
@@ -811,8 +811,8 @@
FAIL_UNLESS("owl_util_uniq 3",
!strcmp("meep foo bar", owl_util_uniq("meep foo", "bar foo meep", "-")));
- if (numfailed) printf("*** WARNING: failures encountered with owl_util\n");
- printf("END testing owl_util (%d failures)\n", numfailed);
+ // if (numfailed) printf("*** WARNING: failures encountered with owl_util\n");
+ printf("# END testing owl_util (%d failures)\n", numfailed);
return(numfailed);
}
Modified: trunk/owl/variable.c
===================================================================
--- trunk/owl/variable.c 2007-07-01 02:12:06 UTC (rev 737)
+++ trunk/owl/variable.c 2007-07-07 21:42:45 UTC (rev 738)
@@ -976,7 +976,7 @@
in_regtest = 1;
- printf("BEGIN testing owl_variable\n");
+ printf("# BEGIN testing owl_variable\n");
FAIL_UNLESS("setup", 0==owl_variable_dict_setup(&vd));
FAIL_UNLESS("get bool", 0==owl_variable_get_bool(&vd,"rxping"));
@@ -1048,8 +1048,8 @@
owl_variable_dict_free(&vd);
- if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n");
- printf("END testing owl_variable (%d failures)\n", numfailed);
+ // if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n");
+ printf("# END testing owl_variable (%d failures)\n", numfailed);
return(numfailed);
}