diff --git a/Makefile b/Makefile index 9b4abf262fd2602f4c7484d659f3cb8ade047d7a..2dae10a6b4a6b9499a2d5f42cdfe3751f0e01ccb 100644 --- a/Makefile +++ b/Makefile @@ -158,6 +158,9 @@ TESTSRUNS := $(patsubst \ $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSPRGS_C)) TESTSYSRUNS := $(patsubst \ $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSYSPRGS_C)) +REALPATHSRCS_C := $(wildcard $(TESTNAMEPREFIX)realpath*.c) +REALPATHRUNS := $(patsubst \ + $(TESTNAMEPREFIX)%.c,$(TESTRUNPREFIX)%,$(REALPATHSRCS_C)) # Tests that are only run manually MANTESTDIR = manual_tests @@ -455,9 +458,16 @@ $(XTESTNAMEPREFIX)darwin_c_full.o: $(XTESTNAMEPREFIX)darwin_c.c $(XTESTNAMEPREFIX)scandir_old.o: $(XTESTNAMEPREFIX)scandir.c $(XTESTNAMEPREFIX)scandir_ino32.o: $(XTESTNAMEPREFIX)scandir.c +# The nonstandard realpath tests include the realpath source +$(TESTNAMEPREFIX)realpath_nonext.o: $(TESTNAMEPREFIX)realpath.c +$(TESTNAMEPREFIX)realpath_nonposix.o: $(TESTNAMEPREFIX)realpath.c + # Provide a target for all "darwin_c" tests $(XTESTRUNPREFIX)darwin_c_all: $(DARWINRUNS) +# Provide a target for all "realpath" tests +$(TESTRUNPREFIX)realpath_all: $(REALPATHRUNS) + $(MANTESTRUNS): $(MANRUNPREFIX)%: $(MANTESTPREFIX)% $< $(TEST_ARGS) diff --git a/test/test_realpath.c b/test/test_realpath.c index ad71421dcc742a0d1422c64f60a274da0fd1d6ae..8fcffd209f5c52d5b65df5e6322263403a0fafe6 100644 --- a/test/test_realpath.c +++ b/test/test_realpath.c @@ -15,6 +15,13 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +/* + * NOTE: Much of the complexity in this test is left over from an earlier + * implementation that used a wrapper macro instead of a wrapper function. + * Macro-related issues are no longer important to test, though the extra + * tests haven't been removed. + */ + /* * Deliberately declaring some potentially redefined names * before including the associated header file, to test robustness. @@ -29,6 +36,7 @@ typedef struct { char *realpath; } rpv_t; typedef struct { strfunc_t realpath; } rpf_t; #include <assert.h> +#include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -88,6 +96,6 @@ main(int argc, char *argv[]) if (verbose) printf("rpv.realpath = rpf.realpath(path, NULL) supported.\n"); free((void*)rpv.realpath); - printf("realpath test succeeded.\n"); + printf("%s succeeded.\n", basename(argv[0])); return 0; } diff --git a/test/test_realpath_nonext.c b/test/test_realpath_nonext.c new file mode 100644 index 0000000000000000000000000000000000000000..0305a65102b095b15947c65d1f971bb70e46e061 --- /dev/null +++ b/test/test_realpath_nonext.c @@ -0,0 +1,7 @@ +/* + * Version of test_realpath with Darwin extensions disabled. + */ + +#define _POSIX_C_SOURCE 200112L + +#include "test_realpath.c" diff --git a/test/test_realpath_nonposix.c b/test/test_realpath_nonposix.c new file mode 100644 index 0000000000000000000000000000000000000000..9870aac45770eda7344a3c86dc232b95d11ab6f1 --- /dev/null +++ b/test/test_realpath_nonposix.c @@ -0,0 +1,23 @@ +/* + * Version of test_realpath with non-POSIX semantics (32-bit only). + */ + +#if !defined(__LP64__) || !__LP64__ + +#define _NONSTD_SOURCE +#include "test_realpath.c" + +#else + +#include <libgen.h> +#include <stdio.h> + +int +main(int argc, char *argv[]) +{ + (void) argc; + printf("%s is inapplicable.\n", basename(argv[0])); + return 0; +} + +#endif