Skip to content

Commit b80771e

Browse files
authored
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 WebAssembly/wasi-libc#184.
1 parent 79e5760 commit b80771e

14 files changed

+86
-0
lines changed

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.observed
2+
*.observed.filtered
23
*.wasm

tests/general/abort.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdlib.h>
2+
3+
int main(void) {
4+
abort();
5+
return 0;
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
134
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Error: failed to run main module `abort.c.---.wasm`
2+
3+
Caused by:
4+
0: failed to invoke `_start`
5+
1: wasm trap: unreachable, source location: @----
6+
wasm backtrace:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cat \
5+
| sed -e 's/main module `abort\.c\.[^`]*\.wasm`/main module `abort.c.---.wasm`/' \
6+
| sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \
7+
| head -n 6

tests/general/assert-fail.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <assert.h>
2+
#include <stdbool.h>
3+
4+
int main(void) {
5+
assert(false);
6+
return 0;
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
134
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Assertion failed: false (assert-fail.c: main: 5)
2+
Error: failed to run main module `assert-fail.c.---.wasm`
3+
4+
Caused by:
5+
0: failed to invoke `_start`
6+
1: wasm trap: unreachable, source location: @----
7+
wasm backtrace:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cat \
5+
| sed -e 's/main module `assert-fail\.c\.[^`]*\.wasm`/main module `assert-fail.c.---.wasm`/' \
6+
| sed -e 's/source location: @[[:xdigit:]]*$/source location: @----/' \
7+
| head -n 7

tests/general/assert-pass.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <assert.h>
2+
#include <stdbool.h>
3+
4+
int main(void) {
5+
assert(true);
6+
return 0;
7+
}

0 commit comments

Comments
 (0)