commit 5befd76049fbcb96bef8ed5bb4d58b128098f470 from: Sven M. Hallberg date: Tue Jul 29 18:16:13 2025 UTC test.h: rename TEST and RUNT to test() and runtest() Also organizes corresponding tests into a nicer directory hierarchy. commit - be897a7b9bdff1a8faae3850d96d39a03ef75bb0 commit + 5befd76049fbcb96bef8ed5bb4d58b128098f470 blob - b1f35683ba3b436400f30fe3c12a5280615f9b80 blob + 857a903b38ec20f0097cc25a24e392d5f92e81e1 --- lang/c/test.h +++ lang/c/test.h @@ -15,7 +15,7 @@ static int status; static int failed_; -#define TEST(X, ...) do { \ +#define test(X, ...) do { \ const char *name = #X "(" #__VA_ARGS__ ")"; \ int i; \ \ @@ -25,12 +25,12 @@ static int failed_; break; \ /* run test if it matches an arg or if there are no args */ \ if (i < argc || argc == 1) \ - RUNT(X, __VA_ARGS__); \ + runtest(X, __VA_ARGS__); \ else if (getenv("V") != NULL) /* V = verbose */ \ printf("%s\t-\n", name); \ } while (0) -#define RUNT(X, ...) do { \ +#define runtest(X, ...) do { \ const char *name = #X "(" #__VA_ARGS__ ")"; \ \ failed_ = 0; \ blob - d3d345769acbfc6d5784598262b8b669269bbd7f blob + d82e4bbd1a740743908c9626690691c259402964 --- test.h.3 +++ test.h.3 @@ -9,21 +9,21 @@ .Sh SYNOPSIS .In test.h .Vt static int status; -.Fn TEST function ... -.Fn RUNT function ... +.Fn test function ... +.Fn runtest function ... .Fn expect expression .Fn fail fmt ... .Fn rem fmt ... . .Sh DESCRIPTION The -.Fn TEST +.Fn test macro calls the given function as a test. Any additional arguments are be passed through to .Ar function , allowing parameterized families of tests. .Pp -.Fn TEST +.Fn test is meant to be called from .Fn main and inspects @@ -34,10 +34,10 @@ The command line should consist (only) of string prefi that select the corresponding tests. An empty command line selects all tests. Each selected test is passed to the -.Fn RUNT +.Fn runtest macro. .Pp -.Fn RUNT +.Fn runtest unconditionally executes the given test and prints its result to standard output. It does not depend on @@ -92,7 +92,7 @@ the test should use includes .In assert.h for convenience. After a failed test returns, -.Fn RUNT +.Fn runtest normally calls .Xr exit 3 , forgoing any remaining tests. @@ -154,9 +154,9 @@ bar(unsigned int mask) int main(int argc, char *argv[]) { - TEST(foo); - TEST(bar, 0x0f); - TEST(bar, 0xff); + test(foo); + test(bar, 0x0f); + test(bar, 0xff); return status; } blob - e357e755fde21db1d3fdefe8daa426d1109757c9 (mode 755) blob + /dev/null --- tests/lang/c/RUNT-argcv.t +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\tOK\n" \ - "foo called\nbar called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - void - runtests(void) - { - /* argc, argv not needed */ - RUNT(foo); - RUNT(bar); - } - - int - main(int argc, char *argv[]) - { - runtests(); - return 0; - } -EOF blob - /dev/null blob + 428fb5546d467591a176a2ef4421aeaba5a96f83 (mode 755) --- /dev/null +++ tests/lang/c/expect/abort.t @@ -0,0 +1,34 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/$(basename "$0").$$ +export CFLAGS=-I../../lang/c +export X=1 +exec ./assert-c-abort \ + "" \ + "" \ + "$tst.c:7: condition failed: 2 == 3\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + expect(2 == 3); /* aborts with X set */ + fputs("foo running\n", stderr); /* should not print */ + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail and abort */ + test(bar); /* will not execute */ + return 0; + } +EOF blob - /dev/null blob + 3475d4d2d750f92577f759a7a0bb9f5193c31002 (mode 755) --- /dev/null +++ tests/lang/c/expect/false.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/fail.t.$$ +export CFLAGS=-I../../lang/c +exec ./assert-c 1 \ + "" \ + "foo()\tFAIL\n" \ + "$tst.c:7: condition failed: 2 == 3\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + expect(2 == 3); + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail */ + test(bar); /* will not execute without K set */ + return 0; + } +EOF blob - /dev/null blob + 6aca62d9a33356436ee8d947759e7229225db13c (mode 755) --- /dev/null +++ tests/lang/c/expect/noabort.t @@ -0,0 +1,34 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/fail.t.$$ +export CFLAGS=-I../../lang/c +exec ./assert-c 1 \ + "" \ + "foo()\tFAIL\n" \ + "$tst.c:7: condition failed: 2 == 3\n$tst.c:9: condition failed: 0\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + expect(2 == 3); /* will print an error */ + expect(3 == 3); + expect(0); /* will print an error */ + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail */ + test(bar); /* will not execute without K set */ + return 0; + } +EOF blob - /dev/null blob + 71b9e60d06bf85cb51ce8802b15a285d5790af55 (mode 755) --- /dev/null +++ tests/lang/c/expect/true.t @@ -0,0 +1,31 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\tOK\n" \ + "" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + expect(2 == 2); + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - 58bff5ea7a6d512ffd048b2920b4eca2c71f94b5 (mode 755) blob + /dev/null --- tests/lang/c/RUNT-args.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo(0x01)\tOK\nbar(\"x y z\")\tOK\n" \ - "foo(1) called\nbar(\"x y z\") called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(int i) - { - fprintf(stderr, "foo(%d) called\n", i); - } - - void - bar(const char *s) - { - fprintf(stderr, "bar(\"%s\") called\n", s); - } - - int - main(int argc, char *argv[]) - { - RUNT(foo, 0x01); - RUNT(bar, "x y z"); - return 0; - } -EOF blob - /dev/null blob + 576e48b05d1c9349a14b98c0bd2b3553ee3df7e6 (mode 755) --- /dev/null +++ tests/lang/c/fail/abort.t @@ -0,0 +1,34 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/$(basename "$0").$$ +export CFLAGS=-I../../lang/c +export X=1 +exec ./assert-c-abort \ + "" \ + "" \ + "$tst.c:7: foo failed\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fail("foo failed"); /* aborts with X set */ + fputs("foo running\n", stderr); /* should not print */ + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail and abort */ + test(bar); /* will not execute */ + return 0; + } +EOF blob - /dev/null blob + 3e7fbc3be6e8486b40aa34fa1d71bf2cf3d40caf (mode 755) --- /dev/null +++ tests/lang/c/fail/fmt.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/fail.t.$$ +export CFLAGS=-I../../lang/c +exec ./assert-c 1 \ + "" \ + "foo(23)\tFAIL\n" \ + "$tst.c:7: foo(23) failed\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(int i) + { + fail("foo(%d) failed", i); + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo, 23); /* expected to fail */ + test(bar); /* will not execute without K set */ + return 0; + } +EOF blob - /dev/null blob + 19f6f0102ab91e54d73e71494cce5ab1f424f596 (mode 755) --- /dev/null +++ tests/lang/c/fail/keepgoing.t @@ -0,0 +1,33 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/fail.t.$$ +export CFLAGS=-I../../lang/c +export K=1 +exec ./assert-c 0 \ + "" \ + "foo()\tFAIL\nbar()\tOK\n" \ + "$tst.c:7: foo failed\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fail("foo failed"); + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail */ + test(bar); /* will still execute with K set */ + return 0; /* with K, we will exit 0! */ + } +EOF blob - /dev/null blob + 50ca78ea98c9aec233e8a4fb83040ddee12e8179 (mode 755) --- /dev/null +++ tests/lang/c/fail/noabort.t @@ -0,0 +1,33 @@ +#!/bin/sh + +unset D V K X +export tst=/tmp/fail.t.$$ +export CFLAGS=-I../../lang/c +exec ./assert-c 1 \ + "" \ + "foo()\tFAIL\n" \ + "$tst.c:7: foo failed\nfoo running\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fail("foo failed"); /* does not abort */ + fputs("foo running\n", stderr); /* this should still print */ + } + + void + bar(void) + { + } + + int + main(int argc, char *argv[]) + { + test(foo); /* expected to fail */ + test(bar); /* will not execute without K set */ + return 0; + } +EOF blob - 7d9884a039ea032514ba31232c306b7d7d563653 (mode 755) blob + /dev/null --- tests/lang/c/RUNT-dryrun.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -export D=1 -exec ./assert-c 0 \ - "" \ - "foo()\nbar()\n" \ - "" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - RUNT(foo); - RUNT(bar); - return 0; - } -EOF blob - d970873a45d9d23aacd58a1a66be094a60f21c83 (mode 755) blob + /dev/null --- tests/lang/c/RUNT.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\tOK\n" \ - "foo called\nbar called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - RUNT(foo); - RUNT(bar); - return 0; - } -EOF blob - 45f6e7c571ed29a759209fc16c59532c62793cb4 (mode 755) blob + /dev/null --- tests/lang/c/TEST-args.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo(0x01)\tOK\nbar(\"x y z\")\tOK\n" \ - "foo(1) called\nbar(\"x y z\") called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(int i) - { - fprintf(stderr, "foo(%d) called\n", i); - } - - void - bar(const char *s) - { - fprintf(stderr, "bar(\"%s\") called\n", s); - } - - int - main(int argc, char *argv[]) - { - TEST(foo, 0x01); - TEST(bar, "x y z"); - return 0; - } -EOF blob - /dev/null blob + f1bb5d296fb1df3c6aa61a833f6120a07f129e5d (mode 755) --- /dev/null +++ tests/lang/c/runtest/argcv.t @@ -0,0 +1,39 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\tOK\n" \ + "foo called\nbar called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + void + runtests(void) + { + /* argc, argv not needed */ + runtest(foo); + runtest(bar); + } + + int + main(int argc, char *argv[]) + { + runtests(); + return 0; + } +EOF blob - /dev/null blob + 5c5fcefdb44713ba8cbf752ba778415f7352651d (mode 755) --- /dev/null +++ tests/lang/c/runtest/args.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo(0x01)\tOK\nbar(\"x y z\")\tOK\n" \ + "foo(1) called\nbar(\"x y z\") called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(int i) + { + fprintf(stderr, "foo(%d) called\n", i); + } + + void + bar(const char *s) + { + fprintf(stderr, "bar(\"%s\") called\n", s); + } + + int + main(int argc, char *argv[]) + { + runtest(foo, 0x01); + runtest(bar, "x y z"); + return 0; + } +EOF blob - /dev/null blob + 834f069d340a58e85ed4cb565010586f52f40086 (mode 755) --- /dev/null +++ tests/lang/c/runtest/dryrun.t @@ -0,0 +1,33 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +export D=1 +exec ./assert-c 0 \ + "" \ + "foo()\nbar()\n" \ + "" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + runtest(foo); + runtest(bar); + return 0; + } +EOF blob - 11481d6b28d81268043e638f9e94c1abce9a2514 (mode 755) blob + /dev/null --- tests/lang/c/TEST-dryrun.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -export D=1 -exec ./assert-c 0 \ - "" \ - "foo()\nbar()\n" \ - "" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - /dev/null blob + 13212104deb606f59fe30c9429c6c919bb5a91ba (mode 755) --- /dev/null +++ tests/lang/c/runtest.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\tOK\n" \ + "foo called\nbar called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + runtest(foo); + runtest(bar); + return 0; + } +EOF blob - 03de7bd387b8fcc262304d6c1365caee21384e2b (mode 755) blob + /dev/null --- tests/lang/c/TEST-select.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\n" \ - "foo called\n" \ - fo \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - /dev/null blob + 4a85d7f1a96266036448822a33184622eae78e98 (mode 755) --- /dev/null +++ tests/lang/c/test/args.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo(0x01)\tOK\nbar(\"x y z\")\tOK\n" \ + "foo(1) called\nbar(\"x y z\") called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(int i) + { + fprintf(stderr, "foo(%d) called\n", i); + } + + void + bar(const char *s) + { + fprintf(stderr, "bar(\"%s\") called\n", s); + } + + int + main(int argc, char *argv[]) + { + test(foo, 0x01); + test(bar, "x y z"); + return 0; + } +EOF blob - /dev/null blob + 8e102dc9a4f1d5ee853c089921a07605f793f94c (mode 755) --- /dev/null +++ tests/lang/c/test/dryrun.t @@ -0,0 +1,33 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +export D=1 +exec ./assert-c 0 \ + "" \ + "foo()\nbar()\n" \ + "" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - /dev/null blob + 43c67f011d758bb9aa984b3471f1dbcdce4f83f2 (mode 755) --- /dev/null +++ tests/lang/c/test/select.t @@ -0,0 +1,33 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\n" \ + "foo called\n" \ + fo \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - /dev/null blob + 6d4102cfd6a99f5311df6a570c749f6b2ee1e5d4 (mode 755) --- /dev/null +++ tests/lang/c/test/stdin.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "xxxxxxxx\n" \ + "foo()\tOK\nbar()\tOK\n" \ + "foo called\nbar called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - /dev/null blob + c3591da7d358ebfa3af2fa5b458222f0ee40a2b4 (mode 755) --- /dev/null +++ tests/lang/c/test/type.t @@ -0,0 +1,34 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\tOK\n" \ + "foo called\nbar called\n" \ +<<-EOF + #include + #include "test.h" + + int + foo(void) + { + fputs("foo called\n", stderr); + return 23; + } + + const char * + bar(void) + { + fputs("bar called\n", stderr); + return "hallo"; + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - /dev/null blob + 94b76a90cd403a5b63dbf7d453faf9a7c00f872b (mode 755) --- /dev/null +++ tests/lang/c/test/verbose.t @@ -0,0 +1,34 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +export V=1 +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\t-\n" \ + "foo called\n" \ + fo \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - e0d67b096ffb78d29056ddf35fa025624ea4ef0d (mode 755) blob + /dev/null --- tests/lang/c/TEST-stdin.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "xxxxxxxx\n" \ - "foo()\tOK\nbar()\tOK\n" \ - "foo called\nbar called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - /dev/null blob + ba7109402845e75ec1ace79b8b297b5fc0a21655 (mode 755) --- /dev/null +++ tests/lang/c/test.t @@ -0,0 +1,32 @@ +#!/bin/sh + +unset D V K X +export CFLAGS=-I../../lang/c +exec ./assert-c 0 \ + "" \ + "foo()\tOK\nbar()\tOK\n" \ + "foo called\nbar called\n" \ +<<-EOF + #include + #include "test.h" + + void + foo(void) + { + fputs("foo called\n", stderr); + } + + void + bar(void) + { + fputs("bar called\n", stderr); + } + + int + main(int argc, char *argv[]) + { + test(foo); + test(bar); + return 0; + } +EOF blob - 0b3fd763f04c730593d1414e2814da5face5e036 (mode 755) blob + /dev/null --- tests/lang/c/TEST-type.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\tOK\n" \ - "foo called\nbar called\n" \ -<<-EOF - #include - #include "test.h" - - int - foo(void) - { - fputs("foo called\n", stderr); - return 23; - } - - const char * - bar(void) - { - fputs("bar called\n", stderr); - return "hallo"; - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - b4b617c9df20bb4bcd1f7fa245a042cfdea0afbc (mode 755) blob + /dev/null --- tests/lang/c/TEST-verbose.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -export V=1 -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\t-\n" \ - "foo called\n" \ - fo \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - 0653cd8bf21dde49f881b2427d9199224dea06dc (mode 755) blob + /dev/null --- tests/lang/c/TEST.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\tOK\n" \ - "foo called\nbar called\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fputs("foo called\n", stderr); - } - - void - bar(void) - { - fputs("bar called\n", stderr); - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - 73a4d13e5fd005108bd97ac8064d23c3d9e4bf4c (mode 755) blob + /dev/null --- tests/lang/c/expect-abort.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/$(basename "$0").$$ -export CFLAGS=-I../../lang/c -export X=1 -exec ./assert-c-abort \ - "" \ - "" \ - "$tst.c:7: condition failed: 2 == 3\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - expect(2 == 3); /* aborts with X set */ - fputs("foo running\n", stderr); /* should not print */ - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail and abort */ - TEST(bar); /* will not execute */ - return 0; - } -EOF blob - 19144d3739a05efa84e9de14c155923838db56b2 (mode 755) blob + /dev/null --- tests/lang/c/expect-false.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/fail.t.$$ -export CFLAGS=-I../../lang/c -exec ./assert-c 1 \ - "" \ - "foo()\tFAIL\n" \ - "$tst.c:7: condition failed: 2 == 3\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - expect(2 == 3); - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail */ - TEST(bar); /* will not execute without K set */ - return 0; - } -EOF blob - 755833d5d4a854fa699a33f6e045488f751fc6c8 (mode 755) blob + /dev/null --- tests/lang/c/expect-noabort.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/fail.t.$$ -export CFLAGS=-I../../lang/c -exec ./assert-c 1 \ - "" \ - "foo()\tFAIL\n" \ - "$tst.c:7: condition failed: 2 == 3\n$tst.c:9: condition failed: 0\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - expect(2 == 3); /* will print an error */ - expect(3 == 3); - expect(0); /* will print an error */ - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail */ - TEST(bar); /* will not execute without K set */ - return 0; - } -EOF blob - 875b6868d0a2d61a534b8fcfecf33a9e4d275222 (mode 755) blob + /dev/null --- tests/lang/c/expect-true.t +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -unset D V K X -export CFLAGS=-I../../lang/c -exec ./assert-c 0 \ - "" \ - "foo()\tOK\nbar()\tOK\n" \ - "" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - expect(2 == 2); - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); - TEST(bar); - return 0; - } -EOF blob - 4f7ae2be169da60e8c3f4fbf9acff7ab190e1b7d (mode 755) blob + /dev/null --- tests/lang/c/fail-abort.t +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/$(basename "$0").$$ -export CFLAGS=-I../../lang/c -export X=1 -exec ./assert-c-abort \ - "" \ - "" \ - "$tst.c:7: foo failed\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fail("foo failed"); /* aborts with X set */ - fputs("foo running\n", stderr); /* should not print */ - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail and abort */ - TEST(bar); /* will not execute */ - return 0; - } -EOF blob - 8b8a650c57ea1d7c6ba6e9615c3d0ee99a18d024 (mode 755) blob + /dev/null --- tests/lang/c/fail-fmt.t +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/fail.t.$$ -export CFLAGS=-I../../lang/c -exec ./assert-c 1 \ - "" \ - "foo(23)\tFAIL\n" \ - "$tst.c:7: foo(23) failed\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(int i) - { - fail("foo(%d) failed", i); - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo, 23); /* expected to fail */ - TEST(bar); /* will not execute without K set */ - return 0; - } -EOF blob - 354f0380a47f2d49b04acf91b6fdd39cb163aa7b (mode 755) blob + /dev/null --- tests/lang/c/fail-keepgoing.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/fail.t.$$ -export CFLAGS=-I../../lang/c -export K=1 -exec ./assert-c 0 \ - "" \ - "foo()\tFAIL\nbar()\tOK\n" \ - "$tst.c:7: foo failed\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fail("foo failed"); - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail */ - TEST(bar); /* will still execute with K set */ - return 0; /* with K, we will exit 0! */ - } -EOF blob - 73f938d42271af687fd144b80740691fd9dea0b5 (mode 755) blob + /dev/null --- tests/lang/c/fail-noabort.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -unset D V K X -export tst=/tmp/fail.t.$$ -export CFLAGS=-I../../lang/c -exec ./assert-c 1 \ - "" \ - "foo()\tFAIL\n" \ - "$tst.c:7: foo failed\nfoo running\n" \ -<<-EOF - #include - #include "test.h" - - void - foo(void) - { - fail("foo failed"); /* does not abort */ - fputs("foo running\n", stderr); /* this should still print */ - } - - void - bar(void) - { - } - - int - main(int argc, char *argv[]) - { - TEST(foo); /* expected to fail */ - TEST(bar); /* will not execute without K set */ - return 0; - } -EOF blob - bffaa1fb384fb56ece9a72f01bd1eb1519469744 blob + 31d01aeb9a83fe0a3edb6951b8655840e43c054a --- tests/lang/c/fail.t +++ tests/lang/c/fail.t @@ -25,8 +25,8 @@ exec ./assert-c 1 \ int main(int argc, char *argv[]) { - TEST(foo); /* expected to fail */ - TEST(bar); /* will not execute without K set */ + test(foo); /* expected to fail */ + test(bar); /* will not execute without K set */ return 0; } EOF blob - a7f07d8ab51c6619f6ff3f948535293cc4a6a919 blob + 66237947fda22c066b00bec4c050f704f99602c8 --- tests/lang/c/rem.t +++ tests/lang/c/rem.t @@ -30,8 +30,8 @@ export CFLAGS=-I../../lang/c main(int argc, char *argv[]) { fputs("main\n", stderr); - TEST(foo); - TEST(bar); + test(foo); + test(bar); return 0; } EOF @@ -62,8 +62,8 @@ V=1 \ main(int argc, char *argv[]) { fputs("main\n", stderr); - TEST(foo); - TEST(bar); + test(foo); + test(bar); return 0; } EOF