test: wire 8 stdlib tests into make test

This commit is contained in:
2026-05-15 09:00:34 +09:00
parent 075da790a4
commit e349536f62
9 changed files with 448 additions and 1 deletions

View File

@@ -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

51
test/wcc/983_base32_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

51
test/wcc/984_base64_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

51
test/wcc/986_crc16_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

51
test/wcc/987_crc32_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

51
test/wcc/988_crc64_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}

54
test/wcc/999_random_run.c Normal file
View File

@@ -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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
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;
}