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

test_realpath: Add test for legacy compatibility entry.

This tests the macports_legacy_realpath() entry point, which is no
longer used by new builds but possibly referenced by old builds.

TESTED:
Passes on all platforms; fails when the legacy entry is disabled.
parent 833254fb
No related branches found
No related tags found
No related merge requests found
......@@ -461,6 +461,7 @@ $(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
$(TESTNAMEPREFIX)realpath_compat.o: $(TESTNAMEPREFIX)realpath.c
# Provide a target for all "darwin_c" tests
$(XTESTRUNPREFIX)darwin_c_all: $(DARWINRUNS)
......
......@@ -44,14 +44,25 @@ typedef struct { strfunc_t realpath; } rpf_t;
#include <sys/param.h>
/*
* Allow testing the legacy compatibility entry.
* We use a simple argless macro and disable the fancier tests.
*/
#ifdef TEST_MACPORTS_LEGACY_REALPATH
#define realpath macports_legacy_realpath
extern char *realpath(const char * __restrict, char * __restrict);
#endif
int
main(int argc, char *argv[])
{
int verbose = 0;
const char *p, *q;
#ifndef TEST_MACPORTS_LEGACY_REALPATH
strfunc_t f;
rpf_t rpf = { realpath };
rpv_t rpv;
#endif /* !TEST_MACPORTS_LEGACY_REALPATH */
char buf[PATH_MAX], cwd[MAXPATHLEN];
if (argc > 1 && !strcmp(argv[1], "-v")) verbose = 1;
......@@ -74,6 +85,7 @@ main(int argc, char *argv[])
if (verbose) printf("realpath(path, NULL) supported.\n");
free((void*)q);
#ifndef TEST_MACPORTS_LEGACY_REALPATH
/* Test with name (reference) only */
f = realpath;
q = f(".", NULL);
......@@ -95,6 +107,7 @@ main(int argc, char *argv[])
assert (!strcmp(rpv.realpath, p) && "rpf.realpath(path, NULL) miscompared");
if (verbose) printf("rpv.realpath = rpf.realpath(path, NULL) supported.\n");
free((void*)rpv.realpath);
#endif /* !TEST_MACPORTS_LEGACY_REALPATH */
printf("%s succeeded.\n", basename(argv[0]));
return 0;
......
/*
* Version of test_realpath for compatibility entry.
*/
/*
* This tests the macports_legacy_realpath() compatibility entry.
*
* For OS versions that never used the wrapper, this entire test is a dummy.
* Because of that condition, this test is an exception to the rule that tests
* shouldn't check the feature flags.
*/
/* MP support header */
#include "MacportsLegacySupport.h"
#if __MPLS_LIB_SUPPORT_REALPATH_WRAP__
#define TEST_MACPORTS_LEGACY_REALPATH
#include "test_realpath.c"
#else /* !__MPLS_LIB_SUPPORT_REALPATH_WRAP__ */
int main(){ return 0; }
#endif /* !__MPLS_LIB_SUPPORT_REALPATH_WRAP__ */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment