000_smoke drops its popen ww -V leg (driver version parity moves to 949_driver_flagargs); 400_w6c feeds its sources through lex/parse/ check/cgen into open_memstream instead of spawning w6c. The five unit binaries now hold zero subprocess calls.
53 lines
987 B
C
53 lines
987 B
C
/*
|
|
* 000_smoke — Phase 0 smoke test.
|
|
*
|
|
* Asserts arena allocation and growth through libwcc, plus the configured
|
|
* version constant. Driver behavior belongs to the driver integration tests.
|
|
*/
|
|
#include "ww.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
static void
|
|
test_arena(void)
|
|
{
|
|
Arena *a = newarena();
|
|
if (a == NULL) {
|
|
fprintf(stderr, "smoke: newarena returned NULL\n");
|
|
exit(1);
|
|
}
|
|
int *p = amalloc(a, sizeof *p);
|
|
*p = 42;
|
|
if (*p != 42) {
|
|
fprintf(stderr, "smoke: arena alloc bad\n");
|
|
exit(1);
|
|
}
|
|
/* force several growths */
|
|
for (int i = 0; i < 10000; i++) {
|
|
char *s = aprintf(a, "hello-%d", i);
|
|
if (s == NULL || strncmp(s, "hello-", 6) != 0) {
|
|
fprintf(stderr, "smoke: aprintf bad\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
freearena(a);
|
|
}
|
|
|
|
static void
|
|
test_version(void)
|
|
{
|
|
if (WW_VERSION == NULL || WW_VERSION[0] == '\0') {
|
|
fprintf(stderr, "smoke: empty WW_VERSION\n");
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
int
|
|
main(void)
|
|
{
|
|
test_arena();
|
|
test_version();
|
|
puts("smoke: ok");
|
|
return 0;
|
|
}
|