Add testsuite framework.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 10 Mar 2007 23:18:03 +0000 (00:18 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 10 Mar 2007 23:18:03 +0000 (00:18 +0100)
Makefile
tests/check.c [new file with mode: 0644]
tests/gp.c [new file with mode: 0644]
tests/ptb.c [new file with mode: 0644]

index b9aee770599d3b2190c5edcc86ca86659892b7b1..f5d9d2d798de257885faca1b2f71881686821a54 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,11 +5,14 @@ TARGETS = $(TARGET_BINS) $(TARGET_LIBS)
 
 all: $(TARGETS)
 
+tests/check: tests/check.o tests/ptb.o tests/gp.o
+       $(CC) $(FLAGS) $^ -o $@ $(CHECK_LIBS)
+
 ptb2xml.o: ptb2xml.c
        $(CC) $(CFLAGS) -c $< $(LIBXSLT_CFLAGS) $(LIBXML_CFLAGS) $(XSLT_DEFINE)
 
 %.o: %.c
-       $(CC) $(CFLAGS) -c $< 
+       $(CC) $(CFLAGS) -c $< -o $@
 
 %.po: %.c
        $(CC) $(CFLAGS) -fPIC -c $< -o $@
@@ -69,7 +72,8 @@ test: all ptb2ptb
 tags: $(wildcard *.c) $(wildcard *.h)
        ctags *.c *.h
 
-check::
+check:: tests/check
+       ./tests/check
 
 configure: configure.in
        autoreconf -f
@@ -82,6 +86,7 @@ Makefile.settings: config.status
 
 clean: 
        rm -f *.o core $(TARGETS) *.po
+       rm -f tests/check tests/*.o
 
 distclean: clean
        rm -f Makefile.settings config.h config.log
diff --git a/tests/check.c b/tests/check.c
new file mode 100644 (file)
index 0000000..a66c79a
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+    testsuite for ptabtools
+    (c) 2007 Jelmer Vernooij <jelmer@samba.org>
+
+       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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <check.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+Suite *ptb_suite();
+Suite *gp_suite();
+
+int main (int argc, char **argv)
+{
+       int nf;
+       SRunner *sr;
+
+       sr = srunner_create(ptb_suite());
+       srunner_add_suite(sr, gp_suite());
+       srunner_run_all (sr, CK_NORMAL);
+       nf = srunner_ntests_failed(sr);
+       srunner_free(sr);
+
+       return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/tests/gp.c b/tests/gp.c
new file mode 100644 (file)
index 0000000..2b71bbb
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+    testsuite for ptabtools
+    (c) 2007 Jelmer Vernooij <jelmer@samba.org>
+
+       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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <check.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+START_TEST(test_get_step)
+END_TEST
+
+Suite *gp_suite()
+{
+       Suite *s = suite_create("gp");
+       TCase *tc_core = tcase_create("core");
+       suite_add_tcase(s, tc_core);
+       tcase_add_test(tc_core, test_get_step);
+       return s;
+}
diff --git a/tests/ptb.c b/tests/ptb.c
new file mode 100644 (file)
index 0000000..d4bd27e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+    testsuite for ptabtools
+    (c) 2007 Jelmer Vernooij <jelmer@samba.org>
+
+       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., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <check.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+START_TEST(test_get_step)
+END_TEST
+
+Suite *ptb_suite()
+{
+       Suite *s = suite_create("ptb");
+       TCase *tc_core = tcase_create("core");
+       suite_add_tcase(s, tc_core);
+       tcase_add_test(tc_core, test_get_step);
+       return s;
+}