mirror of https://github.com/WebAssembly/wasi-sdk
Add tests for assert, abort, and environ. (#105)
To support this, add a mechanism for filtering test output to filter out uninteresting diffs. This adds some coverage for the code being changed in https://github.com/WebAssembly/wasi-libc/pull/184.pull/106/head
parent
79e5760710
commit
b80771e767
@ -1,2 +1,3 @@
|
||||
*.observed
|
||||
*.observed.filtered
|
||||
*.wasm
|
||||
|
@ -0,0 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
abort();
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
134
|
@ -0,0 +1,6 @@
|
||||
Error: failed to run main module `abort.c.---.wasm`
|
||||
|
||||
Caused by:
|
||||
0: failed to invoke `_start`
|
||||
1: wasm trap: unreachable, source location: @----
|
||||
wasm backtrace:
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
cat \
|
||||
| sed -e 's/main module `abort\.c\.[^`]*\.wasm`/main module `abort.c.---.wasm`/' \
|
||||
| sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \
|
||||
| head -n 6
|
@ -0,0 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main(void) {
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
134
|
@ -0,0 +1,7 @@
|
||||
Assertion failed: false (assert-fail.c: main: 5)
|
||||
Error: failed to run main module `assert-fail.c.---.wasm`
|
||||
|
||||
Caused by:
|
||||
0: failed to invoke `_start`
|
||||
1: wasm trap: unreachable, source location: @----
|
||||
wasm backtrace:
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
cat \
|
||||
| sed -e 's/main module `assert-fail\.c\.[^`]*\.wasm`/main module `assert-fail.c.---.wasm`/' \
|
||||
| sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \
|
||||
| head -n 7
|
@ -0,0 +1,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main(void) {
|
||||
assert(true);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
extern char **environ;
|
||||
|
||||
int main(void) {
|
||||
assert(environ != NULL);
|
||||
for (char **p = environ; *p; ++p) {
|
||||
assert(p != NULL);
|
||||
}
|
||||
for (char **p = environ; *p; ++p) {
|
||||
if (strncmp(*p, "HELLO=", 5) == 0) {
|
||||
printf("HELLO = %s\n", *p + 6);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1 @@
|
||||
HELLO=hello
|
@ -0,0 +1 @@
|
||||
HELLO = hello
|
Loading…
Reference in new issue