From e349536f62553b91283633abedbda2d33772286b Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Fri, 15 May 2026 09:00:34 +0900 Subject: [PATCH] test: wire 8 stdlib tests into make test --- Makefile | 38 ++++++++++++++++++++++++++- test/wcc/983_base32_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/984_base64_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/985_adler32_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/986_crc16_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/987_crc32_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/988_crc64_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/989_siphash_run.c | 51 +++++++++++++++++++++++++++++++++++ test/wcc/999_random_run.c | 54 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 448 insertions(+), 1 deletion(-) create mode 100644 test/wcc/983_base32_run.c create mode 100644 test/wcc/984_base64_run.c create mode 100644 test/wcc/985_adler32_run.c create mode 100644 test/wcc/986_crc16_run.c create mode 100644 test/wcc/987_crc32_run.c create mode 100644 test/wcc/988_crc64_run.c create mode 100644 test/wcc/989_siphash_run.c create mode 100644 test/wcc/999_random_run.c diff --git a/Makefile b/Makefile index 627aba2d..db9e94da 100644 --- a/Makefile +++ b/Makefile @@ -229,7 +229,11 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \ $(BIN)/test_w6c_ww $(BIN)/test_ww_ww $(BIN)/test_self_rebuild \ $(BIN)/test_dyn_ww $(BIN)/test_selfcheck $(BIN)/test_at_test_ww \ $(BIN)/test_memio_run $(BIN)/test_temp_run $(BIN)/test_getopt_run \ - $(BIN)/test_bufio_run + $(BIN)/test_base32_run $(BIN)/test_base64_run \ + $(BIN)/test_adler32_run $(BIN)/test_crc16_run \ + $(BIN)/test_crc32_run $(BIN)/test_crc64_run \ + $(BIN)/test_siphash_run \ + $(BIN)/test_bufio_run $(BIN)/test_random_run $(BIN)/test_smoke: test/wcc/000_smoke.c $(LIB)/libwcc.a | $(BIN) $(CC) $(CFLAGS) $(INCS) -o $@ $< -L$(LIB) -lwcc @@ -405,10 +409,42 @@ $(BIN)/test_getopt_run: test/wcc/982_getopt_run.c $(BIN)/ww $(BIN)/w6c \ $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) $(CC) $(CFLAGS) -o $@ $< +$(BIN)/test_base32_run: test/wcc/983_base32_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_base64_run: test/wcc/984_base64_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_adler32_run: test/wcc/985_adler32_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_crc16_run: test/wcc/986_crc16_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_crc32_run: test/wcc/987_crc32_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_crc64_run: test/wcc/988_crc64_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + +$(BIN)/test_siphash_run: test/wcc/989_siphash_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + $(BIN)/test_bufio_run: test/wcc/998_bufio_run.c $(BIN)/ww $(BIN)/w6c \ $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) $(CC) $(CFLAGS) -o $@ $< +$(BIN)/test_random_run: test/wcc/999_random_run.c $(BIN)/ww $(BIN)/w6c \ + $(BIN)/w6a $(BIN)/w6l $(LIB)/libwwrt.a | $(BIN) + $(CC) $(CFLAGS) -o $@ $< + test: all $(TESTS) @WW=$(BIN)/ww BIN=$(BIN) sh test/run diff --git a/test/wcc/983_base32_run.c b/test/wcc/983_base32_run.c new file mode 100644 index 00000000..0ddec4b4 --- /dev/null +++ b/test/wcc/983_base32_run.c @@ -0,0 +1,51 @@ +/* + * 983_base32_run — execute the lib/encoding/base32 @test fixture + * under the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. base32_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/encoding/base32/base32_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "base32_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("base32_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/984_base64_run.c b/test/wcc/984_base64_run.c new file mode 100644 index 00000000..19b2fc91 --- /dev/null +++ b/test/wcc/984_base64_run.c @@ -0,0 +1,51 @@ +/* + * 984_base64_run — execute the lib/encoding/base64 @test fixture + * under the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. base64_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/encoding/base64/base64_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "base64_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("base64_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/985_adler32_run.c b/test/wcc/985_adler32_run.c new file mode 100644 index 00000000..a6651edc --- /dev/null +++ b/test/wcc/985_adler32_run.c @@ -0,0 +1,51 @@ +/* + * 985_adler32_run — execute the lib/hash/adler32 @test fixture + * under the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. adler32_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/hash/adler32/adler32_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "adler32_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("adler32_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/986_crc16_run.c b/test/wcc/986_crc16_run.c new file mode 100644 index 00000000..6976c659 --- /dev/null +++ b/test/wcc/986_crc16_run.c @@ -0,0 +1,51 @@ +/* + * 986_crc16_run — execute the lib/hash/crc16 @test fixture under + * the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. crc16_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/hash/crc16/crc16_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "crc16_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("crc16_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/987_crc32_run.c b/test/wcc/987_crc32_run.c new file mode 100644 index 00000000..d6719b0a --- /dev/null +++ b/test/wcc/987_crc32_run.c @@ -0,0 +1,51 @@ +/* + * 987_crc32_run — execute the lib/hash/crc32 @test fixture under + * the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. crc32_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/hash/crc32/crc32_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "crc32_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("crc32_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/988_crc64_run.c b/test/wcc/988_crc64_run.c new file mode 100644 index 00000000..6c4df5df --- /dev/null +++ b/test/wcc/988_crc64_run.c @@ -0,0 +1,51 @@ +/* + * 988_crc64_run — execute the lib/hash/crc64 @test fixture under + * the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. crc64_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/hash/crc64/crc64_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "crc64_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("crc64_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/989_siphash_run.c b/test/wcc/989_siphash_run.c new file mode 100644 index 00000000..6cf2809c --- /dev/null +++ b/test/wcc/989_siphash_run.c @@ -0,0 +1,51 @@ +/* + * 989_siphash_run — execute the lib/hash/siphash @test fixture + * under the C-side `ww run` driver and assert exit 0. + * + * Sibling to 980_memio_run / 981_temp_run / 982_getopt_run / + * 998_bufio_run. siphash_test.ww carries its own `export fn main()` + * that drives the @test fns and signals which case failed via the + * exit code, so this file is just a thin wrapper — no @test + * scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/hash/siphash/siphash_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "siphash_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("siphash_run: %s ok\n", src); + return 0; +} diff --git a/test/wcc/999_random_run.c b/test/wcc/999_random_run.c new file mode 100644 index 00000000..50080bab --- /dev/null +++ b/test/wcc/999_random_run.c @@ -0,0 +1,54 @@ +/* + * 999_random_run — execute the lib/math/random @test fixture + * under the C-side `ww run` driver and assert exit 0. + * + * Placed at 999 (past the 980-989 stdlib-run sub-band) because + * random number generation exercises many narrow-int cgen paths; + * keeping it numbered at the tail makes its position in the test + * list visually distinct from the small-utility cluster. Sibling + * to 980_memio_run / 998_bufio_run. random_test.ww carries its + * own `export fn main()` that drives the @test fns and signals + * which case failed via the exit code, so this file is just a + * thin wrapper — no @test scanning, no synthetic main generation. + */ +#include +#include +#include +#include + +static int +runwait(const char *cmd) +{ + int rc = system(cmd); + if (rc == -1) return -1; + if (WIFEXITED(rc)) return WEXITSTATUS(rc); + return 1; +} + +int +main(void) +{ + const char *bin = getenv("BIN"); + if (!bin) bin = "out/bin"; + char absbin[1024]; + if (bin[0] != '/') { + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin); + bin = absbin; + } + char cwd[1024]; + if (getcwd(cwd, sizeof cwd) == NULL) return 1; + + const char *src = "lib/math/random/random_test.ww"; + char path[1024], cmd[2048]; + snprintf(path, sizeof path, "%s/%s", cwd, src); + snprintf(cmd, sizeof cmd, "%s/ww run %s", bin, path); + int rc = runwait(cmd); + if (rc != 0) { + fprintf(stderr, "random_run FAIL: %s exited %d\n", src, rc); + return 1; + } + printf("random_run: %s ok\n", src); + return 0; +}