forked from dotnet/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert test_stat_fail_alongtheway to a file based test (emscripten-c…
…ore#21138) Also remove the special logging and just use assert which fails fast and gives a backtrace.
- Loading branch information
Showing
3 changed files
with
47 additions
and
71 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,43 @@ | ||
#include <assert.h> | ||
#include <errno.h> | ||
#include <stdio.h> | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <fcntl.h> | ||
#include <string.h> | ||
|
||
int main() { | ||
assert(mkdir("path", 0777) == 0); | ||
assert(close(open("path/file", O_CREAT | O_WRONLY, 0644)) == 0); | ||
{ | ||
struct stat st; | ||
assert(stat("path", &st) == 0); | ||
assert(st.st_mode = 0777); | ||
} | ||
{ | ||
struct stat st; | ||
assert(stat("path/nosuchfile", &st) == -1); | ||
printf("info: errno=%d %s\n", errno, strerror(errno)); | ||
assert(errno == ENOENT); | ||
} | ||
{ | ||
struct stat st; | ||
assert(stat("path/file", &st) == 0); | ||
assert(st.st_mode = 0666); | ||
} | ||
{ | ||
struct stat st; | ||
assert(stat("path/file/impossible", &st) == -1); | ||
printf("info: errno=%d %s\n", errno, strerror(errno)); | ||
assert(errno == ENOTDIR); | ||
} | ||
{ | ||
struct stat st; | ||
assert(lstat("path/file/impossible", &st) == -1); | ||
printf("info: errno=%d %s\n", errno, strerror(errno)); | ||
assert(errno == ENOTDIR); | ||
} | ||
return 0; | ||
} |
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,3 @@ | ||
info: errno=44 No such file or directory | ||
info: errno=54 Not a directory | ||
info: errno=54 Not a directory |
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