Changeset 2547


Ignore:
Timestamp:
Mar 2, 2006, 2:24:50 AM (19 years ago)
Author:
bird
Message:

fclose / flush testcase.

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  
    9696        smoketests/fchmod-1.c \
    9797        smoketests/nonblock-1.c \
    98         smoketests/fclose-1.c
     98        smoketests/fclose-2.c
    9999       
    100100#       smoketests/weak-export-1.c - dll
  • TabularUnified branches/libc-0.6/src/libctests/libc/smoketests/fclose-1.c

    r2546 r2547  
    4040    int   fChild = 0;
    4141
    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
    4352    if (argc == 2 && !strcmp(argv[1], "!child!"))
    4453    {
     
    6473
    6574        CHECK(fclose(stdout));
    66         CHECK(fclose(stdout) != -1 ? -1 : 0);
     75        CHECKERRNO(fclose(stdout), 0 /* unspecified, follow glibc. */);
    6776
    6877        pid = fork();
     
    7281        CHECK(fflush(stdout));
    7382        CHECK(fflush(stderr));
    74         CHECK(fclose(stdout) != -1 ? -1 : 0);
     83        CHECKERRNO(fclose(stdout), EBADF);
    7584        CHECK(fflush(stdout));
    7685
    77         CHECK(fprintf(stdout, "fail0") != -1 ? -1 : 0);
     86        CHECKERRNO(fprintf(stdout, "fail0"), EBADF);
    7887        if (fd >= 0)
    7988            CHECK(dup2(fd, STDOUT_FILENO) != STDOUT_FILENO ? -1 : 0);
    80         CHECK(fprintf(stdout, "fail1") != -1 ? -1 : 0);
     89        CHECKERRNO(fprintf(stdout, "fail1"), EBADF);
    8190        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);*/
    8492
    8593        if (!fChild)
    8694        {
     95            CHECK(close(STDOUT_FILENO));
    8796            execl(argv[0], argv[0], "!child!", NULL);
    8897            CHECK(-1/*exec failed*/);
Note: See TracChangeset for help on using the changeset viewer.