Changeset 2547
- Timestamp:
- Mar 2, 2006, 2:24:50 AM (19 years ago)
- Location:
- branches/libc-0.6/src/libctests/libc
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/libc-0.6/src/libctests/libc/Makefile ¶
r2546 r2547 96 96 smoketests/fchmod-1.c \ 97 97 smoketests/nonblock-1.c \ 98 smoketests/fclose- 1.c98 smoketests/fclose-2.c 99 99 100 100 # smoketests/weak-export-1.c - dll -
TabularUnified branches/libc-0.6/src/libctests/libc/smoketests/fclose-1.c ¶
r2546 r2547 40 40 int fChild = 0; 41 41 42 #define CHECK(expr) do { int rc2 = expr; if (rc2) { fprintf(pFile, "fclose-1: %d: %s failed rc2=%d\n", __LINE__, #expr, rc2); rc = 1; } } while (0) 42 #define CHECK(expr) \ 43 do { int rc2 = expr; if (rc2) { fprintf(pFile, "fclose-1: %d: %s failed rc2=%d\n", __LINE__, #expr, rc2); rc = 1; } } while (0) 44 #define CHECKERRNO(expr, err) \ 45 do { int rc2; \ 46 errno = 0; \ 47 rc2 = expr; \ 48 if (rc2 != -1) { fprintf(pFile, "fclose-1: %d: %s didn't fail! rc2=%d\n", __LINE__, #expr, rc2); rc = 1; } \ 49 else if (errno != err) { fprintf(pFile, "fclose-1: %d: %s expected errno=%d got %d: %s\n", __LINE__, #expr, err, errno, strerror(errno)); rc = 1; } \ 50 } while (0) 51 43 52 if (argc == 2 && !strcmp(argv[1], "!child!")) 44 53 { … … 64 73 65 74 CHECK(fclose(stdout)); 66 CHECK (fclose(stdout) != -1 ? -1 : 0);75 CHECKERRNO(fclose(stdout), 0 /* unspecified, follow glibc. */); 67 76 68 77 pid = fork(); … … 72 81 CHECK(fflush(stdout)); 73 82 CHECK(fflush(stderr)); 74 CHECK (fclose(stdout) != -1 ? -1 : 0);83 CHECKERRNO(fclose(stdout), EBADF); 75 84 CHECK(fflush(stdout)); 76 85 77 CHECK (fprintf(stdout, "fail0") != -1 ? -1 : 0);86 CHECKERRNO(fprintf(stdout, "fail0"), EBADF); 78 87 if (fd >= 0) 79 88 CHECK(dup2(fd, STDOUT_FILENO) != STDOUT_FILENO ? -1 : 0); 80 CHECK (fprintf(stdout, "fail1") != -1 ? -1 : 0);89 CHECKERRNO(fprintf(stdout, "fail1"), EBADF); 81 90 CHECK(fflush(stdout)); 82 CHECK(freopen(NULL, "w", stdout) ? -1 : 0); 83 CHECK(close(STDOUT_FILENO)); 91 /*CHECKERRNO(freopen(NULL, "w", stdout) ? 0 : -1, EBADF);*/ 84 92 85 93 if (!fChild) 86 94 { 95 CHECK(close(STDOUT_FILENO)); 87 96 execl(argv[0], argv[0], "!child!", NULL); 88 97 CHECK(-1/*exec failed*/);
Note:
See TracChangeset
for help on using the changeset viewer.