Skip to content
Snippets Groups Projects
Commit ca62f3ea authored by Fred Wright's avatar Fred Wright Committed by Christopher Nielsen
Browse files

Add tests for alternate realpath() versions.

This ensures that all three versions of realpath() (two in 64-bit
builds) have test coverage.  The test for the impossible 64-bit
non-POSIX case is a dummy.

The 10.15 non-POSIX realpath() has a bug (unrelated to
legacy-support) causing the relevant test to fail.  A subsequent
commit excludes that case from the test.

This test uncovered real bugs in the former wrapper implementation.

TESTED:
Without the realpath() fix, fails on 10.5 and on 10.4 with later SDK.
With the fix, passes on all platforms (except as noted above).
parent b3de412f
No related branches found
No related tags found
No related merge requests found
...@@ -158,6 +158,9 @@ TESTSRUNS := $(patsubst \ ...@@ -158,6 +158,9 @@ TESTSRUNS := $(patsubst \
$(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSPRGS_C)) $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSPRGS_C))
TESTSYSRUNS := $(patsubst \ TESTSYSRUNS := $(patsubst \
$(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSYSPRGS_C)) $(TESTNAMEPREFIX)%,$(TESTRUNPREFIX)%,$(TESTSYSPRGS_C))
REALPATHSRCS_C := $(wildcard $(TESTNAMEPREFIX)realpath*.c)
REALPATHRUNS := $(patsubst \
$(TESTNAMEPREFIX)%.c,$(TESTRUNPREFIX)%,$(REALPATHSRCS_C))
# Tests that are only run manually # Tests that are only run manually
MANTESTDIR = manual_tests MANTESTDIR = manual_tests
...@@ -455,9 +458,16 @@ $(XTESTNAMEPREFIX)darwin_c_full.o: $(XTESTNAMEPREFIX)darwin_c.c ...@@ -455,9 +458,16 @@ $(XTESTNAMEPREFIX)darwin_c_full.o: $(XTESTNAMEPREFIX)darwin_c.c
$(XTESTNAMEPREFIX)scandir_old.o: $(XTESTNAMEPREFIX)scandir.c $(XTESTNAMEPREFIX)scandir_old.o: $(XTESTNAMEPREFIX)scandir.c
$(XTESTNAMEPREFIX)scandir_ino32.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 # Provide a target for all "darwin_c" tests
$(XTESTRUNPREFIX)darwin_c_all: $(DARWINRUNS) $(XTESTRUNPREFIX)darwin_c_all: $(DARWINRUNS)
# Provide a target for all "realpath" tests
$(TESTRUNPREFIX)realpath_all: $(REALPATHRUNS)
$(MANTESTRUNS): $(MANRUNPREFIX)%: $(MANTESTPREFIX)% $(MANTESTRUNS): $(MANRUNPREFIX)%: $(MANTESTPREFIX)%
$< $(TEST_ARGS) $< $(TEST_ARGS)
......
...@@ -15,6 +15,13 @@ ...@@ -15,6 +15,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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 * Deliberately declaring some potentially redefined names
* before including the associated header file, to test robustness. * before including the associated header file, to test robustness.
...@@ -29,6 +36,7 @@ typedef struct { char *realpath; } rpv_t; ...@@ -29,6 +36,7 @@ typedef struct { char *realpath; } rpv_t;
typedef struct { strfunc_t realpath; } rpf_t; typedef struct { strfunc_t realpath; } rpf_t;
#include <assert.h> #include <assert.h>
#include <libgen.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -88,6 +96,6 @@ main(int argc, char *argv[]) ...@@ -88,6 +96,6 @@ main(int argc, char *argv[])
if (verbose) printf("rpv.realpath = rpf.realpath(path, NULL) supported.\n"); if (verbose) printf("rpv.realpath = rpf.realpath(path, NULL) supported.\n");
free((void*)rpv.realpath); free((void*)rpv.realpath);
printf("realpath test succeeded.\n"); printf("%s succeeded.\n", basename(argv[0]));
return 0; return 0;
} }
/*
* Version of test_realpath with Darwin extensions disabled.
*/
#define _POSIX_C_SOURCE 200112L
#include "test_realpath.c"
/*
* 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment