diff options
Diffstat (limited to 'tap')
69 files changed, 2630 insertions, 0 deletions
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 | |||
| 4 | if USE_LIBTAP_LOCAL | ||
| 5 | noinst_LTLIBRARIES = libtap.la | ||
| 6 | libtap_la_SOURCES = tap.c tap.h | ||
| 7 | include_HEADERS = tap.h | ||
| 8 | endif 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 @@ | |||
| 1 | NAME | ||
| 2 | tap -- write tests that implement the Test Anything Protocol | ||
| 3 | |||
| 4 | SYNOPSIS | ||
| 5 | #include <tap.h> | ||
| 6 | |||
| 7 | DESCRIPTION | ||
| 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 | ||
| 10 | The | ||
| 11 | .Nm | ||
| 12 | library provides functions for writing test scripts that produce output | ||
| 13 | consistent with the Test Anything Protocol. A test harness that parses | ||
| 14 | this protocol can run these tests and produce useful reports indicating | ||
| 15 | their success or failure. | ||
| 16 | .Ss PRINTF STRINGS | ||
| 17 | In the descriptions that follow, for any function that takes as the | ||
| 18 | last two parameters | ||
| 19 | .Dq Fa char * , Fa ... | ||
| 20 | it can be assumed that the | ||
| 21 | .Fa char * | ||
| 22 | is a | ||
| 23 | .Fn printf | ||
| 24 | -like format string, and the optional arguments are values to be placed | ||
| 25 | in 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 | ||
| 42 | You must first specify a test plan. This indicates how many tests you | ||
| 43 | intend to run, and allows the test harness to notice if any tests were | ||
| 44 | missed, or if the test program exited prematurely. | ||
| 45 | .Pp | ||
| 46 | To do this, use | ||
| 47 | .Fn plan_tests , | ||
| 48 | which always returns 0. The function will cause your program to exit | ||
| 49 | prematurely if you specify 0 tests. | ||
| 50 | .Pp | ||
| 51 | In some situations you may not know how many tests you will be running, or | ||
| 52 | you are developing your test program, and do not want to update the | ||
| 53 | .Fn plan_tests | ||
| 54 | parameter every time you make a change. For those situations use | ||
| 55 | .Fn plan_no_plan . | ||
| 56 | It returns 0, and indicates to the test harness that an indeterminate number | ||
| 57 | of tests will be run. | ||
| 58 | .Pp | ||
| 59 | Both | ||
| 60 | .Fn plan_tests | ||
| 61 | and | ||
| 62 | .Fn plan_no_plan | ||
| 63 | will cause your test program to exit prematurely with a diagnostic | ||
| 64 | message if they are called more than once. | ||
| 65 | .Pp | ||
| 66 | If your test program detects at run time that some required functionality | ||
| 67 | is missing (for example, it relies on a database connection which is not | ||
| 68 | present, or a particular configuration option that has not been included | ||
| 69 | in the running kernel) use | ||
| 70 | .Fn plan_skip_all , | ||
| 71 | passing as parameters a string to display indicating the reason for skipping | ||
| 72 | the 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 | ||
| 93 | Tests are implemented as expressions checked by calls to the | ||
| 94 | .Fn ok | ||
| 95 | and | ||
| 96 | .Fn ok1 | ||
| 97 | macros. In both cases | ||
| 98 | .Fa expression | ||
| 99 | should evaluate to true if the test succeeded. | ||
| 100 | .Pp | ||
| 101 | .Fn ok | ||
| 102 | allows you to specify a name, or comment, describing the test which will | ||
| 103 | be included in the output. | ||
| 104 | .Fn ok1 | ||
| 105 | is for those times when the expression to be tested is self | ||
| 106 | explanatory and does not need an associated comment. In those cases | ||
| 107 | the test expression becomes the comment. | ||
| 108 | .Pp | ||
| 109 | These four calls are equivalent: | ||
| 110 | .Bd -literal -offset indent | ||
| 111 | int i = 5; | ||
| 112 | |||
| 113 | ok(i == 5, "i equals 5"); /* Overly verbose */ | ||
| 114 | ok(i == 5, "i equals %d", i); /* Just to demonstrate printf-like | ||
| 115 | behaviour of the test name */ | ||
| 116 | ok(i == 5, "i == 5"); /* Needless repetition */ | ||
| 117 | ok1(i == 5); /* Just right */ | ||
| 118 | .Ed | ||
| 119 | .Pp | ||
| 120 | It is good practice to ensure that the test name describes the meaning | ||
| 121 | behind the test rather than what you are testing. Viz | ||
| 122 | .Bd -literal -offset indent | ||
| 123 | ok(db != NULL, "db is not NULL"); /* Not bad, but */ | ||
| 124 | ok(db != NULL, "Database conn. succeeded"); /* this is better */ | ||
| 125 | .Ed | ||
| 126 | .Pp | ||
| 127 | .Fn ok | ||
| 128 | and | ||
| 129 | .Fn ok1 | ||
| 130 | return 1 if the expression evaluated to true, and 0 if it evaluated to | ||
| 131 | false. This lets you chain calls from | ||
| 132 | .Fn ok | ||
| 133 | to | ||
| 134 | .Fn diag | ||
| 135 | to only produce diagnostic output if the test failed. For example, this | ||
| 136 | code will include diagnostic information about why the database connection | ||
| 137 | failed, but only if the test failed. | ||
| 138 | .Bd -literal -offset indent | ||
| 139 | ok(db != NULL, "Database conn. succeeded") || | ||
| 140 | diag("Database error code: %d", dberrno); | ||
| 141 | .Ed | ||
| 142 | .Pp | ||
| 143 | You also have | ||
| 144 | .Fn pass | ||
| 145 | and | ||
| 146 | .Fn fail . | ||
| 147 | From the Test::More documentation: | ||
| 148 | .Bd -literal -offset indent | ||
| 149 | Sometimes you just want to say that the tests have passed. | ||
| 150 | Usually the case is you've got some complicated condition | ||
| 151 | that is difficult to wedge into an ok(). In this case, | ||
| 152 | you can simply use pass() (to declare the test ok) or fail | ||
| 153 | (for not ok). | ||
| 154 | |||
| 155 | Use these very, very, very sparingly. | ||
| 156 | .Ed | ||
| 157 | .Pp | ||
| 158 | These 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 | ||
| 173 | Sets of tests can be skipped. Ordinarily you would do this because | ||
| 174 | the test can't be run in this particular testing environment. | ||
| 175 | .Pp | ||
| 176 | For example, suppose some tests should be run as root. If the test is | ||
| 177 | not being run as root then the tests should be skipped. In this | ||
| 178 | implementation, skipped tests are flagged as being ok, with a special | ||
| 179 | message indicating that they were skipped. It is your responsibility | ||
| 180 | to ensure that the number of tests skipped (the first parameter to | ||
| 181 | .Fn skip ) | ||
| 182 | is correct for the number of tests to skip. | ||
| 183 | .Pp | ||
| 184 | One way of implementing this is with a | ||
| 185 | .Dq do { } while(0); | ||
| 186 | loop, or an | ||
| 187 | .Dq if( ) { } else { } | ||
| 188 | construct, to ensure that there are no additional side effects from the | ||
| 189 | skipped tests. | ||
| 190 | .Bd -literal -offset indent | ||
| 191 | if(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 | ||
| 198 | Two macros are provided to assist with this. The previous example could | ||
| 199 | be re-written as follows. | ||
| 200 | .Bd -literal -offset indent | ||
| 201 | skip_start(getuid() != 0, 1, "because test only works as root"); | ||
| 202 | |||
| 203 | ok(do_something_as_root() == 0, "Did something as root"); | ||
| 204 | |||
| 205 | skip_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 | ||
| 219 | Sets of tests can be flagged as being | ||
| 220 | .Dq TODO . | ||
| 221 | These are tests that you expect to fail, probably because you haven't | ||
| 222 | fixed a bug, or finished a new feature yet. These tests will still be | ||
| 223 | run, but with additional output that indicates that they are expected | ||
| 224 | to fail. Should a test start to succeed unexpectedly, tools like | ||
| 225 | .Xr prove 1 | ||
| 226 | will indicate this, and you can move the test out of the todo | ||
| 227 | block. This is much more useful than simply commenting out (or | ||
| 228 | .Dq #ifdef 0 ... #endif ) | ||
| 229 | the tests. | ||
| 230 | .Bd -literal -offset indent | ||
| 231 | todo_start("dwim() not returning true yet"); | ||
| 232 | |||
| 233 | ok(dwim(), "Did what the user wanted"); | ||
| 234 | |||
| 235 | todo_end(); | ||
| 236 | .Ed | ||
| 237 | .Pp | ||
| 238 | Should | ||
| 239 | .Fn dwim | ||
| 240 | ever start succeeding you will know about it as soon as you run the | ||
| 241 | tests. Note that | ||
| 242 | .Em unlike | ||
| 243 | the | ||
| 244 | .Fn skip_* | ||
| 245 | family, additional code between | ||
| 246 | .Fn todo_start | ||
| 247 | and | ||
| 248 | .Fn todo_end | ||
| 249 | .Em is | ||
| 250 | executed. | ||
| 251 | .Ss SKIP vs. TODO | ||
| 252 | From the Test::More documentation; | ||
| 253 | .Bd -literal -offset indent | ||
| 254 | If it's something the user might not be able to do, use SKIP. | ||
| 255 | This includes optional modules that aren't installed, running | ||
| 256 | under an OS that doesn't have some feature (like fork() or | ||
| 257 | symlinks), or maybe you need an Internet connection and one | ||
| 258 | isn't available. | ||
| 259 | |||
| 260 | If it's something the programmer hasn't done yet, use TODO. | ||
| 261 | This is for any code you haven't written yet, or bugs you have | ||
| 262 | yet 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 | ||
| 273 | If your tests need to produce diagnostic output, use | ||
| 274 | .Fn diag . | ||
| 275 | It ensures that the output will not be considered by the TAP test harness. | ||
| 276 | .Fn diag | ||
| 277 | adds the necessary trailing | ||
| 278 | .Dq \en | ||
| 279 | for you. | ||
| 280 | .Bd -literal -offset indent | ||
| 281 | diag("Expected return code 0, got return code %d", rcode); | ||
| 282 | .Ed | ||
| 283 | .Pp | ||
| 284 | .Fn diag | ||
| 285 | always 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 | ||
| 294 | For maximum compatability your test program should return a particular | ||
| 295 | exit code. This is calculated by | ||
| 296 | .Fn exit_status | ||
| 297 | so it is sufficient to always return from | ||
| 298 | .Fn main | ||
| 299 | with either | ||
| 300 | .Dq return exit_status(); | ||
| 301 | or | ||
| 302 | .Dq exit(exit_status()); | ||
| 303 | as appropriate. | ||
| 304 | .Sh EXAMPLES | ||
| 305 | The | ||
| 306 | .Pa tests | ||
| 307 | directory in the source distribution contains numerous tests of | ||
| 308 | .Nm | ||
| 309 | functionality, written using | ||
| 310 | .Nm . | ||
| 311 | Examine them for examples of how to construct test suites. | ||
| 312 | .Sh COMPATABILITY | ||
| 313 | .Nm | ||
| 314 | strives to be compatible with the Perl Test::More and Test::Harness | ||
| 315 | modules. The test suite verifies that | ||
| 316 | .Nm | ||
| 317 | is bug-for-bug compatible with their behaviour. This is why some | ||
| 318 | functions which would more naturally return nothing return constant | ||
| 319 | values. | ||
| 320 | .Pp | ||
| 321 | If the | ||
| 322 | .Lb libpthread | ||
| 323 | is found at compile time, | ||
| 324 | .Nm | ||
| 325 | .Em should | ||
| 326 | be thread safe. Indications to the contrary (and test cases that expose | ||
| 327 | incorrect 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 | ||
| 334 | requires a | ||
| 335 | .St -isoC-99 | ||
| 336 | compiler. Some of the | ||
| 337 | .Nm | ||
| 338 | functionality is implemented as variadic macros, and that functionality | ||
| 339 | was not formally codified until C99. Patches to use | ||
| 340 | .Nm | ||
| 341 | with earlier compilers that have their own implementation of variadic | ||
| 342 | macros will be gratefully received. | ||
| 343 | .Sh HISTORY | ||
| 344 | .Nm | ||
| 345 | was written to help improve the quality and coverage of the FreeBSD | ||
| 346 | regression test suite, and released in the hope that others find it | ||
| 347 | a 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 | ||
| 353 | would not exist without the efforts of | ||
| 354 | .An "Michael G Schwern" Aq schqern@pobox.com , | ||
| 355 | .An "Andy Lester" Aq andy@petdance.com , | ||
| 356 | and the countless others who have worked on the Perl QA programme. | ||
| 357 | .Sh BUGS | ||
| 358 | Ideally, running the tests would have no side effects on the behaviour | ||
| 359 | of the application you are testing. However, it is not always possible | ||
| 360 | to avoid them. The following side effects of using | ||
| 361 | .Nm | ||
| 362 | are known. | ||
| 363 | .Bl -bullet -offset indent | ||
| 364 | .It | ||
| 365 | stdout is set to unbuffered mode after calling any of the | ||
| 366 | .Fn plan_* | ||
| 367 | functions. | ||
| 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 | |||
| 34 | static int no_plan = 0; | ||
| 35 | static int skip_all = 0; | ||
| 36 | static int have_plan = 0; | ||
| 37 | static unsigned int test_count = 0; /* Number of tests that have been run */ | ||
| 38 | static unsigned int e_tests = 0; /* Expected number of tests to run */ | ||
| 39 | static unsigned int failures = 0; /* Number of tests that failed */ | ||
| 40 | static char *todo_msg = NULL; | ||
| 41 | static char *todo_msg_fixed = "libtap malloc issue"; | ||
| 42 | static int todo = 0; | ||
| 43 | static 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> | ||
| 49 | static 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 | |||
| 57 | static void _expected_tests(unsigned int); | ||
| 58 | static void _tap_init(void); | ||
| 59 | static 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 | */ | ||
| 68 | unsigned 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 | */ | ||
| 164 | void | ||
| 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 | */ | ||
| 187 | int | ||
| 188 | plan_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 | */ | ||
| 213 | int | ||
| 214 | plan_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 | */ | ||
| 238 | int | ||
| 239 | plan_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 | |||
| 269 | unsigned int | ||
| 270 | diag(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 | |||
| 289 | void | ||
| 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 | |||
| 301 | int | ||
| 302 | skip(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 | |||
| 327 | void | ||
| 328 | todo_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 | |||
| 343 | void | ||
| 344 | todo_end(void) | ||
| 345 | { | ||
| 346 | |||
| 347 | LOCK; | ||
| 348 | |||
| 349 | todo = 0; | ||
| 350 | free(todo_msg); | ||
| 351 | |||
| 352 | UNLOCK; | ||
| 353 | } | ||
| 354 | |||
| 355 | int | ||
| 356 | exit_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 | */ | ||
| 388 | void | ||
| 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 | |||
| 76 | unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); | ||
| 77 | |||
| 78 | int plan_no_plan(void); | ||
| 79 | int plan_skip_all(char *); | ||
| 80 | int plan_tests(unsigned int); | ||
| 81 | |||
| 82 | unsigned int diag(char *, ...); | ||
| 83 | |||
| 84 | int skip(unsigned int, char *, ...); | ||
| 85 | |||
| 86 | void todo_start(char *, ...); | ||
| 87 | void todo_end(void); | ||
| 88 | |||
| 89 | int 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 @@ | |||
| 1 | SUBDIRS= diag | ||
| 2 | SUBDIRS+= fail | ||
| 3 | SUBDIRS+= ok | ||
| 4 | SUBDIRS+= pass | ||
| 5 | SUBDIRS+= plan | ||
| 6 | SUBDIRS+= skip | ||
| 7 | SUBDIRS+= 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 @@ | |||
| 1 | Most 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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../src | ||
| 10 | test_LDFLAGS = -L../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | plan tests => 2; | ||
| 11 | |||
| 12 | $rc = diag("A diagnostic message"); | ||
| 13 | diag("Returned: $rc"); | ||
| 14 | |||
| 15 | ok(1, 'test 1') or diag "ok() failed, and shouldn't"; | ||
| 16 | ok(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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../src | ||
| 10 | test_LDFLAGS = -L../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 2; | ||
| 11 | diag("Returned: " . sprintf('%d', $rc)); | ||
| 12 | |||
| 13 | $rc = fail('test to fail'); | ||
| 14 | diag("Returned: $rc"); | ||
| 15 | |||
| 16 | $rc = fail('test to fail with extra string'); | ||
| 17 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 @@ | |||
| 1 | SUBDIRS = ok | ||
| 2 | SUBDIRS += ok-hash | ||
| 3 | SUBDIRS += 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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 4; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | |||
| 14 | $rc = ok(1, 'Test with no hash'); | ||
| 15 | diag("Returned: $rc"); | ||
| 16 | |||
| 17 | $rc = ok(1, 'Test with one # hash'); | ||
| 18 | diag("Returned: $rc"); | ||
| 19 | |||
| 20 | $rc = ok(1, 'Test with # two # hashes'); | ||
| 21 | diag("Returned: $rc"); | ||
| 22 | |||
| 23 | $rc = ok(1, 'Test with ## back to back hashes'); | ||
| 24 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 3; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | |||
| 14 | $rc = ok(1, 'First test'); | ||
| 15 | diag("Returned: $rc"); | ||
| 16 | |||
| 17 | $rc = ok(1, '1'); | ||
| 18 | diag("Returned: $rc"); | ||
| 19 | |||
| 20 | $rc = ok(1, 'Third test'); | ||
| 21 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 5; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | |||
| 14 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
| 15 | diag("Returned: $rc"); | ||
| 16 | |||
| 17 | $rc = ok(1 == 1, '1 equals 1'); # Used for %d testing in test.c | ||
| 18 | diag("Returned: $rc"); | ||
| 19 | |||
| 20 | $rc = ok(1 == 1, '1 == 1'); # Test ok1() passes when it should | ||
| 21 | diag("Returned: $rc"); | ||
| 22 | |||
| 23 | $rc = ok(1 == 2, '1 equals 2'); # Test ok() fails when it should | ||
| 24 | diag("Returned: $rc"); | ||
| 25 | |||
| 26 | $rc = ok(1 == 2, '1 == 2'); # Test ok1() fails when it should | ||
| 27 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../src | ||
| 10 | test_LDFLAGS = -L../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 2; | ||
| 11 | diag("Returned: " . sprintf('%d', $rc)); | ||
| 12 | |||
| 13 | $rc = pass('test to pass'); | ||
| 14 | diag("Returned: $rc"); | ||
| 15 | |||
| 16 | $rc = pass('test to pass with extra string'); | ||
| 17 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 @@ | |||
| 1 | SUBDIRS = no-tests | ||
| 2 | SUBDIRS += no_plan | ||
| 3 | SUBDIRS += not-enough-tests | ||
| 4 | SUBDIRS += too-many-plans | ||
| 5 | SUBDIRS += too-many-tests | ||
| 6 | SUBDIRS += sane | ||
| 7 | SUBDIRS += 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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 0; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | my $rc = 0; | ||
| 7 | |||
| 8 | use Test::More; | ||
| 9 | |||
| 10 | $rc = plan qw(no_plan); | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 1; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("Returned: $rc"); | ||
| 15 | |||
| 16 | $rc = ok(1); | ||
| 17 | diag("Returned: $rc"); | ||
| 18 | |||
| 19 | $rc = ok(1); | ||
| 20 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 1; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 29 | int | ||
| 30 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan skip_all => "No good reason"; | ||
| 11 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 1; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("Returned: $rc"); | ||
| 15 | |||
| 16 | $rc = plan tests => 1; | ||
| 17 | diag("Returned: $rc"); | ||
| 18 | |||
| 19 | $rc = ok(0); | ||
| 20 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/twice!.*$/twice!/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/twice!.*$/twice!/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../../src | ||
| 10 | test_LDFLAGS = -L../../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 5; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | $rc = ok(1); | ||
| 14 | diag("Returned: $rc"); | ||
| 15 | |||
| 16 | $rc = ok(0); | ||
| 17 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../src | ||
| 10 | test_LDFLAGS = -L../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 4; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | my $side_effect = 0; # Check whether skipping has side effects | ||
| 14 | |||
| 15 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
| 16 | diag("Returned: $rc"); | ||
| 17 | |||
| 18 | # Start skipping | ||
| 19 | SKIP: { | ||
| 20 | $rc = skip "Testing skipping", 1; | ||
| 21 | |||
| 22 | $side_effect++; | ||
| 23 | |||
| 24 | $rc = ok($side_effect == 1, '$side_effect checked out'); | ||
| 25 | } | ||
| 26 | |||
| 27 | diag("Returned: $rc"); | ||
| 28 | |||
| 29 | SKIP: { | ||
| 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"); | ||
| 40 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed test \(.*\)/# Failed test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
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 | |||
| 2 | TESTS = test.t | ||
| 3 | TESTS_ENVIRONMENT = $(SHELL) | ||
| 4 | |||
| 5 | EXTRA_DIST = $(TESTS) test.pl | ||
| 6 | |||
| 7 | check_PROGRAMS = test | ||
| 8 | |||
| 9 | test_CFLAGS = -g -I../../src | ||
| 10 | test_LDFLAGS = -L../../src | ||
| 11 | test_LDADD = -ltap | ||
| 12 | |||
| 13 | CLEANFILES = 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 | |||
| 31 | int | ||
| 32 | main(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 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | |||
| 6 | use Test::More; | ||
| 7 | |||
| 8 | my $rc = 0; | ||
| 9 | |||
| 10 | $rc = plan tests => 5; | ||
| 11 | diag("Returned: " . sprintf("%d", $rc)); | ||
| 12 | |||
| 13 | my $side_effect = 0; # Check whether TODO has side effects | ||
| 14 | |||
| 15 | $rc = ok(1 == 1, '1 equals 1'); # Test ok() passes when it should | ||
| 16 | diag("Returned: $rc"); | ||
| 17 | |||
| 18 | # Start TODO tests | ||
| 19 | TODO: { | ||
| 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 | |||
| 33 | TODO: { | ||
| 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"); | ||
| 41 | diag("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 | |||
| 3 | cd `dirname $0` | ||
| 4 | |||
| 5 | echo '1..2' | ||
| 6 | |||
| 7 | make 2>&1 > /dev/null | ||
| 8 | |||
| 9 | perl ./test.pl 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.pl.out | ||
| 10 | perlstatus=$? | ||
| 11 | |||
| 12 | ./test 2>&1 | sed -e 's/# Failed (TODO) test \(.*\)/# Failed (TODO) test ()/' > test.c.out | ||
| 13 | cstatus=$? | ||
| 14 | |||
| 15 | diff -u test.pl.out test.c.out | ||
| 16 | |||
| 17 | if [ $? -eq 0 ]; then | ||
| 18 | echo 'ok 1 - output is identical' | ||
| 19 | else | ||
| 20 | echo 'not ok 1 - output is identical' | ||
| 21 | fi | ||
| 22 | |||
| 23 | if [ $perlstatus -eq $cstatus ]; then | ||
| 24 | echo 'ok 2 - status code' | ||
| 25 | else | ||
| 26 | echo 'not ok 2 - status code' | ||
| 27 | echo "# perlstatus = $perlstatus" | ||
| 28 | echo "# cstatus = $cstatus" | ||
| 29 | fi | ||
