Files
huntedbytheirsandSisyphus 370e64c3a6 Add smoke test and benchmarks
smoke links crt0.o + libc.a with -nostdlib -static and proves the whole chain runs without the dynamic linker; bench_strlen and bench_syscall measure the string core and raw syscall round-trip cost via make bench.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <[email protected]>
2026-08-30 04:09:45 -04:00

31 lines
756 B
C

/*
* smoke.c — end-to-end smoke test.
*
* Linked with crt0.o + libc.a, -nostdlib -static: if this binary runs at
* all, the whole chain works — entry point, main(), our string code, and
* raw syscalls — with no dynamic linker and no glibc in the process.
*/
#include <string.h>
#include <unistd.h>
int main(void)
{
static const char msg[] = "nulsl-libc smoke test: ok\n";
if (strcmp("abc", "abc") != 0)
return 1;
if (strcmp("abc", "abd") == 0)
return 2;
if (strncmp("abcdef", "abcxyz", 3) != 0)
return 3;
if (strlen("nulsl") != 5)
return 4;
if (memcmp("abcd", "abce", 3) != 0)
return 5;
if (write(STDOUT_FILENO, msg, sizeof msg - 1) < 0)
return 6;
return 0;
}