diff options
| author | miod <> | 2007-10-20 12:37:09 +0000 |
|---|---|---|
| committer | miod <> | 2007-10-20 12:37:09 +0000 |
| commit | f3fcdb0a92dbfed3956fed57bb7bc2715f06944c (patch) | |
| tree | 20f41b46a794f8426b200cbffc8d5bb5adc026e8 /src | |
| parent | 1af04725f287a6fe50818cb67f9b2b7b6e664249 (diff) | |
| download | openbsd-f3fcdb0a92dbfed3956fed57bb7bc2715f06944c.tar.gz openbsd-f3fcdb0a92dbfed3956fed57bb7bc2715f06944c.tar.bz2 openbsd-f3fcdb0a92dbfed3956fed57bb7bc2715f06944c.zip | |
Give more details on failure.
Diffstat (limited to 'src')
| -rw-r--r-- | src/regress/lib/libc/dirname/dirname_test.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/regress/lib/libc/dirname/dirname_test.c b/src/regress/lib/libc/dirname/dirname_test.c index 0dd95d6c30..add76980cf 100644 --- a/src/regress/lib/libc/dirname/dirname_test.c +++ b/src/regress/lib/libc/dirname/dirname_test.c | |||
| @@ -30,7 +30,7 @@ main(void) | |||
| 30 | strlcat(path, fname, sizeof(path)); | 30 | strlcat(path, fname, sizeof(path)); |
| 31 | str = dirname(path); | 31 | str = dirname(path); |
| 32 | if (strcmp(str, dname) != 0) | 32 | if (strcmp(str, dname) != 0) |
| 33 | goto fail; | 33 | errx(1, "0: dirname(%s) = %s != %s", path, str, dname); |
| 34 | 34 | ||
| 35 | /* | 35 | /* |
| 36 | * There are four states that require special handling: | 36 | * There are four states that require special handling: |
| @@ -52,20 +52,20 @@ main(void) | |||
| 52 | /* Case 1 */ | 52 | /* Case 1 */ |
| 53 | str = dirname(NULL); | 53 | str = dirname(NULL); |
| 54 | if (strcmp(str, ".") != 0) | 54 | if (strcmp(str, ".") != 0) |
| 55 | goto fail; | 55 | errx(1, "1: dirname(NULL) = %s != .", str); |
| 56 | 56 | ||
| 57 | /* Case 2 */ | 57 | /* Case 2 */ |
| 58 | strlcpy(path, "", sizeof(path)); | 58 | strlcpy(path, "", sizeof(path)); |
| 59 | str = dirname(path); | 59 | str = dirname(path); |
| 60 | if (strcmp(str, ".") != 0) | 60 | if (strcmp(str, ".") != 0) |
| 61 | goto fail; | 61 | errx(1, "2: dirname(%s) = %s != .", path, str); |
| 62 | 62 | ||
| 63 | /* Case 3 */ | 63 | /* Case 3 */ |
| 64 | for (i = 0; i < MAXPATHLEN - 1; i++) | 64 | for (i = 0; i < MAXPATHLEN - 1; i++) |
| 65 | strlcat(path, "/", sizeof(path)); /* path cleared above */ | 65 | strlcat(path, "/", sizeof(path)); /* path cleared above */ |
| 66 | str = dirname(path); | 66 | str = dirname(path); |
| 67 | if (strcmp(str, "/") != 0) | 67 | if (strcmp(str, "/") != 0) |
| 68 | goto fail; | 68 | errx(1, "3: dirname(%s) = %s != /", path, str); |
| 69 | 69 | ||
| 70 | /* Case 4 */ | 70 | /* Case 4 */ |
| 71 | strlcpy(path, "/", sizeof(path)); /* reset path */ | 71 | strlcpy(path, "/", sizeof(path)); /* reset path */ |
| @@ -73,10 +73,10 @@ main(void) | |||
| 73 | strlcat(path, dir, sizeof(path)); | 73 | strlcat(path, dir, sizeof(path)); |
| 74 | strlcat(path, fname, sizeof(path)); | 74 | strlcat(path, fname, sizeof(path)); |
| 75 | str = dirname(path); | 75 | str = dirname(path); |
| 76 | if (str != NULL || errno != ENAMETOOLONG) | 76 | if (str != NULL) |
| 77 | goto fail; | 77 | errx(1, "4: dirname(%s) = %s != NULL", path, str); |
| 78 | if (errno != ENAMETOOLONG) | ||
| 79 | errx(1, "4: dirname(%s) sets errno to %d", path, errno); | ||
| 78 | 80 | ||
| 79 | return (0); | 81 | return (0); |
| 80 | fail: | ||
| 81 | return (1); | ||
| 82 | } | 82 | } |
