libredirect: add tests for new wrappers

This commit is contained in:
Noah Fontes 2023-01-26 12:06:46 -08:00
parent eb620ff9f7
commit 2cfe8451ed
No known key found for this signature in database
GPG key ID: 85B8C0A0B15FF53F

View file

@ -63,6 +63,12 @@ int main(int argc, char *argv[])
FILE *testfp;
int testfd;
struct stat testsb;
#ifndef __APPLE__
struct stat64 testsb64;
#endif
#ifdef __linux__
struct statx testsbx;
#endif
char buf[PATH_MAX];
testfp = fopen(TESTPATH, "r");
@ -76,6 +82,20 @@ int main(int argc, char *argv[])
assert(access(TESTPATH, X_OK) == 0);
assert(stat(TESTPATH, &testsb) != -1);
#ifndef __APPLE__
assert(stat64(TESTPATH, &testsb64) != -1);
#endif
assert(fstatat(123, TESTPATH, &testsb, 0) != -1);
#ifndef __APPLE__
assert(fstatat64(123, TESTPATH, &testsb64, 0) != -1);
#endif
#ifdef __linux__
assert(statx(123, TESTPATH, 0, STATX_ALL, &testsbx) != -1);
#endif
assert(getcwd(buf, PATH_MAX) != NULL);
assert(chdir(TESTDIR) == 0);
assert(chdir(buf) == 0);
assert(mkdir(TESTDIR "/dir-mkdir", 0777) == 0);
assert(unlink(TESTDIR "/dir-mkdir") == -1); // it's a directory!