From eb8dd9dca1228af0cd132f515509051ecfabf6f6 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 14 Apr 2025 17:32:06 +0000 Subject: This commit was manufactured by cvs2git to create tag 'tb_20250414'. --- src/regress/lib/libc/dirname/Makefile | 3 -- src/regress/lib/libc/dirname/dirname_test.c | 81 ----------------------------- 2 files changed, 84 deletions(-) delete mode 100644 src/regress/lib/libc/dirname/Makefile delete mode 100644 src/regress/lib/libc/dirname/dirname_test.c (limited to 'src/regress/lib/libc/dirname') diff --git a/src/regress/lib/libc/dirname/Makefile b/src/regress/lib/libc/dirname/Makefile deleted file mode 100644 index fc152df954..0000000000 --- a/src/regress/lib/libc/dirname/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PROG=dirname_test - -.include diff --git a/src/regress/lib/libc/dirname/dirname_test.c b/src/regress/lib/libc/dirname/dirname_test.c deleted file mode 100644 index 250b4def66..0000000000 --- a/src/regress/lib/libc/dirname/dirname_test.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2007 Bret S. Lambert - * - * Public domain. - */ - -#include -#include -#include -#include -#include -#include - -int -main(void) -{ - char path[2 * PATH_MAX]; - char dname[128]; - const char *dir = "junk"; - const char *fname = "/file.name.ext"; - char *str; - int i; - - /* Test normal functioning */ - strlcpy(path, "/", sizeof(path)); - strlcpy(dname, "/", sizeof(dname)); - strlcat(path, dir, sizeof(path)); - strlcat(dname, dir, sizeof(dname)); - strlcat(path, fname, sizeof(path)); - str = dirname(path); - if (strcmp(str, dname) != 0) - errx(1, "0: dirname(%s) = %s != %s", path, str, dname); - - /* - * There are four states that require special handling: - * - * 1) path is NULL - * 2) path is the empty string - * 3) path is composed entirely of slashes - * 4) the resulting name is larger than PATH_MAX - * - * The first two cases require that a pointer - * to the string "." be returned. - * - * The third case requires that a pointer - * to the string "/" be returned. - * - * The final case requires that NULL be returned - * and errno * be set to ENAMETOOLONG. - */ - /* Case 1 */ - str = dirname(NULL); - if (strcmp(str, ".") != 0) - errx(1, "1: dirname(NULL) = %s != .", str); - - /* Case 2 */ - strlcpy(path, "", sizeof(path)); - str = dirname(path); - if (strcmp(str, ".") != 0) - errx(1, "2: dirname(%s) = %s != .", path, str); - - /* Case 3 */ - for (i = 0; i < PATH_MAX - 1; i++) - strlcat(path, "/", sizeof(path)); /* path cleared above */ - str = dirname(path); - if (strcmp(str, "/") != 0) - errx(1, "3: dirname(%s) = %s != /", path, str); - - /* Case 4 */ - strlcpy(path, "/", sizeof(path)); /* reset path */ - for (i = 0; i <= PATH_MAX; i += strlen(dir)) - strlcat(path, dir, sizeof(path)); - strlcat(path, fname, sizeof(path)); - str = dirname(path); - if (str != NULL) - errx(1, "4: dirname(%s) = %s != NULL", path, str); - if (errno != ENAMETOOLONG) - errx(1, "4: dirname(%s) sets errno to %d", path, errno); - - return (0); -} -- cgit v1.2.3-55-g6feb