Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: add wasi test for freopen()
This test provides missing coverage for __wasi_fd_renumber().
  • Loading branch information
cjihrig committed Jan 23, 2020
commit 1dc6d2f0c44ea1f93ebc1306632e92719726004d
1 change: 1 addition & 0 deletions test/fixtures/wasi/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello from input2.txt
16 changes: 16 additions & 0 deletions test/wasi/c/freopen.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <assert.h>
#include <stdio.h>

int main() {
FILE* file_orig = fopen("/sandbox/input.txt", "r");
assert(file_orig != NULL);
FILE* file_new = freopen("/sandbox/input2.txt", "r", file_orig);
assert(file_new != NULL);

int c = fgetc(file_new);
while (c != EOF) {
int wrote = fputc((char)c, stdout);
assert(wrote != EOF);
c = fgetc(file_new);
}
}
1 change: 1 addition & 0 deletions test/wasi/test-wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if (process.argv[2] === 'wasi-child') {
runWASI({ test: 'clock_getres' });
runWASI({ test: 'exitcode', exitCode: 120 });
runWASI({ test: 'fd_prestat_get_refresh' });
runWASI({ test: 'freopen', stdout: `hello from input2.txt${EOL}` });
runWASI({ test: 'getentropy' });
runWASI({ test: 'getrusage' });
runWASI({ test: 'gettimeofday' });
Expand Down
Binary file added test/wasi/wasm/freopen.wasm
Binary file not shown.