-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add wasi test for symlink() and readlink()
This test provides missing coverage for __wasi_path_symlink() and __wasi_path_readlink(). PR-URL: #31403 Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
2c2b3ba
commit 099c921
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
int main() { | ||
const char* target = "./input.txt"; | ||
const char* linkpath = "/sandbox/subdir/test_link"; | ||
char readlink_result[128]; | ||
size_t result_size = sizeof(readlink_result); | ||
|
||
assert(0 == symlink(target, linkpath)); | ||
assert(readlink(linkpath, readlink_result, result_size) == | ||
strlen(target) + 1); | ||
assert(0 == strcmp(readlink_result, target)); | ||
|
||
FILE* file = fopen(linkpath, "r"); | ||
assert(file != NULL); | ||
|
||
int c = fgetc(file); | ||
while (c != EOF) { | ||
int wrote = fputc(c, stdout); | ||
assert(wrote != EOF); | ||
c = fgetc(file); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.