summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore8
-rw-r--r--Makefile.am2
-rw-r--r--NEWS1
-rw-r--r--configure.in117
-rw-r--r--lib/tests/Makefile.am49
-rw-r--r--tap/Makefile.am13
-rw-r--r--tap/README11
-rw-r--r--tap/tap.3368
-rw-r--r--tap/tap.c435
-rw-r--r--tap/tap.h89
-rw-r--r--tap/tests/Makefile.am7
-rw-r--r--tap/tests/README12
-rw-r--r--tap/tests/diag/Makefile.am13
-rw-r--r--tap/tests/diag/test.c46
-rw-r--r--tap/tests/diag/test.pl16
-rw-r--r--tap/tests/diag/test.t29
-rw-r--r--tap/tests/fail/Makefile.am13
-rw-r--r--tap/tests/fail/test.c46
-rw-r--r--tap/tests/fail/test.pl17
-rw-r--r--tap/tests/fail/test.t29
-rw-r--r--tap/tests/ok/Makefile.am3
-rw-r--r--tap/tests/ok/ok-hash/Makefile.am13
-rw-r--r--tap/tests/ok/ok-hash/test.c52
-rw-r--r--tap/tests/ok/ok-hash/test.pl24
-rw-r--r--tap/tests/ok/ok-hash/test.t29
-rw-r--r--tap/tests/ok/ok-numeric/Makefile.am13
-rw-r--r--tap/tests/ok/ok-numeric/test.c49
-rw-r--r--tap/tests/ok/ok-numeric/test.pl21
-rw-r--r--tap/tests/ok/ok-numeric/test.t29
-rw-r--r--tap/tests/ok/ok/Makefile.am13
-rw-r--r--tap/tests/ok/ok/test.c55
-rw-r--r--tap/tests/ok/ok/test.pl27
-rw-r--r--tap/tests/ok/ok/test.t29
-rw-r--r--tap/tests/pass/Makefile.am13
-rw-r--r--tap/tests/pass/test.c46
-rw-r--r--tap/tests/pass/test.pl17
-rw-r--r--tap/tests/pass/test.t29
-rw-r--r--tap/tests/plan/Makefile.am7
-rw-r--r--tap/tests/plan/no-tests/Makefile.am13
-rw-r--r--tap/tests/plan/no-tests/test.c43
-rw-r--r--tap/tests/plan/no-tests/test.pl14
-rw-r--r--tap/tests/plan/no-tests/test.t29
-rw-r--r--tap/tests/plan/no_plan/Makefile.am13
-rw-r--r--tap/tests/plan/no_plan/test.c43
-rw-r--r--tap/tests/plan/no_plan/test.pl14
-rw-r--r--tap/tests/plan/no_plan/test.t29
-rw-r--r--tap/tests/plan/not-enough-tests/Makefile.am13
-rw-r--r--tap/tests/plan/not-enough-tests/test.c49
-rw-r--r--tap/tests/plan/not-enough-tests/test.pl20
-rw-r--r--tap/tests/plan/not-enough-tests/test.t29
-rw-r--r--tap/tests/plan/sane/Makefile.am13
-rw-r--r--tap/tests/plan/sane/test.c43
-rw-r--r--tap/tests/plan/sane/test.pl14
-rw-r--r--tap/tests/plan/sane/test.t29
-rw-r--r--tap/tests/plan/skip_all/Makefile.am13
-rw-r--r--tap/tests/plan/skip_all/test.c38
-rw-r--r--tap/tests/plan/skip_all/test.pl11
-rw-r--r--tap/tests/plan/skip_all/test.t29
-rw-r--r--tap/tests/plan/too-many-plans/Makefile.am13
-rw-r--r--tap/tests/plan/too-many-plans/test.c49
-rw-r--r--tap/tests/plan/too-many-plans/test.pl20
-rw-r--r--tap/tests/plan/too-many-plans/test.t29
-rw-r--r--tap/tests/plan/too-many-tests/Makefile.am13
-rw-r--r--tap/tests/plan/too-many-tests/test.c46
-rw-r--r--tap/tests/plan/too-many-tests/test.pl17
-rw-r--r--tap/tests/plan/too-many-tests/test.t29
-rw-r--r--tap/tests/skip/Makefile.am13
-rw-r--r--tap/tests/skip/test.c69
-rw-r--r--tap/tests/skip/test.pl40
-rw-r--r--tap/tests/skip/test.t29
-rw-r--r--tap/tests/todo/Makefile.am13
-rw-r--r--tap/tests/todo/test.c68
-rw-r--r--tap/tests/todo/test.pl41
-rw-r--r--tap/tests/todo/test.t29
74 files changed, 2743 insertions, 64 deletions
diff --git a/.gitignore b/.gitignore
index 54655f8e..d93f23f3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,6 +96,14 @@ NP-VERSION-FILE
96/intl/ref-del.sin 96/intl/ref-del.sin
97/intl/textdomain.c 97/intl/textdomain.c
98 98
99# /tap/
100/tap/.deps
101/tap/.libs
102/tap/Makefile
103/tap/Makefile.in
104/tap/libtap.la
105/tap/tap.lo
106
99# /lib/ 107# /lib/
100/lib/.deps 108/lib/.deps
101/lib/getopt.h 109/lib/getopt.h
diff --git a/Makefile.am b/Makefile.am
index a0bc561e..b6e5f2ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
1## Process this file with automake to produce Makefile.in 1## Process this file with automake to produce Makefile.in
2 2
3SUBDIRS = gl lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ 3SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
4 4
5EXTRA_DIST = config.rpath \ 5EXTRA_DIST = config.rpath \
6 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \ 6 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \
diff --git a/NEWS b/NEWS
index c69fd2f8..729beae3 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,7 @@ This file documents the major additions and syntax changes between releases.
17 Fixed bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159) 17 Fixed bug where additional headers with redirection caused a segfault (Dieter Van de Walle - 2089159)
18 check_disk: make autofs mount paths specified with -p before we determing the mount list (Erik Welch) 18 check_disk: make autofs mount paths specified with -p before we determing the mount list (Erik Welch)
19 Fixed buffer overflow in check_ntp/check_ntp_peer (#1999319, Ubuntu #291265) 19 Fixed buffer overflow in check_ntp/check_ntp_peer (#1999319, Ubuntu #291265)
20 Re-bundled libtap as a built-in library (--enable-libtap): detects system library as pre-1.4.13 and does not install the built-in library anymore
20 21
211.4.13 25th Sept 2008 221.4.13 25th Sept 2008
22 Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen) 23 Fix Debian bug #460097: check_http --max-age broken (Hilko Bengen)
diff --git a/configure.in b/configure.in
index 39cd6b71..3ff06366 100644
--- a/configure.in
+++ b/configure.in
@@ -118,7 +118,7 @@ AC_SUBST(PERL, $with_perl)
118 118
119dnl openssl/gnutls 119dnl openssl/gnutls
120AC_ARG_WITH(openssl, 120AC_ARG_WITH(openssl,
121 AC_HELP_STRING([--with-openssl=DIR], 121 AC_HELP_STRING([--with-openssl=DIR],
122 [path to openssl installation]),) 122 [path to openssl installation]),)
123 123
124AC_ARG_WITH(gnutls, 124AC_ARG_WITH(gnutls,
@@ -156,23 +156,41 @@ AC_CHECK_HEADERS(math.h)
156AC_CHECK_LIB(m,floor,MATHLIBS="-lm") 156AC_CHECK_LIB(m,floor,MATHLIBS="-lm")
157AC_SUBST(MATHLIBS) 157AC_SUBST(MATHLIBS)
158 158
159dnl Check for libtap, to run perl-like tests 159dnl Check if we buils local libtap
160AC_CHECK_LIB(tap, plan_tests, 160AC_ARG_ENABLE(libtap,
161 AC_HELP_STRING([--enable-libtap],
162 [Enable built-in libtap for unit-testing (default: autodetect system library).]),
163 [enable_libtap=$enableval],
164 [enable_libtap=no])
165AM_CONDITIONAL([USE_LIBTAP_LOCAL],[test "$enable_libtap" = "yes"])
166
167# If not local, check if we can use the system one
168if test "$enable_libtap" != "yes" ; then
169 dnl Check for libtap, to run perl-like tests
170 AC_CHECK_LIB(tap, plan_tests,
171 enable_libtap="yes"
172 )
173fi
174
175# Finally, define tests if we use libtap
176if test "$enable_libtap" = "yes" ; then
161 EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64" 177 EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
162 AC_SUBST(EXTRA_TEST) 178 AC_SUBST(EXTRA_TEST)
163 ) 179fi
164 180
165dnl INI Parsing 181dnl INI Parsing
166AC_ARG_ENABLE(extra-opts, 182AC_ARG_ENABLE(extra-opts,
167 AC_HELP_STRING([--enable-extra-opts], 183 AC_HELP_STRING([--enable-extra-opts],
168 [Enables parsing of plugins ini config files for extra options (default: no)]), 184 [Enables parsing of plugins ini config files for extra options (default: no)]),
169 [enable_extra_opts=$enableval], 185 [enable_extra_opts=$enableval],
170 [enable_extra_opts=no]) 186 [enable_extra_opts=no])
171AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"]) 187AM_CONDITIONAL([USE_PARSE_INI],[test "$enable_extra_opts" = "yes"])
172if test "$enable_extra_opts" = "yes" ; then 188if test "$enable_extra_opts" = "yes" ; then
173 EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
174 AC_SUBST(EXTRA_TEST)
175 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.]) 189 AC_DEFINE(NP_EXTRA_OPTS,[1],[Enable INI file parsing.])
190 if test "$enable_libtap" = "yes"; then
191 EXTRA_TEST="$EXTRA_TEST test_ini test_opts"
192 AC_SUBST(EXTRA_TEST)
193 fi
176fi 194fi
177 195
178dnl Check for PostgreSQL libraries 196dnl Check for PostgreSQL libraries
@@ -272,8 +290,8 @@ fi
272if test "$FOUNDINCLUDE" = "yes" ; then 290if test "$FOUNDINCLUDE" = "yes" ; then
273 EXTRAS="$EXTRAS check_ide_smart" 291 EXTRAS="$EXTRAS check_ide_smart"
274else 292else
275 AC_MSG_WARN([Skipping check_ide_smart plugin.]) 293 AC_MSG_WARN([Skipping check_ide_smart plugin.])
276 AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.]) 294 AC_MSG_WARN([check_ide_smart is linux specific. It requires linux/hdreg.h and linux/types.h.])
277fi 295fi
278 296
279dnl Check for mysql libraries 297dnl Check for mysql libraries
@@ -467,7 +485,7 @@ ac_cv_HAVE_VA_COPY=yes,
467ac_cv_HAVE_VA_COPY=no)]) 485ac_cv_HAVE_VA_COPY=no)])
468if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then 486if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
469 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available]) 487 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
470else 488else
471 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[ 489 AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
472 AC_TRY_LINK([#include <stdarg.h> 490 AC_TRY_LINK([#include <stdarg.h>
473 va_list ap1,ap2;], [__va_copy(ap1,ap2);], 491 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
@@ -513,7 +531,7 @@ AC_PATH_PROG(PATH_TO_PS,ps)
513 531
514AC_MSG_CHECKING(for ps syntax) 532AC_MSG_CHECKING(for ps syntax)
515AC_ARG_WITH(ps_command, 533AC_ARG_WITH(ps_command,
516 ACX_HELP_STRING([--with-ps-command=PATH], 534 ACX_HELP_STRING([--with-ps-command=PATH],
517 [Verbatim command to execute for ps]), 535 [Verbatim command to execute for ps]),
518 PS_COMMAND=$withval) 536 PS_COMMAND=$withval)
519AC_ARG_WITH(ps_format, 537AC_ARG_WITH(ps_format,
@@ -521,7 +539,7 @@ AC_ARG_WITH(ps_format,
521 [Format string for scanning ps output]), 539 [Format string for scanning ps output]),
522 PS_FORMAT=$withval) 540 PS_FORMAT=$withval)
523AC_ARG_WITH(ps_cols, 541AC_ARG_WITH(ps_cols,
524 ACX_HELP_STRING([--with-ps-cols=NUM], 542 ACX_HELP_STRING([--with-ps-cols=NUM],
525 [Number of columns in ps command]), 543 [Number of columns in ps command]),
526 PS_COLS=$withval) 544 PS_COLS=$withval)
527AC_ARG_WITH(ps_varlist, 545AC_ARG_WITH(ps_varlist,
@@ -529,7 +547,7 @@ AC_ARG_WITH(ps_varlist,
529 [Variable list for sscanf of 'ps' output]), 547 [Variable list for sscanf of 'ps' output]),
530 PS_VARLIST=$withval) 548 PS_VARLIST=$withval)
531 549
532if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then 550if test -n "$PS_COMMAND" && test -n "$PS_FORMAT" && test -n "$PS_COLS" && test -n "$PS_VARLIST"; then
533 ac_cv_ps_command="$PS_COMMAND" 551 ac_cv_ps_command="$PS_COMMAND"
534 ac_cv_ps_format="$PS_FORMAT" 552 ac_cv_ps_format="$PS_FORMAT"
535 ac_cv_ps_varlist="$PS_VARLIST" 553 ac_cv_ps_varlist="$PS_VARLIST"
@@ -603,7 +621,7 @@ then
603 ac_cv_ps_cols=9 621 ac_cv_ps_cols=9
604 AC_MSG_RESULT([$ac_cv_ps_command]) 622 AC_MSG_RESULT([$ac_cv_ps_command])
605 623
606dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4. 624dnl Some *BSDs have different format for ps. This is mainly to catch FreeBSD 4.
607dnl Limitation: Only first 16 chars returned for ucomm field 625dnl Limitation: Only first 16 chars returned for ucomm field
608dnl Must come before ps -weo 626dnl Must come before ps -weo
609elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \ 627elif ps -axwo 'stat uid pid ppid vsz rss pcpu ucomm command' 2>/dev/null | \
@@ -680,9 +698,9 @@ then
680 ac_cv_ps_cols=9 698 ac_cv_ps_cols=9
681 AC_MSG_RESULT([$ac_cv_ps_command]) 699 AC_MSG_RESULT([$ac_cv_ps_command])
682 700
683dnl Tru64 - needs %*[ +<>] in PS_FORMAT. 701dnl Tru64 - needs %*[ +<>] in PS_FORMAT.
684dnl Has /usr/bin/ps and /sbin/ps - force sbin version 702dnl Has /usr/bin/ps and /sbin/ps - force sbin version
685dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead 703dnl Can't use vsize and rssize because comes back with text (eg, 1.5M instead
686dnl of 1500). Will need big changes to check_procs to support 704dnl of 1500). Will need big changes to check_procs to support
687elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \ 705elif /sbin/ps -eo 'stat uid pid ppid pcpu etime comm args' 2>/dev/null | \
688 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null 706 egrep -i ["^ *S +[UID]+ +[PID]+ +[PID]+ +[%CPU]+ +[ELAPSD]+ +[COMMAND]+ +[COMMAND]+"] > /dev/null
@@ -808,7 +826,7 @@ then
808 ac_cv_ps_cols=8 826 ac_cv_ps_cols=8
809 AC_MSG_RESULT([$ac_cv_ps_command]) 827 AC_MSG_RESULT([$ac_cv_ps_command])
810 828
811dnl UnixWare 829dnl UnixWare
812elif ps -Al 2>/dev/null | \ 830elif ps -Al 2>/dev/null | \
813 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null 831 egrep -i ["^ *F +S +UID +PID +PPID +CLS +PRI +NI +C +ADDR +SZ +WCHAN +TTY +TIME +COMD"] >/dev/null
814then 832then
@@ -1173,7 +1191,7 @@ fi
1173AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient) 1191AC_PATH_PROG(PATH_TO_SMBCLIENT,smbclient)
1174AC_ARG_WITH(smbclient_command, 1192AC_ARG_WITH(smbclient_command,
1175 ACX_HELP_STRING([--with-smbclient-command=PATH], 1193 ACX_HELP_STRING([--with-smbclient-command=PATH],
1176 [sets path to smbclient]), 1194 [sets path to smbclient]),
1177 PATH_TO_SMBCLIENT=$withval) 1195 PATH_TO_SMBCLIENT=$withval)
1178if test -n "$PATH_TO_SMBCLIENT" 1196if test -n "$PATH_TO_SMBCLIENT"
1179then 1197then
@@ -1229,7 +1247,7 @@ fi
1229AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat) 1247AC_PATH_PROG(PATH_TO_QUAKESTAT,quakestat)
1230AC_PATH_PROG(PATH_TO_QSTAT,qstat) 1248AC_PATH_PROG(PATH_TO_QSTAT,qstat)
1231AC_ARG_WITH(qstat_command, 1249AC_ARG_WITH(qstat_command,
1232 ACX_HELP_STRING([--with-qstat-command=PATH], 1250 ACX_HELP_STRING([--with-qstat-command=PATH],
1233 [Path to qstat command]), PATH_TO_QSTAT=$withval) 1251 [Path to qstat command]), PATH_TO_QSTAT=$withval)
1234 1252
1235if test -x "$PATH_TO_QUAKESTAT" 1253if test -x "$PATH_TO_QUAKESTAT"
@@ -1245,7 +1263,7 @@ else
1245 AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin]) 1263 AC_MSG_WARN([Get qstat from http://www.activesw.com/people/steve/qstat.html in order to make check_game plugin])
1246fi 1264fi
1247 1265
1248if test $ac_cv_path_to_qstat 1266if test $ac_cv_path_to_qstat
1249then 1267then
1250 AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat", 1268 AC_DEFINE_UNQUOTED(PATH_TO_QSTAT,"$ac_cv_path_to_qstat",
1251 [path to qstat/quakestat]) 1269 [path to qstat/quakestat])
@@ -1404,12 +1422,12 @@ AC_CHECK_MEMBERS([struct swapent.se_nblks],,,[
1404 #include <sys/swap.h> 1422 #include <sys/swap.h>
1405 ]) 1423 ])
1406 1424
1407if test "$ac_cv_have_decl_swapctl" = "yes"; 1425if test "$ac_cv_have_decl_swapctl" = "yes";
1408then 1426then
1409 EXTRAS="$EXTRAS check_swap" 1427 EXTRAS="$EXTRAS check_swap"
1410 AC_MSG_CHECKING([for 2-arg (SVR4) swapctl]) 1428 AC_MSG_CHECKING([for 2-arg (SVR4) swapctl])
1411 if test "$ac_cv_type_swaptbl_t" = "yes" -a \ 1429 if test "$ac_cv_type_swaptbl_t" = "yes" -a \
1412 "$ac_cv_type_swapent_t" = "yes"; 1430 "$ac_cv_type_swapent_t" = "yes";
1413 then 1431 then
1414 AC_MSG_RESULT([yes]) 1432 AC_MSG_RESULT([yes])
1415 ac_cv_check_swap_swapctl_svr4="1"; 1433 ac_cv_check_swap_swapctl_svr4="1";
@@ -1418,7 +1436,7 @@ then
1418 else 1436 else
1419 AC_MSG_RESULT([no]) 1437 AC_MSG_RESULT([no])
1420 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl]) 1438 AC_MSG_CHECKING([for 3-arg (*BSD) swapctl])
1421 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes"; 1439 if test "$ac_cv_member_struct_swapent_se_nblks" = "yes";
1422 then 1440 then
1423 AC_MSG_RESULT([yes]) 1441 AC_MSG_RESULT([yes])
1424 AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1, 1442 AC_DEFINE([CHECK_SWAP_SWAPCTL_BSD],1,
@@ -1459,12 +1477,12 @@ dnl end tests for the swapctl system calls
1459dnl 1477dnl
1460 1478
1461 1479
1462if test "x$ac_cv_have_swap" != "x" 1480if test "x$ac_cv_have_swap" != "x"
1463then 1481then
1464 AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found]) 1482 AC_DEFINE(HAVE_SWAP,1,[Define if swap/swapinfo command is found])
1465 EXTRAS="$EXTRAS check_swap" 1483 EXTRAS="$EXTRAS check_swap"
1466fi 1484fi
1467if test "x$ac_cv_swap_command" != "x" 1485if test "x$ac_cv_swap_command" != "x"
1468then 1486then
1469 AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command", 1487 AC_DEFINE_UNQUOTED(SWAP_COMMAND,"$ac_cv_swap_command",
1470 [Path to swap/swapinfo binary, with any args]) 1488 [Path to swap/swapinfo binary, with any args])
@@ -1509,7 +1527,7 @@ fi
1509AC_PATH_PROG(PATH_TO_APTGET,apt-get) 1527AC_PATH_PROG(PATH_TO_APTGET,apt-get)
1510AC_ARG_WITH(apt-get_command, 1528AC_ARG_WITH(apt-get_command,
1511 ACX_HELP_STRING([--with-apt-get-command=PATH], 1529 ACX_HELP_STRING([--with-apt-get-command=PATH],
1512 [Path to apt-get command]), 1530 [Path to apt-get command]),
1513 with_apt_get_command=$withval, 1531 with_apt_get_command=$withval,
1514 with_apt_get_command=$PATH_TO_APTGET) 1532 with_apt_get_command=$PATH_TO_APTGET)
1515AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present]) 1533AC_DEFINE_UNQUOTED(PATH_TO_APTGET,"$PATH_TO_APTGET",[Path to apt-get command, if present])
@@ -1538,7 +1556,7 @@ case $host in
1538 *sun* | *solaris*) 1556 *sun* | *solaris*)
1539 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c]) 1557 AC_DEFINE(__sun__,1,[sun specific code in check_dhcp.c])
1540 ;; 1558 ;;
1541 *hpux*) 1559 *hpux*)
1542 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c]) 1560 AC_DEFINE(__hpux__,1,[hpux specific code in check_dhcp.c])
1543 ;; 1561 ;;
1544esac 1562esac
@@ -1558,8 +1576,8 @@ dnl 2.6.9-11 (okay in 2.6.9-5). Redhat investigating root cause
1558dnl We patch plugins/popen.c 1576dnl We patch plugins/popen.c
1559dnl Need to add smp because uname different on those 1577dnl Need to add smp because uname different on those
1560dnl Can force patch to be applied with --enable-redhat-pthread-workaround 1578dnl Can force patch to be applied with --enable-redhat-pthread-workaround
1561AC_ARG_ENABLE(redhat-pthread-workaround, 1579AC_ARG_ENABLE(redhat-pthread-workaround,
1562 AC_HELP_STRING([--enable-redhat-pthread-workaround], 1580 AC_HELP_STRING([--enable-redhat-pthread-workaround],
1563 [force Redhat patch to be applied (default: test system)]), 1581 [force Redhat patch to be applied (default: test system)]),
1564 [ac_cv_enable_redhat_pthread_workaround=$enableval], 1582 [ac_cv_enable_redhat_pthread_workaround=$enableval],
1565 [ac_cv_enable_redhat_pthread_workaround=test]) 1583 [ac_cv_enable_redhat_pthread_workaround=test])
@@ -1581,7 +1599,7 @@ fi
1581 1599
1582dnl Perl modules 1600dnl Perl modules
1583AC_ARG_ENABLE(perl-modules, 1601AC_ARG_ENABLE(perl-modules,
1584 AC_HELP_STRING([--enable-perl-modules], 1602 AC_HELP_STRING([--enable-perl-modules],
1585 [Enables installation of Nagios::Plugin and its dependencies (default: no)]), 1603 [Enables installation of Nagios::Plugin and its dependencies (default: no)]),
1586 [enable_perl_modules=$enableval], 1604 [enable_perl_modules=$enableval],
1587 [enable_perl_modules=no]) 1605 [enable_perl_modules=no])
@@ -1589,6 +1607,18 @@ if test "$enable_perl_modules" = "yes" ; then
1589 AC_SUBST(PERLMODS_DIR,perlmods) 1607 AC_SUBST(PERLMODS_DIR,perlmods)
1590fi 1608fi
1591 1609
1610# From Tap configure
1611# Checks for libraries
1612case "$host" in
1613 *-*-*freebsd4*)
1614 LDFLAGS="$LDFLAGS -pthread"
1615 HAVE_LIBPTHREAD=1
1616 ;;
1617 *)
1618 AC_CHECK_LIB(pthread, main)
1619 ;;
1620esac
1621
1592dnl External libraries - see ACKNOWLEDGEMENTS 1622dnl External libraries - see ACKNOWLEDGEMENTS
1593gl_INIT 1623gl_INIT
1594 1624
@@ -1598,24 +1628,25 @@ if test "$ac_cv_uname_s" = 'SunOS' -a \( "x$ac_cv_prog_ac_ct_AR" = "x" -o "$ac_c
1598fi 1628fi
1599 1629
1600AC_OUTPUT( 1630AC_OUTPUT(
1601 Makefile 1631 Makefile
1602 lib/Makefile 1632 tap/Makefile
1603 plugins/Makefile 1633 lib/Makefile
1634 plugins/Makefile
1604 lib/tests/Makefile 1635 lib/tests/Makefile
1605 plugins-root/Makefile 1636 plugins-root/Makefile
1606 plugins-scripts/Makefile 1637 plugins-scripts/Makefile
1607 plugins-scripts/subst 1638 plugins-scripts/subst
1608 plugins-scripts/utils.pm 1639 plugins-scripts/utils.pm
1609 plugins-scripts/utils.sh 1640 plugins-scripts/utils.sh
1610 perlmods/Makefile 1641 perlmods/Makefile
1611 command.cfg 1642 command.cfg
1612 test.pl 1643 test.pl
1613 pkg/solaris/pkginfo 1644 pkg/solaris/pkginfo
1614 po/Makefile.in 1645 po/Makefile.in
1615) 1646)
1616 1647
1617 1648
1618dnl the ones below that are commented out need to be cleaned up 1649dnl the ones below that are commented out need to be cleaned up
1619dnl in the configure code above to use with_foo instead of ac_cv_foo 1650dnl in the configure code above to use with_foo instead of ac_cv_foo
1620dnl if we want them to show up here. it'd also make the code cleaner. 1651dnl if we want them to show up here. it'd also make the code cleaner.
1621dnl i'll get to that on another rainy day :) -sf 1652dnl i'll get to that on another rainy day :) -sf
@@ -1649,5 +1680,5 @@ ACX_FEATURE([with],[perl])
1649ACX_FEATURE([enable],[perl-modules]) 1680ACX_FEATURE([enable],[perl-modules])
1650ACX_FEATURE([with],[cgiurl]) 1681ACX_FEATURE([with],[cgiurl])
1651ACX_FEATURE([with],[trusted-path]) 1682ACX_FEATURE([with],[trusted-path])
1652 1683ACX_FEATURE([enable],[libtap])
1653 1684
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 25e2bed3..596d00fd 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -15,40 +15,49 @@ EXTRA_DIST = $(np_test_scripts) $(np_test_files)
15 15
16LIBS = @LIBINTL@ 16LIBS = @LIBINTL@
17 17
18if USE_LIBTAP_LOCAL
19tap_cflags = -I$(top_srcdir)/tap
20tap_ldflags = -L$(top_srcdir)/tap
21tap_ldadd = $(top_srcdir)/gl/libgnu.a
22else
23## Shouldn't we detect that??
24tap_ldflags = -L/usr/local/lib
25endif
26
18test_utils_SOURCES = test_utils.c 27test_utils_SOURCES = test_utils.c
19test_utils_CFLAGS = -g -I.. 28test_utils_CFLAGS = -g -I.. $(tap_cflags)
20test_utils_LDFLAGS = -L/usr/local/lib -ltap 29test_utils_LDFLAGS = $(tap_ldflags) -ltap
21test_utils_LDADD = ../utils_base.o 30test_utils_LDADD = ../utils_base.o $(tap_ldadd)
22 31
23test_disk_SOURCES = test_disk.c 32test_disk_SOURCES = test_disk.c
24test_disk_CFLAGS = -g -I.. 33test_disk_CFLAGS = -g -I.. $(tap_cflags)
25test_disk_LDFLAGS = -L/usr/local/lib -ltap 34test_disk_LDFLAGS = $(tap_ldflags) -ltap
26test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a 35test_disk_LDADD = ../utils_disk.o $(top_srcdir)/gl/libgnu.a
27 36
28test_tcp_SOURCES = test_tcp.c 37test_tcp_SOURCES = test_tcp.c
29test_tcp_CFLAGS = -g -I.. 38test_tcp_CFLAGS = -g -I.. $(tap_cflags)
30test_tcp_LDFLAGS = -L/usr/local/lib -ltap 39test_tcp_LDFLAGS = $(tap_ldflags) -ltap
31test_tcp_LDADD = ../utils_tcp.o 40test_tcp_LDADD = ../utils_tcp.o $(tap_ldadd)
32 41
33test_cmd_SOURCES = test_cmd.c 42test_cmd_SOURCES = test_cmd.c
34test_cmd_CFLAGS = -g -I.. 43test_cmd_CFLAGS = -g -I.. $(tap_cflags)
35test_cmd_LDFLAGS = -L/usr/local/lib -ltap 44test_cmd_LDFLAGS = $(tap_ldflags) -ltap
36test_cmd_LDADD = ../utils_cmd.o ../utils_base.o 45test_cmd_LDADD = ../utils_cmd.o ../utils_base.o $(tap_ldadd)
37 46
38test_base64_SOURCES = test_base64.c 47test_base64_SOURCES = test_base64.c
39test_base64_CFLAGS = -g -I.. 48test_base64_CFLAGS = -g -I.. $(tap_cflags)
40test_base64_LDFLAGS = -L/usr/local/lib -ltap 49test_base64_LDFLAGS = $(tap_ldflags) -ltap
41test_base64_LDADD = $(top_srcdir)/gl/base64.o 50test_base64_LDADD = $(top_srcdir)/gl/base64.o $(tap_ldadd)
42 51
43test_ini_SOURCES = test_ini.c 52test_ini_SOURCES = test_ini.c
44test_ini_CFLAGS = -g -I.. 53test_ini_CFLAGS = -g -I.. $(tap_cflags)
45test_ini_LDFLAGS = -L/usr/local/lib -ltap 54test_ini_LDFLAGS = $(tap_ldflags) -ltap
46test_ini_LDADD = ../utils_base.o ../parse_ini.o 55test_ini_LDADD = ../utils_base.o ../parse_ini.o $(tap_ldadd)
47 56
48test_opts_SOURCES = test_opts.c 57test_opts_SOURCES = test_opts.c
49test_opts_CFLAGS = -g -I.. 58test_opts_CFLAGS = -g -I.. $(tap_cflags)
50test_opts_LDFLAGS = -L/usr/local/lib -ltap 59test_opts_LDFLAGS = $(tap_ldflags) -ltap
51test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o 60test_opts_LDADD = ../utils_base.o ../parse_ini.o ../extra_opts.o $(tap_ldadd)
52 61
53test: ${noinst_PROGRAMS} 62test: ${noinst_PROGRAMS}
54 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) 63 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
diff --git a/tap/Makefile.am b/tap/Makefile.am
new file mode 100644
index 00000000..86147c5c
--- /dev/null
+++ b/tap/Makefile.am
@@ -0,0 +1,13 @@
1# Tap self-tests are not implemented (yet?)
2# SUBDIRS = tests
3
4if USE_LIBTAP_LOCAL
5noinst_LTLIBRARIES = libtap.la
6libtap_la_SOURCES = tap.c tap.h
7include_HEADERS = tap.h
8endif USE_LIBTAP_LOCAL
9
10# see top comment
11#prove:
12# prove -v -r
13
diff --git a/tap/README b/tap/README
new file mode 100644
index 00000000..6c15be0a
--- /dev/null
+++ b/tap/README
@@ -0,0 +1,11 @@
1NAME
2 tap -- write tests that implement the Test Anything Protocol
3
4SYNOPSIS
5 #include <tap.h>
6
7DESCRIPTION
8 The tap library provides functions for writing test scripts that produce
9 output consistent with the Test Anything Protocol. A test harness that
10 parses this protocol can run these tests and produce useful reports indi-
11 cating their success or failure.
diff --git a/tap/tap.3 b/tap/tap.3
new file mode 100644
index 00000000..4b23c24a
--- /dev/null
+++ b/tap/tap.3
@@ -0,0 +1,368 @@
1.Dd December 20, 2004
2.Os
3.Dt TAP 3
4.Sh NAME
5.Nm tap
6.Nd write tests that implement the Test Anything Protocol
7.Sh SYNOPSIS
8.In tap.h
9.Sh DESCRIPTION
10The
11.Nm
12library provides functions for writing test scripts that produce output
13consistent with the Test Anything Protocol. A test harness that parses
14this protocol can run these tests and produce useful reports indicating
15their success or failure.
16.Ss PRINTF STRINGS
17In the descriptions that follow, for any function that takes as the
18last two parameters
19.Dq Fa char * , Fa ...
20it can be assumed that the
21.Fa char *
22is a
23.Fn printf
24-like format string, and the optional arguments are values to be placed
25in that string.
26.Ss TEST PLANS
27.Bl -tag -width indent
28.It Xo
29.Ft int
30.Fn plan_tests "unsigned int"
31.Xc
32.It Xo
33.Ft int
34.Fn plan_no_plan "void"
35.Xc
36.It Xo
37.Ft int
38.Fn plan_skip_all "char *" "..."
39.Xc
40.El
41.Pp
42You must first specify a test plan. This indicates how many tests you
43intend to run, and allows the test harness to notice if any tests were
44missed, or if the test program exited prematurely.
45.Pp
46To do this, use
47.Fn plan_tests ,
48which always returns 0. The function will cause your program to exit
49prematurely if you specify 0 tests.
50.Pp
51In some situations you may not know how many tests you will be running, or
52you are developing your test program, and do not want to update the
53.Fn plan_tests
54parameter every time you make a change. For those situations use
55.Fn plan_no_plan .
56It returns 0, and indicates to the test harness that an indeterminate number
57of tests will be run.
58.Pp
59Both
60.Fn plan_tests
61and
62.Fn plan_no_plan
63will cause your test program to exit prematurely with a diagnostic
64message if they are called more than once.
65.Pp
66If your test program detects at run time that some required functionality
67is missing (for example, it relies on a database connection which is not
68present, or a particular configuration option that has not been included
69in the running kernel) use
70.Fn plan_skip_all ,
71passing as parameters a string to display indicating the reason for skipping
72the tests.
73.Ss SIMPLE TESTS
74.Bl -tag -width indent
75.It Xo
76.Ft unsigned int
77.Fn ok "expression" "char *" "..."
78.Xc
79.It Xo
80.Ft unsigned int
81.Fn ok1 "expression"
82.Xc
83.It Xo
84.Ft unsigned int
85.Fn pass "char *" "..."
86.Xc
87.It Xo
88.Ft unsigned int
89.Fn fail "char *" "..."
90.Xc
91.El
92.Pp
93Tests are implemented as expressions checked by calls to the
94.Fn ok
95and
96.Fn ok1
97macros. In both cases
98.Fa expression
99should evaluate to true if the test succeeded.
100.Pp
101.Fn ok
102allows you to specify a name, or comment, describing the test which will
103be included in the output.
104.Fn ok1
105is for those times when the expression to be tested is self
106explanatory and does not need an associated comment. In those cases
107the test expression becomes the comment.
108.Pp
109These four calls are equivalent:
110.Bd -literal -offset indent
111int i = 5;
112
113ok(i == 5, "i equals 5"); /* Overly verbose */
114ok(i == 5, "i equals %d", i); /* Just to demonstrate printf-like
115 behaviour of the test name */
116ok(i == 5, "i == 5"); /* Needless repetition */
117ok1(i == 5); /* Just right */
118.Ed
119.Pp
120It is good practice to ensure that the test name describes the meaning
121behind the test rather than what you are testing. Viz
122.Bd -literal -offset indent
123ok(db != NULL, "db is not NULL"); /* Not bad, but */
124ok(db != NULL, "Database conn. succeeded"); /* this is better */
125.Ed
126.Pp
127.Fn ok
128and
129.Fn ok1
130return 1 if the expression evaluated to true, and 0 if it evaluated to
131false. This lets you chain calls from
132.Fn ok
133to
134.Fn diag
135to only produce diagnostic output if the test failed. For example, this
136code will include diagnostic information about why the database connection
137failed, but only if the test failed.
138.Bd -literal -offset indent
139ok(db != NULL, "Database conn. succeeded") ||
140 diag("Database error code: %d", dberrno);
141.Ed
142.Pp
143You also have
144.Fn pass
145and
146.Fn fail .
147From the Test::More documentation:
148.Bd -literal -offset indent
149Sometimes you just want to say that the tests have passed.
150Usually the case is you've got some complicated condition
151that is difficult to wedge into an ok(). In this case,
152you can simply use pass() (to declare the test ok) or fail
153(for not ok).
154
155Use these very, very, very sparingly.
156.Ed
157.Pp
158These are synonyms for ok(1, ...) and ok(0, ...).
159.Ss SKIPPING TESTS
160.Bl -tag -width indent
161.It Xo
162.Ft int
163.Fn skip "unsigned int" "char *" "..."
164.Xc
165.It Xo
166.Fn skip_start "expression" "unsigned int" "char *" "..."
167.Xc
168.It Xo
169.Sy skip_end
170.Xc
171.El
172.Pp
173Sets of tests can be skipped. Ordinarily you would do this because
174the test can't be run in this particular testing environment.
175.Pp
176For example, suppose some tests should be run as root. If the test is
177not being run as root then the tests should be skipped. In this
178implementation, skipped tests are flagged as being ok, with a special
179message indicating that they were skipped. It is your responsibility
180to ensure that the number of tests skipped (the first parameter to
181.Fn skip )
182is correct for the number of tests to skip.
183.Pp
184One way of implementing this is with a
185.Dq do { } while(0);
186loop, or an
187.Dq if( ) { } else { }
188construct, to ensure that there are no additional side effects from the
189skipped tests.
190.Bd -literal -offset indent
191if(getuid() != 0) {
192 skip(1, "because test only works as root");
193} else {
194 ok(do_something_as_root() == 0, "Did something as root");
195}
196.Ed
197.Pp
198Two macros are provided to assist with this. The previous example could
199be re-written as follows.
200.Bd -literal -offset indent
201skip_start(getuid() != 0, 1, "because test only works as root");
202
203ok(do_something_as_root() == 0, "Did something as root");
204
205skip_end; /* It's a macro, no parentheses */
206.Ed
207.Ss MARKING TESTS AS Dq TODO
208.Bl -tag -width indent
209.It Xo
210.Ft void
211.Fn todo_start "char *" "..."
212.Xc
213.It Xo
214.Ft void
215.Fn todo_end "void"
216.Xc
217.El
218.Pp
219Sets of tests can be flagged as being
220.Dq TODO .
221These are tests that you expect to fail, probably because you haven't
222fixed a bug, or finished a new feature yet. These tests will still be
223run, but with additional output that indicates that they are expected
224to fail. Should a test start to succeed unexpectedly, tools like
225.Xr prove 1
226will indicate this, and you can move the test out of the todo
227block. This is much more useful than simply commenting out (or
228.Dq #ifdef 0 ... #endif )
229the tests.
230.Bd -literal -offset indent
231todo_start("dwim() not returning true yet");
232
233ok(dwim(), "Did what the user wanted");
234
235todo_end();
236.Ed
237.Pp
238Should
239.Fn dwim
240ever start succeeding you will know about it as soon as you run the
241tests. Note that
242.Em unlike
243the
244.Fn skip_*
245family, additional code between
246.Fn todo_start
247and
248.Fn todo_end
249.Em is
250executed.
251.Ss SKIP vs. TODO
252From the Test::More documentation;
253.Bd -literal -offset indent
254If it's something the user might not be able to do, use SKIP.
255This includes optional modules that aren't installed, running
256under an OS that doesn't have some feature (like fork() or
257symlinks), or maybe you need an Internet connection and one
258isn't available.
259
260If it's something the programmer hasn't done yet, use TODO.
261This is for any code you haven't written yet, or bugs you have
262yet to fix, but want to put tests in your testing script
263(always a good idea).
264.Ed
265.Ss DIAGNOSTIC OUTPUT
266.Bl -tag -width indent
267.It Xo
268.Fr unsigned int
269.Fn diag "char *" "..."
270.Xc
271.El
272.Pp
273If your tests need to produce diagnostic output, use
274.Fn diag .
275It ensures that the output will not be considered by the TAP test harness.
276.Fn diag
277adds the necessary trailing
278.Dq \en
279for you.
280.Bd -literal -offset indent
281diag("Expected return code 0, got return code %d", rcode);
282.Ed
283.Pp
284.Fn diag
285always returns 0.
286.Ss EXIT STATUS
287.Bl -tag -width indent
288.It Xo
289.Fr int
290.Fn exit_status void
291.Xc
292.El
293.Pp
294For maximum compatability your test program should return a particular
295exit code. This is calculated by
296.Fn exit_status
297so it is sufficient to always return from
298.Fn main
299with either
300.Dq return exit_status();
301or
302.Dq exit(exit_status());
303as appropriate.
304.Sh EXAMPLES
305The
306.Pa tests
307directory in the source distribution contains numerous tests of
308.Nm
309functionality, written using
310.Nm .
311Examine them for examples of how to construct test suites.
312.Sh COMPATABILITY
313.Nm
314strives to be compatible with the Perl Test::More and Test::Harness
315modules. The test suite verifies that
316.Nm
317is bug-for-bug compatible with their behaviour. This is why some
318functions which would more naturally return nothing return constant
319values.
320.Pp
321If the
322.Lb libpthread
323is found at compile time,
324.Nm
325.Em should
326be thread safe. Indications to the contrary (and test cases that expose
327incorrect behaviour) are very welcome.
328.Sh SEE ALSO
329.Xr Test::More 1 ,
330.Xr Test::Harness 1 ,
331.Xr prove 1
332.Sh STANDARDS
333.Nm
334requires a
335.St -isoC-99
336compiler. Some of the
337.Nm
338functionality is implemented as variadic macros, and that functionality
339was not formally codified until C99. Patches to use
340.Nm
341with earlier compilers that have their own implementation of variadic
342macros will be gratefully received.
343.Sh HISTORY
344.Nm
345was written to help improve the quality and coverage of the FreeBSD
346regression test suite, and released in the hope that others find it
347a useful tool to help improve the quality of their code.
348.Sh AUTHORS
349.An "Nik Clayton" Aq nik@ngo.org.uk ,
350.Aq nik@FreeBSD.org
351.Pp
352.Nm
353would not exist without the efforts of
354.An "Michael G Schwern" Aq schqern@pobox.com ,
355.An "Andy Lester" Aq andy@petdance.com ,
356and the countless others who have worked on the Perl QA programme.
357.Sh BUGS
358Ideally, running the tests would have no side effects on the behaviour
359of the application you are testing. However, it is not always possible
360to avoid them. The following side effects of using
361.Nm
362are known.
363.Bl -bullet -offset indent
364.It
365stdout is set to unbuffered mode after calling any of the
366.Fn plan_*
367functions.
368.El
diff --git a/tap/tap.c b/tap/tap.c
new file mode 100644
index 00000000..97c20e96
--- /dev/null
+++ b/tap/tap.c
@@ -0,0 +1,435 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <ctype.h>
28#include <stdarg.h>
29#include <stdio.h>
30#include <stdlib.h>
31
32#include "tap.h"
33
34static int no_plan = 0;
35static int skip_all = 0;
36static int have_plan = 0;
37static unsigned int test_count = 0; /* Number of tests that have been run */
38static unsigned int e_tests = 0; /* Expected number of tests to run */
39static unsigned int failures = 0; /* Number of tests that failed */
40static char *todo_msg = NULL;
41static char *todo_msg_fixed = "libtap malloc issue";
42static int todo = 0;
43static int test_died = 0;
44
45/* Encapsulate the pthread code in a conditional. In the absence of
46 libpthread the code does nothing */
47#ifdef HAVE_LIBPTHREAD
48#include <pthread.h>
49static pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER;
50# define LOCK pthread_mutex_lock(&M);
51# define UNLOCK pthread_mutex_unlock(&M);
52#else
53# define LOCK
54# define UNLOCK
55#endif
56
57static void _expected_tests(unsigned int);
58static void _tap_init(void);
59static void _cleanup(void);
60
61/*
62 * Generate a test result.
63 *
64 * ok -- boolean, indicates whether or not the test passed.
65 * test_name -- the name of the test, may be NULL
66 * test_comment -- a comment to print afterwards, may be NULL
67 */
68unsigned int
69_gen_result(int ok, const char *func, char *file, unsigned int line,
70 char *test_name, ...)
71{
72 va_list ap;
73 char *local_test_name = NULL;
74 char *c;
75 int name_is_digits;
76
77 LOCK;
78
79 test_count++;
80
81 /* Start by taking the test name and performing any printf()
82 expansions on it */
83 if(test_name != NULL) {
84 va_start(ap, test_name);
85 vasprintf(&local_test_name, test_name, ap);
86 va_end(ap);
87
88 /* Make sure the test name contains more than digits
89 and spaces. Emit an error message and exit if it
90 does */
91 if(local_test_name) {
92 name_is_digits = 1;
93 for(c = local_test_name; *c != '\0'; c++) {
94 if(!isdigit(*c) && !isspace(*c)) {
95 name_is_digits = 0;
96 break;
97 }
98 }
99
100 if(name_is_digits) {
101 diag(" You named your test '%s'. You shouldn't use numbers for your test names.", local_test_name);
102 diag(" Very confusing.");
103 }
104 }
105 }
106
107 if(!ok) {
108 printf("not ");
109 failures++;
110 }
111
112 printf("ok %d", test_count);
113
114 if(test_name != NULL) {
115 printf(" - ");
116
117 /* Print the test name, escaping any '#' characters it
118 might contain */
119 if(local_test_name != NULL) {
120 flockfile(stdout);
121 for(c = local_test_name; *c != '\0'; c++) {
122 if(*c == '#')
123 fputc('\\', stdout);
124 fputc((int)*c, stdout);
125 }
126 funlockfile(stdout);
127 } else { /* vasprintf() failed, use a fixed message */
128 printf("%s", todo_msg_fixed);
129 }
130 }
131
132 /* If we're in a todo_start() block then flag the test as being
133 TODO. todo_msg should contain the message to print at this
134 point. If it's NULL then asprintf() failed, and we should
135 use the fixed message.
136
137 This is not counted as a failure, so decrement the counter if
138 the test failed. */
139 if(todo) {
140 printf(" # TODO %s", todo_msg ? todo_msg : todo_msg_fixed);
141 if(!ok)
142 failures--;
143 }
144
145 printf("\n");
146
147 if(!ok)
148 diag(" Failed %stest (%s:%s() at line %d)",
149 todo ? "(TODO) " : "", file, func, line);
150
151 free(local_test_name);
152
153 UNLOCK;
154
155 /* We only care (when testing) that ok is positive, but here we
156 specifically only want to return 1 or 0 */
157 return ok ? 1 : 0;
158}
159
160/*
161 * Initialise the TAP library. Will only do so once, however many times it's
162 * called.
163 */
164void
165_tap_init(void)
166{
167 static int run_once = 0;
168
169 LOCK;
170
171 if(!run_once) {
172 atexit(_cleanup);
173
174 /* stdout needs to be unbuffered so that the output appears
175 in the same place relative to stderr output as it does
176 with Test::Harness */
177 setbuf(stdout, 0);
178 run_once = 1;
179 }
180
181 UNLOCK;
182}
183
184/*
185 * Note that there's no plan.
186 */
187int
188plan_no_plan(void)
189{
190
191 LOCK;
192
193 _tap_init();
194
195 if(have_plan != 0) {
196 fprintf(stderr, "You tried to plan twice!\n");
197 test_died = 1;
198 UNLOCK;
199 exit(255);
200 }
201
202 have_plan = 1;
203 no_plan = 1;
204
205 UNLOCK;
206
207 return 0;
208}
209
210/*
211 * Note that the plan is to skip all tests
212 */
213int
214plan_skip_all(char *reason)
215{
216
217 LOCK;
218
219 _tap_init();
220
221 skip_all = 1;
222
223 printf("1..0");
224
225 if(reason != NULL)
226 printf(" # Skip %s", reason);
227
228 printf("\n");
229
230 UNLOCK;
231
232 exit(0);
233}
234
235/*
236 * Note the number of tests that will be run.
237 */
238int
239plan_tests(unsigned int tests)
240{
241
242 LOCK;
243
244 _tap_init();
245
246 if(have_plan != 0) {
247 fprintf(stderr, "You tried to plan twice!\n");
248 test_died = 1;
249 UNLOCK;
250 exit(255);
251 }
252
253 if(tests == 0) {
254 fprintf(stderr, "You said to run 0 tests! You've got to run something.\n");
255 test_died = 1;
256 UNLOCK;
257 exit(255);
258 }
259
260 have_plan = 1;
261
262 _expected_tests(tests);
263
264 UNLOCK;
265
266 return 0;
267}
268
269unsigned int
270diag(char *fmt, ...)
271{
272 va_list ap;
273
274 LOCK;
275
276 fputs("# ", stderr);
277
278 va_start(ap, fmt);
279 vfprintf(stderr, fmt, ap);
280 va_end(ap);
281
282 fputs("\n", stderr);
283
284 UNLOCK;
285
286 return 0;
287}
288
289void
290_expected_tests(unsigned int tests)
291{
292
293 LOCK;
294
295 printf("1..%d\n", tests);
296 e_tests = tests;
297
298 UNLOCK;
299}
300
301int
302skip(unsigned int n, char *fmt, ...)
303{
304 va_list ap;
305 char *skip_msg;
306
307 LOCK;
308
309 va_start(ap, fmt);
310 asprintf(&skip_msg, fmt, ap);
311 va_end(ap);
312
313 while(n-- > 0) {
314 test_count++;
315 printf("ok %d # skip %s\n", test_count,
316 skip_msg != NULL ?
317 skip_msg : "libtap():malloc() failed");
318 }
319
320 free(skip_msg);
321
322 UNLOCK;
323
324 return 1;
325}
326
327void
328todo_start(char *fmt, ...)
329{
330 va_list ap;
331
332 LOCK;
333
334 va_start(ap, fmt);
335 vasprintf(&todo_msg, fmt, ap);
336 va_end(ap);
337
338 todo = 1;
339
340 UNLOCK;
341}
342
343void
344todo_end(void)
345{
346
347 LOCK;
348
349 todo = 0;
350 free(todo_msg);
351
352 UNLOCK;
353}
354
355int
356exit_status(void)
357{
358 int r;
359
360 LOCK;
361
362 /* If there's no plan, just return the number of failures */
363 if(no_plan || !have_plan) {
364 UNLOCK;
365 return failures;
366 }
367
368 /* Ran too many tests? Return the number of tests that were run
369 that shouldn't have been */
370 if(e_tests < test_count) {
371 r = test_count - e_tests;
372 UNLOCK;
373 return r;
374 }
375
376 /* Return the number of tests that failed + the number of tests
377 that weren't run */
378 r = failures + e_tests - test_count;
379 UNLOCK;
380
381 return r;
382}
383
384/*
385 * Cleanup at the end of the run, produce any final output that might be
386 * required.
387 */
388void
389_cleanup(void)
390{
391
392 LOCK;
393
394 /* If plan_no_plan() wasn't called, and we don't have a plan,
395 and we're not skipping everything, then something happened
396 before we could produce any output */
397 if(!no_plan && !have_plan && !skip_all) {
398 diag("Looks like your test died before it could output anything.");
399 UNLOCK;
400 return;
401 }
402
403 if(test_died) {
404 diag("Looks like your test died just after %d.", test_count);
405 UNLOCK;
406 return;
407 }
408
409
410 /* No plan provided, but now we know how many tests were run, and can
411 print the header at the end */
412 if(!skip_all && (no_plan || !have_plan)) {
413 printf("1..%d\n", test_count);
414 }
415
416 if((have_plan && !no_plan) && e_tests < test_count) {
417 diag("Looks like you planned %d tests but ran %d extra.",
418 e_tests, test_count - e_tests);
419 UNLOCK;
420 return;
421 }
422
423 if((have_plan || !no_plan) && e_tests > test_count) {
424 diag("Looks like you planned %d tests but only ran %d.",
425 e_tests, test_count);
426 UNLOCK;
427 return;
428 }
429
430 if(failures)
431 diag("Looks like you failed %d tests of %d.",
432 failures, test_count);
433
434 UNLOCK;
435}
diff --git a/tap/tap.h b/tap/tap.h
new file mode 100644
index 00000000..e64f9d5f
--- /dev/null
+++ b/tap/tap.h
@@ -0,0 +1,89 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
28 and requires the caller to add the final comma if they've ommitted
29 the optional arguments */
30#ifdef __GNUC__
31# define ok(e, test, ...) ((e) ? \
32 _gen_result(1, __func__, __FILE__, __LINE__, \
33 test, ## __VA_ARGS__) : \
34 _gen_result(0, __func__, __FILE__, __LINE__, \
35 test, ## __VA_ARGS__))
36
37# define ok1(e) ((e) ? \
38 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
39 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
40
41# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
42# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
43
44# define skip_start(test, n, fmt, ...) \
45 do { \
46 if((test)) { \
47 skip(n, fmt, ## __VA_ARGS__); \
48 continue; \
49 }
50#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
51# define ok(e, ...) ((e) ? \
52 _gen_result(1, __func__, __FILE__, __LINE__, \
53 __VA_ARGS__) : \
54 _gen_result(0, __func__, __FILE__, __LINE__, \
55 __VA_ARGS__))
56
57# define ok1(e) ((e) ? \
58 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
59 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
60
61# define pass(...) ok(1, __VA_ARGS__);
62# define fail(...) ok(0, __VA_ARGS__);
63
64# define skip_start(test, n, ...) \
65 do { \
66 if((test)) { \
67 skip(n, __VA_ARGS__); \
68 continue; \
69 }
70#else /* __STDC_VERSION__ */
71# error "Needs gcc or C99 compiler for variadic macros."
72#endif /* __STDC_VERSION__ */
73
74# define skip_end } while(0);
75
76unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
77
78int plan_no_plan(void);
79int plan_skip_all(char *);
80int plan_tests(unsigned int);
81
82unsigned int diag(char *, ...);
83
84int skip(unsigned int, char *, ...);
85
86void todo_start(char *, ...);
87void todo_end(void);
88
89int exit_status(void);
diff --git a/tap/tests/Makefile.am b/tap/tests/Makefile.am
new file mode 100644
index 00000000..481a9672
--- /dev/null
+++ b/tap/tests/Makefile.am
@@ -0,0 +1,7 @@
1SUBDIRS= diag
2SUBDIRS+= fail
3SUBDIRS+= ok
4SUBDIRS+= pass
5SUBDIRS+= plan
6SUBDIRS+= skip
7SUBDIRS+= todo
diff --git a/tap/tests/README b/tap/tests/README
new file mode 100644
index 00000000..a15fec28
--- /dev/null
+++ b/tap/tests/README
@@ -0,0 +1,12 @@
1Most of the tests follow the same pattern.
2
3 * test.pl that uses Test::More, and demonstrates whatever functionality
4 that we're trying to test. This is the reference code.
5
6 * test.c, which tests the libtap reimplementation of the same functionality.
7
8 * test.t, which compiles the .c program, runs both test scripts, and then
9 diffs their output to make sure it's identical.
10
11 Right now, test.t is identical in every directory. This sucks somewhat.
12 It should either be a symlink to a common script
diff --git a/tap/tests/diag/Makefile.am b/tap/tests/diag/Makefile.am
new file mode 100644
index 00000000..c1ccb751
--- /dev/null
+++ b/tap/tests/diag/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../src
10test_LDFLAGS = -L../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/diag/test.c b/tap/tests/diag/test.c
new file mode 100644
index 00000000..401db647
--- /dev/null
+++ b/tap/tests/diag/test.c
@@ -0,0 +1,46 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 plan_tests(2);
37
38 rc = diag("A diagnostic message");
39 diag("Returned: %d", rc);
40
41 /* Make sure the failure is passed through */
42 ok(1, "test 1") || diag("ok() failed, and shouldn't");
43 ok(0, "test 2") || diag("ok() passed, and shouldn't");
44
45 return exit_status();
46}
diff --git a/tap/tests/diag/test.pl b/tap/tests/diag/test.pl
new file mode 100644
index 00000000..621dc27d
--- /dev/null
+++ b/tap/tests/diag/test.pl
@@ -0,0 +1,16 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10plan tests => 2;
11
12$rc = diag("A diagnostic message");
13diag("Returned: $rc");
14
15ok(1, 'test 1') or diag "ok() failed, and shouldn't";
16ok(0, 'test 2') or diag "ok() passed, and shouldn't";
diff --git a/tap/tests/diag/test.t b/tap/tests/diag/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/diag/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/fail/Makefile.am b/tap/tests/fail/Makefile.am
new file mode 100644
index 00000000..c1ccb751
--- /dev/null
+++ b/tap/tests/fail/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../src
10test_LDFLAGS = -L../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/fail/test.c b/tap/tests/fail/test.c
new file mode 100644
index 00000000..621b6c29
--- /dev/null
+++ b/tap/tests/fail/test.c
@@ -0,0 +1,46 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(2);
37 diag("Returned: %d", rc);
38
39 rc = fail("test to fail");
40 diag("Returned: %d", rc);
41
42 rc = fail("test to fail %s", "with extra string");
43 diag("Returned: %d", rc);
44
45 return exit_status();
46}
diff --git a/tap/tests/fail/test.pl b/tap/tests/fail/test.pl
new file mode 100644
index 00000000..73de1a7b
--- /dev/null
+++ b/tap/tests/fail/test.pl
@@ -0,0 +1,17 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 2;
11diag("Returned: " . sprintf('%d', $rc));
12
13$rc = fail('test to fail');
14diag("Returned: $rc");
15
16$rc = fail('test to fail with extra string');
17diag("Returned: $rc");
diff --git a/tap/tests/fail/test.t b/tap/tests/fail/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/fail/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/ok/Makefile.am b/tap/tests/ok/Makefile.am
new file mode 100644
index 00000000..c9497480
--- /dev/null
+++ b/tap/tests/ok/Makefile.am
@@ -0,0 +1,3 @@
1SUBDIRS = ok
2SUBDIRS += ok-hash
3SUBDIRS += ok-numeric
diff --git a/tap/tests/ok/ok-hash/Makefile.am b/tap/tests/ok/ok-hash/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/ok/ok-hash/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/ok/ok-hash/test.c b/tap/tests/ok/ok-hash/test.c
new file mode 100644
index 00000000..16be137a
--- /dev/null
+++ b/tap/tests/ok/ok-hash/test.c
@@ -0,0 +1,52 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(4);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, "Test with no hash");
40 diag("Returned: %d", rc);
41
42 rc = ok(1, "Test with one # hash");
43 diag("Returned: %d", rc);
44
45 rc = ok(1, "Test with # two # hashes");
46 diag("Returned: %d", rc);
47
48 rc = ok(1, "Test with ## back to back hashes");
49 diag("Returned: %d", rc);
50
51 return exit_status();
52}
diff --git a/tap/tests/ok/ok-hash/test.pl b/tap/tests/ok/ok-hash/test.pl
new file mode 100644
index 00000000..306ddca0
--- /dev/null
+++ b/tap/tests/ok/ok-hash/test.pl
@@ -0,0 +1,24 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 4;
11diag("Returned: " . sprintf("%d", $rc));
12
13
14$rc = ok(1, 'Test with no hash');
15diag("Returned: $rc");
16
17$rc = ok(1, 'Test with one # hash');
18diag("Returned: $rc");
19
20$rc = ok(1, 'Test with # two # hashes');
21diag("Returned: $rc");
22
23$rc = ok(1, 'Test with ## back to back hashes');
24diag("Returned: $rc");
diff --git a/tap/tests/ok/ok-hash/test.t b/tap/tests/ok/ok-hash/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/ok/ok-hash/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/ok/ok-numeric/Makefile.am b/tap/tests/ok/ok-numeric/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/ok/ok-numeric/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/ok/ok-numeric/test.c b/tap/tests/ok/ok-numeric/test.c
new file mode 100644
index 00000000..0e33a748
--- /dev/null
+++ b/tap/tests/ok/ok-numeric/test.c
@@ -0,0 +1,49 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(3);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, "First test");
40 diag("Returned: %d", rc);
41
42 rc = ok(1, "1");
43 diag("Returned: %d", rc);
44
45 rc = ok(1, "Third test");
46 diag("Returned: %d", rc);
47
48 return exit_status();
49}
diff --git a/tap/tests/ok/ok-numeric/test.pl b/tap/tests/ok/ok-numeric/test.pl
new file mode 100644
index 00000000..86f165f2
--- /dev/null
+++ b/tap/tests/ok/ok-numeric/test.pl
@@ -0,0 +1,21 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 3;
11diag("Returned: " . sprintf("%d", $rc));
12
13
14$rc = ok(1, 'First test');
15diag("Returned: $rc");
16
17$rc = ok(1, '1');
18diag("Returned: $rc");
19
20$rc = ok(1, 'Third test');
21diag("Returned: $rc");
diff --git a/tap/tests/ok/ok-numeric/test.t b/tap/tests/ok/ok-numeric/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/ok/ok-numeric/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/ok/ok/Makefile.am b/tap/tests/ok/ok/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/ok/ok/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/ok/ok/test.c b/tap/tests/ok/ok/test.c
new file mode 100644
index 00000000..ae04f2e4
--- /dev/null
+++ b/tap/tests/ok/ok/test.c
@@ -0,0 +1,55 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(5);
37 diag("Returned: %d", rc);
38
39 rc = ok(1 == 1, "1 equals 1");
40 diag("Returned: %d", rc);
41
42 rc = ok(1 == 1, "1 equals %d", 1);
43 diag("Returned: %d", rc);
44
45 rc = ok1(1 == 1);
46 diag("Returned: %d", rc);
47
48 rc = ok(1 == 2, "1 equals 2");
49 diag("Returned: %d", rc);
50
51 rc = ok1(1 == 2);
52 diag("Returned: %d", rc);
53
54 return exit_status();
55}
diff --git a/tap/tests/ok/ok/test.pl b/tap/tests/ok/ok/test.pl
new file mode 100644
index 00000000..59f41819
--- /dev/null
+++ b/tap/tests/ok/ok/test.pl
@@ -0,0 +1,27 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 5;
11diag("Returned: " . sprintf("%d", $rc));
12
13
14$rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should
15diag("Returned: $rc");
16
17$rc = ok(1 == 1, '1 equals 1'); # Used for %d testing in test.c
18diag("Returned: $rc");
19
20$rc = ok(1 == 1, '1 == 1'); # Test ok1() passes when it should
21diag("Returned: $rc");
22
23$rc = ok(1 == 2, '1 equals 2'); # Test ok() fails when it should
24diag("Returned: $rc");
25
26$rc = ok(1 == 2, '1 == 2'); # Test ok1() fails when it should
27diag("Returned: $rc");
diff --git a/tap/tests/ok/ok/test.t b/tap/tests/ok/ok/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/ok/ok/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/pass/Makefile.am b/tap/tests/pass/Makefile.am
new file mode 100644
index 00000000..c1ccb751
--- /dev/null
+++ b/tap/tests/pass/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../src
10test_LDFLAGS = -L../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/pass/test.c b/tap/tests/pass/test.c
new file mode 100644
index 00000000..39d8a7c1
--- /dev/null
+++ b/tap/tests/pass/test.c
@@ -0,0 +1,46 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(2);
37 diag("Returned: %d", rc);
38
39 rc = pass("test to pass");
40 diag("Returned: %d", rc);
41
42 rc = pass("test to pass %s", "with extra string");
43 diag("Returned: %d", rc);
44
45 return exit_status();
46}
diff --git a/tap/tests/pass/test.pl b/tap/tests/pass/test.pl
new file mode 100644
index 00000000..8abc92e7
--- /dev/null
+++ b/tap/tests/pass/test.pl
@@ -0,0 +1,17 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 2;
11diag("Returned: " . sprintf('%d', $rc));
12
13$rc = pass('test to pass');
14diag("Returned: $rc");
15
16$rc = pass('test to pass with extra string');
17diag("Returned: $rc");
diff --git a/tap/tests/pass/test.t b/tap/tests/pass/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/pass/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/Makefile.am b/tap/tests/plan/Makefile.am
new file mode 100644
index 00000000..0724931a
--- /dev/null
+++ b/tap/tests/plan/Makefile.am
@@ -0,0 +1,7 @@
1SUBDIRS = no-tests
2SUBDIRS += no_plan
3SUBDIRS += not-enough-tests
4SUBDIRS += too-many-plans
5SUBDIRS += too-many-tests
6SUBDIRS += sane
7SUBDIRS += skip_all
diff --git a/tap/tests/plan/no-tests/Makefile.am b/tap/tests/plan/no-tests/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/no-tests/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/no-tests/test.c b/tap/tests/plan/no-tests/test.c
new file mode 100644
index 00000000..78c5d371
--- /dev/null
+++ b/tap/tests/plan/no-tests/test.c
@@ -0,0 +1,43 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(0);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 return exit_status();
43}
diff --git a/tap/tests/plan/no-tests/test.pl b/tap/tests/plan/no-tests/test.pl
new file mode 100644
index 00000000..93d2b3b8
--- /dev/null
+++ b/tap/tests/plan/no-tests/test.pl
@@ -0,0 +1,14 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 0;
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
diff --git a/tap/tests/plan/no-tests/test.t b/tap/tests/plan/no-tests/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/no-tests/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/no_plan/Makefile.am b/tap/tests/plan/no_plan/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/no_plan/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/no_plan/test.c b/tap/tests/plan/no_plan/test.c
new file mode 100644
index 00000000..5cffbdc2
--- /dev/null
+++ b/tap/tests/plan/no_plan/test.c
@@ -0,0 +1,43 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_no_plan();
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 return exit_status();
43}
diff --git a/tap/tests/plan/no_plan/test.pl b/tap/tests/plan/no_plan/test.pl
new file mode 100644
index 00000000..19e42b57
--- /dev/null
+++ b/tap/tests/plan/no_plan/test.pl
@@ -0,0 +1,14 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6my $rc = 0;
7
8use Test::More;
9
10$rc = plan qw(no_plan);
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
diff --git a/tap/tests/plan/no_plan/test.t b/tap/tests/plan/no_plan/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/no_plan/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/not-enough-tests/Makefile.am b/tap/tests/plan/not-enough-tests/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/not-enough-tests/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/not-enough-tests/test.c b/tap/tests/plan/not-enough-tests/test.c
new file mode 100644
index 00000000..a9ec64f2
--- /dev/null
+++ b/tap/tests/plan/not-enough-tests/test.c
@@ -0,0 +1,49 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(1);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 rc = ok(1, NULL);
43 diag("Returned: %d", rc);
44
45 rc = ok(1, NULL);
46 diag("Returned: %d", rc);
47
48 return exit_status();
49}
diff --git a/tap/tests/plan/not-enough-tests/test.pl b/tap/tests/plan/not-enough-tests/test.pl
new file mode 100644
index 00000000..73787a7c
--- /dev/null
+++ b/tap/tests/plan/not-enough-tests/test.pl
@@ -0,0 +1,20 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 1;
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
15
16$rc = ok(1);
17diag("Returned: $rc");
18
19$rc = ok(1);
20diag("Returned: $rc");
diff --git a/tap/tests/plan/not-enough-tests/test.t b/tap/tests/plan/not-enough-tests/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/not-enough-tests/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/sane/Makefile.am b/tap/tests/plan/sane/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/sane/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/sane/test.c b/tap/tests/plan/sane/test.c
new file mode 100644
index 00000000..0843d3af
--- /dev/null
+++ b/tap/tests/plan/sane/test.c
@@ -0,0 +1,43 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(1);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 return exit_status();
43}
diff --git a/tap/tests/plan/sane/test.pl b/tap/tests/plan/sane/test.pl
new file mode 100644
index 00000000..35c4ef2f
--- /dev/null
+++ b/tap/tests/plan/sane/test.pl
@@ -0,0 +1,14 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 1;
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
diff --git a/tap/tests/plan/sane/test.t b/tap/tests/plan/sane/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/sane/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/skip_all/Makefile.am b/tap/tests/plan/skip_all/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/skip_all/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/skip_all/test.c b/tap/tests/plan/skip_all/test.c
new file mode 100644
index 00000000..31722da9
--- /dev/null
+++ b/tap/tests/plan/skip_all/test.c
@@ -0,0 +1,38 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include "tap.h"
28
29int
30main(int argc, char *argv[])
31{
32 unsigned int rc = 0;
33
34 rc = plan_skip_all("No good reason");
35 diag("Returned: %d", rc);
36
37 return exit_status();
38}
diff --git a/tap/tests/plan/skip_all/test.pl b/tap/tests/plan/skip_all/test.pl
new file mode 100644
index 00000000..32555724
--- /dev/null
+++ b/tap/tests/plan/skip_all/test.pl
@@ -0,0 +1,11 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan skip_all => "No good reason";
11diag("Returned: " . sprintf("%d", $rc));
diff --git a/tap/tests/plan/skip_all/test.t b/tap/tests/plan/skip_all/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/skip_all/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/too-many-plans/Makefile.am b/tap/tests/plan/too-many-plans/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/too-many-plans/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/too-many-plans/test.c b/tap/tests/plan/too-many-plans/test.c
new file mode 100644
index 00000000..b189cb72
--- /dev/null
+++ b/tap/tests/plan/too-many-plans/test.c
@@ -0,0 +1,49 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(1);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 rc = plan_tests(1);
43 diag("Returned: %d", rc);
44
45 rc = ok(0, NULL);
46 diag("Returned: %d", rc);
47
48 return exit_status();
49}
diff --git a/tap/tests/plan/too-many-plans/test.pl b/tap/tests/plan/too-many-plans/test.pl
new file mode 100644
index 00000000..893e5fc0
--- /dev/null
+++ b/tap/tests/plan/too-many-plans/test.pl
@@ -0,0 +1,20 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 1;
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
15
16$rc = plan tests => 1;
17diag("Returned: $rc");
18
19$rc = ok(0);
20diag("Returned: $rc");
diff --git a/tap/tests/plan/too-many-plans/test.t b/tap/tests/plan/too-many-plans/test.t
new file mode 100644
index 00000000..cd2acf74
--- /dev/null
+++ b/tap/tests/plan/too-many-plans/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/twice!.*$/twice!/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/twice!.*$/twice!/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/plan/too-many-tests/Makefile.am b/tap/tests/plan/too-many-tests/Makefile.am
new file mode 100644
index 00000000..91d880e7
--- /dev/null
+++ b/tap/tests/plan/too-many-tests/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../../src
10test_LDFLAGS = -L../../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/plan/too-many-tests/test.c b/tap/tests/plan/too-many-tests/test.c
new file mode 100644
index 00000000..0f724104
--- /dev/null
+++ b/tap/tests/plan/too-many-tests/test.c
@@ -0,0 +1,46 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35
36 rc = plan_tests(5);
37 diag("Returned: %d", rc);
38
39 rc = ok(1, NULL);
40 diag("Returned: %d", rc);
41
42 rc = ok(0, NULL);
43 diag("Returned: %d", rc);
44
45 return exit_status();
46}
diff --git a/tap/tests/plan/too-many-tests/test.pl b/tap/tests/plan/too-many-tests/test.pl
new file mode 100644
index 00000000..0a1666ba
--- /dev/null
+++ b/tap/tests/plan/too-many-tests/test.pl
@@ -0,0 +1,17 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 5;
11diag("Returned: " . sprintf("%d", $rc));
12
13$rc = ok(1);
14diag("Returned: $rc");
15
16$rc = ok(0);
17diag("Returned: $rc");
diff --git a/tap/tests/plan/too-many-tests/test.t b/tap/tests/plan/too-many-tests/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/plan/too-many-tests/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/skip/Makefile.am b/tap/tests/skip/Makefile.am
new file mode 100644
index 00000000..c1ccb751
--- /dev/null
+++ b/tap/tests/skip/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../src
10test_LDFLAGS = -L../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/skip/test.c b/tap/tests/skip/test.c
new file mode 100644
index 00000000..d8f3eafd
--- /dev/null
+++ b/tap/tests/skip/test.c
@@ -0,0 +1,69 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35 unsigned int side_effect = 0;
36
37 rc = plan_tests(4);
38 diag("Returned: %d", rc);
39
40 rc = ok(1 == 1, "1 equals 1"); /* Should always work */
41 diag("Returned: %d", rc);
42
43 do {
44 if(1) {
45 rc = skip(1, "Testing skipping");
46 continue;
47 }
48
49 side_effect++;
50
51 ok(side_effect == 1, "side_effect checked out");
52
53 } while(0);
54
55 diag("Returned: %d", rc);
56
57 skip_start(1 == 1, 1, "Testing skipping #2");
58
59 side_effect++;
60 rc = ok(side_effect == 1, "side_effect checked out");
61 diag("Returned: %d", rc);
62
63 skip_end;
64
65 rc = ok(side_effect == 0, "side_effect is %d", side_effect);
66 diag("Returned: %d", rc);
67
68 return exit_status();
69}
diff --git a/tap/tests/skip/test.pl b/tap/tests/skip/test.pl
new file mode 100644
index 00000000..dc294717
--- /dev/null
+++ b/tap/tests/skip/test.pl
@@ -0,0 +1,40 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 4;
11diag("Returned: " . sprintf("%d", $rc));
12
13my $side_effect = 0; # Check whether skipping has side effects
14
15$rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should
16diag("Returned: $rc");
17
18# Start skipping
19SKIP: {
20 $rc = skip "Testing skipping", 1;
21
22 $side_effect++;
23
24 $rc = ok($side_effect == 1, '$side_effect checked out');
25}
26
27diag("Returned: $rc");
28
29SKIP: {
30 $rc = skip "Testing skipping #2", 1;
31 diag("Returned: $rc");
32
33 $side_effect++;
34
35 $rc = ok($side_effect == 1, '$side_effect checked out');
36 diag("Returned: $rc");
37}
38
39$rc = ok($side_effect == 0, "side_effect is $side_effect");
40diag("Returned: $rc");
diff --git a/tap/tests/skip/test.t b/tap/tests/skip/test.t
new file mode 100644
index 00000000..bf0fe8f1
--- /dev/null
+++ b/tap/tests/skip/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi
diff --git a/tap/tests/todo/Makefile.am b/tap/tests/todo/Makefile.am
new file mode 100644
index 00000000..c1ccb751
--- /dev/null
+++ b/tap/tests/todo/Makefile.am
@@ -0,0 +1,13 @@
1
2TESTS = test.t
3TESTS_ENVIRONMENT = $(SHELL)
4
5EXTRA_DIST = $(TESTS) test.pl
6
7check_PROGRAMS = test
8
9test_CFLAGS = -g -I../../src
10test_LDFLAGS = -L../../src
11test_LDADD = -ltap
12
13CLEANFILES = test.o test.c.out test.pl.out
diff --git a/tap/tests/todo/test.c b/tap/tests/todo/test.c
new file mode 100644
index 00000000..ac6339a7
--- /dev/null
+++ b/tap/tests/todo/test.c
@@ -0,0 +1,68 @@
1/*-
2 * Copyright (c) 2004 Nik Clayton
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <stdio.h>
28
29#include "tap.h"
30
31int
32main(int argc, char *argv[])
33{
34 unsigned int rc = 0;
35 unsigned int side_effect = 0;
36
37 rc = plan_tests(5);
38 diag("Returned: %d", rc);
39
40 rc = ok(1 == 1, "1 equals 1"); /* Should always work */
41 diag("Returned: %d", rc);
42
43 todo_start("For testing purposes");
44
45 side_effect++;
46
47 /* This test should fail */
48 rc = ok(side_effect == 0, "side_effect checked out");
49 diag("Returned: %d", rc);
50
51 /* This test should unexpectedly succeed */
52 rc = ok(side_effect == 1, "side_effect checked out");
53 diag("Returned: %d", rc);
54
55 todo_end();
56
57 todo_start("Testing printf() %s in todo_start()", "expansion");
58
59 rc = ok(0, "dummy test");
60 diag("Returned: %d", rc);
61
62 todo_end();
63
64 rc = ok(side_effect == 1, "side_effect is %d", side_effect);
65 diag("Returned: %d", rc);
66
67 return exit_status();
68}
diff --git a/tap/tests/todo/test.pl b/tap/tests/todo/test.pl
new file mode 100644
index 00000000..2621e12f
--- /dev/null
+++ b/tap/tests/todo/test.pl
@@ -0,0 +1,41 @@
1#!/usr/bin/perl
2
3use warnings;
4use strict;
5
6use Test::More;
7
8my $rc = 0;
9
10$rc = plan tests => 5;
11diag("Returned: " . sprintf("%d", $rc));
12
13my $side_effect = 0; # Check whether TODO has side effects
14
15$rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should
16diag("Returned: $rc");
17
18# Start TODO tests
19TODO: {
20 local $TODO = 'For testing purposes';
21
22 $side_effect++;
23
24 # This test should fail
25 $rc = ok($side_effect == 0, 'side_effect checked out');
26 diag("Returned: $rc");
27
28 # This test should unexpectedly succeed
29 $rc = ok($side_effect == 1, 'side_effect checked out');
30 diag("Returned: $rc");
31}
32
33TODO: {
34 local $TODO = 'Testing printf() expansion in todo_start()';
35
36 $rc = ok(0, 'dummy test');
37 diag("Returned: $rc");
38}
39
40$rc = ok($side_effect == 1, "side_effect is $side_effect");
41diag("Returned: $rc");
diff --git a/tap/tests/todo/test.t b/tap/tests/todo/test.t
new file mode 100644
index 00000000..7dbb17b6
--- /dev/null
+++ b/tap/tests/todo/test.t
@@ -0,0 +1,29 @@
1#!/bin/sh
2
3cd `dirname $0`
4
5echo '1..2'
6
7make 2>&1 > /dev/null
8
9perl ./test.pl 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.pl.out
10perlstatus=$?
11
12./test 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.c.out
13cstatus=$?
14
15diff -u test.pl.out test.c.out
16
17if [ $? -eq 0 ]; then
18 echo 'ok 1 - output is identical'
19else
20 echo 'not ok 1 - output is identical'
21fi
22
23if [ $perlstatus -eq $cstatus ]; then
24 echo 'ok 2 - status code'
25else
26 echo 'not ok 2 - status code'
27 echo "# perlstatus = $perlstatus"
28 echo "# cstatus = $cstatus"
29fi