c/t/bool.t.c | 11 +++-------- c/t/compile_flags.txt.do | 4 +--- c/t/conf/.gitignore | 1 - c/t/conf/tap.rc.do | 12 ------------ c/t/default.t.do | 8 +++----- c/t/magic.t.c | 11 +++-------- c/t/nil.t.c | 11 +++-------- c/t/tai.t.c | 11 +++-------- c/t/tai64.t.c | 11 +++-------- c/t/tap.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ c/t/tap.h | 30 ++++++++++++++++++++++++++++++ makedist | 2 -- diff --git a/c/t/bool.t.c b/c/t/bool.t.c index cf90ff0ae0ca6582b051ea5278b1916579d3085324c6880c032096492e639060..4685825f93937d83f15830819c1335cd7c1046e77fa060cc6ae893a097d82bfb 100644 --- a/c/t/bool.t.c +++ b/c/t/bool.t.c @@ -1,15 +1,12 @@ #include #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-macro-identifier" -#include -#pragma clang diagnostic pop - #include #include #include #include + +#include "tap.h" static void test( @@ -56,10 +53,8 @@ int main(void) { - plan(NO_PLAN); - test(KEKSAtomBoolEncode, KEKSItemFalse, false, 0x02); test(KEKSAtomBoolEncode, KEKSItemTrue, true, 0x03); - return exit_status(); + return TAPStatus(); } diff --git a/c/t/compile_flags.txt.do b/c/t/compile_flags.txt.do index d35d986ae86a201da6a68a6f0f36dc6f11b255a06d768e030c3780ed02e0c746..0ea34f7b19cc593bcd4235a4a405106cce276c91ce837a61ebfc492ee63a8c87 100644 --- a/c/t/compile_flags.txt.do +++ b/c/t/compile_flags.txt.do @@ -1,5 +1,3 @@ -redo-ifchange ../conf/prefix conf/tap.rc +redo-ifchange ../conf/prefix read PREFIX <../conf/prefix printf "%s\n" "-I$PREFIX/include" -. conf/tap.rc -printf "%s\n" "$TAP_CFLAGS" diff --git a/c/t/conf/.gitignore b/c/t/conf/.gitignore deleted file mode 100644 index 4cdbe3c96c615bb2287132bc8aea5bb5e20f1edc7c0d34d12e019795c8d27e07..0000000000000000000000000000000000000000 --- a/c/t/conf/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/tap.rc diff --git a/c/t/conf/tap.rc.do b/c/t/conf/tap.rc.do deleted file mode 100644 index 1f694097a56798e6e7af512744e59c426008251bb53ad6495699c10bc8d6ead8..0000000000000000000000000000000000000000 --- a/c/t/conf/tap.rc.do +++ /dev/null @@ -1,12 +0,0 @@ -PKGCONF=${PKGCONF:-$(command -v pkgconf || command -v pkg-config)} -cat < #include #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-macro-identifier" -#include -#pragma clang diagnostic pop - #include #include #include #include +#include "tap.h" + int main(void) { - plan(NO_PLAN); - unsigned char magic[12] = {0}; getrandom(magic, 12, 0); magic[11] = 123; @@ -161,5 +156,5 @@ buf[3] = 'S'; err = KEKSItemsParse(&items, &off, buf, cap); ok(err == KEKSErrBadMagic, "bad magic KeKS"); - return exit_status(); + return TAPStatus(); } diff --git a/c/t/nil.t.c b/c/t/nil.t.c index a179247ba3f365c6455252e885e32d6e8620e131c1b6a4d70c35692137710858..e250850601a3516e51b6aeb87a2aa381fd3d565033ad54ef546f893288dd64c3 100644 --- a/c/t/nil.t.c +++ b/c/t/nil.t.c @@ -1,20 +1,15 @@ #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-macro-identifier" -#include -#pragma clang diagnostic pop - #include #include #include #include +#include "tap.h" + int main(void) { - plan(NO_PLAN); - size_t len = 0; unsigned char buf[] = {0, 0}; size_t cap = 0; @@ -49,5 +44,5 @@ ok(KEKSItemsEncode(&items, 0, &off, buf, cap), "items encode"); ok(off == 1, "items encode off"); ok(buf[0] == 0x01, "items encode val"); - return exit_status(); + return TAPStatus(); } diff --git a/c/t/tai.t.c b/c/t/tai.t.c index 27c5a36da7c772846df2ad208200a18f4a5c1ab96452934f9f2f0a957f1395c6..a4c10f06609583b0bd95b5b72552259ca2183319b621848fba03692bf536c090 100644 --- a/c/t/tai.t.c +++ b/c/t/tai.t.c @@ -5,11 +5,6 @@ #include #include #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-macro-identifier" -#include -#pragma clang diagnostic pop - #include #include #include @@ -17,11 +12,11 @@ #include #include #include +#include "tap.h" + int main(void) { - plan(NO_PLAN); - unsigned char src[8] = {0}; getrandom(src, 4, 0); struct timespec ts; @@ -111,5 +106,5 @@ (const unsigned char *)"\x40\xFF\x00\x00\x00\x00\x00\x10\x3B\xA0\x00\x00", 12) == KEKSErrTAI64BadNsec, "too big ns"); - return exit_status(); + return TAPStatus(); } diff --git a/c/t/tai64.t.c b/c/t/tai64.t.c index d980aa66123a620a16d42bd7967e2d0c4a1b5dd7d7a00391b71479f77728144a..0cf30b6be86df6fd0d6ab32874985b9362a6227c664234e6f22eb303e09e1c96 100644 --- a/c/t/tai64.t.c +++ b/c/t/tai64.t.c @@ -2,11 +2,6 @@ #include #include #include -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-macro-identifier" -#include -#pragma clang diagnostic pop - #include #include #include @@ -14,11 +9,11 @@ #include #include #include +#include "tap.h" + int main(void) { - plan(NO_PLAN); - unsigned char src[16] = {0}; getrandom(src, 16, 0); size_t len = 0; @@ -193,5 +188,5 @@ off = 0; err = KEKSItemsParse(&items, &off, buf, cap); ok(err == KEKSErrTAI64TooBig, "64NA: highest bit set"); - return exit_status(); + return TAPStatus(); } diff --git a/c/t/tap.c b/c/t/tap.c new file mode 100644 index 0000000000000000000000000000000000000000..ea54fea09257daad9e75c30ab79df34c91310d5693f4859de29579849509c4ba --- /dev/null +++ b/c/t/tap.c @@ -0,0 +1,64 @@ +#include +#include +#include + +#include "tap.h" + +static int tapN = 0; +static int tapRC = EXIT_SUCCESS; + +static void +vtapOK( + const char *file, + const int line, + const char *func, + const bool test, + const char *fmt, + va_list args) +{ + if (!test) { + fputs("not ", stdout); + tapRC = EXIT_FAILURE; + } + printf("ok %d - ", ++tapN); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" + vprintf(fmt, args); +#pragma clang diagnostic pop + puts(""); + if (!test) { + printf("# %s:%d:%s\n", file, line, func); + } +} + +void +tapOK( + const char *file, + const int line, + const char *func, + const bool test, + const char *fmt, + ...) +{ + va_list args; + va_start(args, fmt); + vtapOK(file, line, func, test, fmt, args); + va_end(args); +} + +int +TAPStatus(void) +{ + printf("1..%d\n", tapN); + return tapRC; +} + +void +diag(const char *name, const unsigned char *buf, const size_t bufLen) +{ + printf("# %s: %zu: ", name, bufLen); + for (size_t i = 0; i < bufLen; i++) { + printf("%02X", buf[i]); + } + puts(""); +} diff --git a/c/t/tap.h b/c/t/tap.h new file mode 100644 index 0000000000000000000000000000000000000000..87897c25d422e3e5d28c71aea354c7a98b6a1b44ed4969cea4a48e18d6f0c929 --- /dev/null +++ b/c/t/tap.h @@ -0,0 +1,30 @@ +#ifndef MIN_TAP_H +#define MIN_TAP_H + +#include +#include + +void +tapOK( + const char *file, + const int line, + const char *func, + const bool test, + const char *fmt, + ...); + +// Print TAP-compatible test's result, supplying with the name. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-macros" +#define ok(...) tapOK(__FILE__, __LINE__, __func__, __VA_ARGS__, NULL) +#pragma clang diagnostic pop + +// Print TAP test plan and return the desired exit code. +int +TAPStatus(void); + +// Print diagnostics named message with hexadecimal buffer's contents. +void +diag(const char *name, const unsigned char *buf, const size_t bufLen); + +#endif // MIN_TAP_H diff --git a/makedist b/makedist index f1cd7e0c2365e90a084da00919ddba3cbf4cdad0c7d186ff0d08b455a46a83fc..fb40eb41f926f929f8b002426fb597d1ff0fe00950e5b2015dd17ec4f97ae3cb 100755 --- a/makedist +++ b/makedist @@ -61,8 +61,6 @@ rm -fr .git makedist mkdir third-party cd .. -zstd -d <$cur/third-party/libtap-0.1.0-44-gb53e4ef.tar.zst \ - >keks-"$release"/third-party/libtap-0.1.0-44-gb53e4ef.tar zstd -d <$cur/third-party/monocypher-4.0.2.tar.zst \ >keks-"$release"/third-party/monocypher-4.0.2.tar zstd -d <$cur/third-party/goredo-2.6.4.tar.zst \