@@ -6122,77 +6122,7 @@ def test(opts, has, not_has):
61226122 test(['-sEXPORTED_RUNTIME_METHODS=[]', '-sEXPORTED_RUNTIME_METHODS=addRunDependency'], "Module['addRunDependency", "Module['waka")
61236123
61246124 def test_stat_fail_alongtheway(self):
6125- create_file('src.c', r'''
6126- #include <errno.h>
6127- #include <stdio.h>
6128- #include <sys/types.h>
6129- #include <sys/stat.h>
6130- #include <unistd.h>
6131- #include <stdlib.h>
6132- #include <fcntl.h>
6133- #include <string.h>
6134-
6135- #define CHECK(expression) \
6136- if(!(expression)) { \
6137- error = errno; \
6138- printf("FAIL: %s\n", #expression); fail = 1; \
6139- } else { \
6140- error = errno; \
6141- printf("pass: %s\n", #expression); \
6142- } \
6143-
6144- int main() {
6145- int error;
6146- int fail = 0;
6147- CHECK(mkdir("path", 0777) == 0);
6148- CHECK(close(open("path/file", O_CREAT | O_WRONLY, 0644)) == 0);
6149- {
6150- struct stat st;
6151- CHECK(stat("path", &st) == 0);
6152- CHECK(st.st_mode = 0777);
6153- }
6154- {
6155- struct stat st;
6156- CHECK(stat("path/nosuchfile", &st) == -1);
6157- printf("info: errno=%d %s\n", error, strerror(error));
6158- CHECK(error == ENOENT);
6159- }
6160- {
6161- struct stat st;
6162- CHECK(stat("path/file", &st) == 0);
6163- CHECK(st.st_mode = 0666);
6164- }
6165- {
6166- struct stat st;
6167- CHECK(stat("path/file/impossible", &st) == -1);
6168- printf("info: errno=%d %s\n", error, strerror(error));
6169- CHECK(error == ENOTDIR);
6170- }
6171- {
6172- struct stat st;
6173- CHECK(lstat("path/file/impossible", &st) == -1);
6174- printf("info: errno=%d %s\n", error, strerror(error));
6175- CHECK(error == ENOTDIR);
6176- }
6177- return fail;
6178- }
6179- ''')
6180- self.do_runf('src.c', r'''pass: mkdir("path", 0777) == 0
6181- pass: close(open("path/file", O_CREAT | O_WRONLY, 0644)) == 0
6182- pass: stat("path", &st) == 0
6183- pass: st.st_mode = 0777
6184- pass: stat("path/nosuchfile", &st) == -1
6185- info: errno=44 No such file or directory
6186- pass: error == ENOENT
6187- pass: stat("path/file", &st) == 0
6188- pass: st.st_mode = 0666
6189- pass: stat("path/file/impossible", &st) == -1
6190- info: errno=54 Not a directory
6191- pass: error == ENOTDIR
6192- pass: lstat("path/file/impossible", &st) == -1
6193- info: errno=54 Not a directory
6194- pass: error == ENOTDIR
6195- ''')
6125+ self.do_other_test('test_stat_fail_alongtheway.c')
61966126
61976127 def test_link_with_a_static(self):
61986128 create_file('x.c', r'''
0 commit comments