testsuite/nfs: Check the path returned by getcwd

This commit is contained in:
Chris Johns
2023-08-06 15:49:31 +10:00
parent fdde806c50
commit afc6ad0525

View File

@@ -317,21 +317,28 @@ static void
test_path_eval(const char *base, int depth) test_path_eval(const char *base, int depth)
{ {
char path[MAXPATHLEN]; char path[MAXPATHLEN];
char curpath[MAXPATHLEN];
char getpath[MAXPATHLEN];
int l; int l;
printf("test path eval\n"); printf("test path eval: %s\n", base);
test_setup(base); test_setup(base);
sprintf(curpath, "%s/%s", base, test_top);
for (l = 1; l <= depth; ++l) { for (l = 1; l <= depth; ++l) {
snprintf(path, sizeof(path), "%d", l); snprintf(path, sizeof(path), "%d", l);
printf("test: nfs: mkdir: %s\n", path); strcat(curpath, "/");
strcat(curpath, path);
printf("test: nfs: mkdir: %s (%s)\n", path, curpath);
rtems_test_errno_assert(mkdir(path, 0777) == 0); rtems_test_errno_assert(mkdir(path, 0777) == 0);
printf("test: nfs: chdir: %s\n", path); printf("test: nfs: chdir: %s (%s)\n", path, curpath);
rtems_test_errno_assert(chdir(path) == 0); rtems_test_errno_assert(chdir(path) == 0);
printf("test: nfs: getcwd: %s\n", path); printf("test: nfs: getcwd: %s (%s)\n", path, curpath);
assert(getcwd(path, sizeof(path)) != NULL); assert(getcwd(getpath, sizeof(getpath)) != NULL);
printf("test: nfs: getcwd: %s\n", path); printf("test: nfs: getcwd: %s (want: %s)\n", getpath, curpath);
assert(strcmp(curpath, getpath) == 0);
} }
test_cleanup(base); test_cleanup(base);