Changeset 1674 for trunk/src/emx/testcase
- Timestamp:
- Dec 1, 2004, 2:37:40 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/testcase/libc/miscinnotek/fsinternals.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1673 r1674 2 2 #include <string.h> 3 3 #include <errno.h> 4 5 int __libc_back_fsResolve(const char *pszUserPath, unsigned fFlags, char *pszNativePath, int *pfInUnixTree); 6 7 /** __libc_back_fsResolve() flags. 8 * @{ */ 9 /** Resolves the path up to but not including the last component. */ 10 #define BACKFS_FLAGS_RESOLVE_PARENT 0x1 11 /** Resolves and verfies the entire path. */ 12 #define BACKFS_FLAGS_RESOLVE_FULL 0x2 13 /** Resolves and verfies the entire path but it's ok if the last component doesn't exist. */ 14 #define BACKFS_FLAGS_RESOLVE_FULL_MAYBE 0x3 15 /** @} */ 4 #include "../../../src/lib/sys/b_fs.h" 16 5 17 6 18 int main (int argc, char *argv[]) 7 /** 8 * Do one call, check and report the result. 9 */ 10 static int testit(const char *pszPath, unsigned fFlags, int rcCorrect) 19 11 { 20 12 char szNativePath[300]; … … 22 14 23 15 memset(szNativePath, 0xAA, sizeof(szNativePath)); 16 szNativePath[sizeof(szNativePath) - 1] = '\0'; 24 17 errno = 0; 25 rc = __libc_back_fsResolve(".", BACKFS_FLAGS_RESOLVE_FULL, szNativePath, NULL); 26 printf("+ '.' -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath); 18 rc = __libc_back_fsResolve(pszPath, fFlags, szNativePath, NULL); 19 if (errno != 0) 20 printf("FAILURE: flags=%#02x path='%s' -> rc=%d errno=%d szNativePath='%s' ERRNO CHANGED!\n", fFlags, pszPath, rc, errno, szNativePath); 21 else if (!rcCorrect) 22 { 23 /* 24 * Positive test. 25 */ 26 if (!rc) 27 { 28 if (!strchr(szNativePath, 0xAA)) 29 { 30 printf("SUCCESS: flags=%#02x path='%s' -> szNativePath='%s'\n", fFlags, pszPath, szNativePath); 31 return 0; 32 } 33 else 34 printf("FAILURE: flags=%#02x path='%s' -> rc=%d szNativePath='%s' PADDING!\n", fFlags, pszPath, rc, szNativePath); 35 } 36 else 37 printf("FAILURE: flags=%#02x path='%s' -> rc=%d szNativePath='%s' (failed)\n", fFlags, pszPath, rc, szNativePath); 38 } 39 else 40 { 41 /* 42 * Negative test. 43 */ 44 if (rc == rcCorrect) 45 { 46 printf("SUCCESS: flags=%#02x path='%s' -> rc=%d (negative)\n", fFlags, pszPath, rc); 47 return 0; 48 } 49 else 50 printf("FAILURE: flags=%#02x path='%s' -> rc=%d not %d! (negative)\n", fFlags, pszPath, rc, rcCorrect); 51 } 52 return 1; 53 } 27 54 28 memset(szNativePath, 0xAA, sizeof(szNativePath));29 errno = 0;30 rc = __libc_back_fsResolve("/", BACKFS_FLAGS_RESOLVE_FULL, szNativePath, NULL);31 printf("+ '/' -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath);32 55 33 memset(szNativePath, 0xAA, sizeof(szNativePath)); 34 errno = 0; 35 rc = __libc_back_fsResolve("/tmp", BACKFS_FLAGS_RESOLVE_FULL, szNativePath, NULL); 36 printf("+ '/tmp' -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath); 56 int main (int argc, char *argv[]) 57 { 58 int rcRet = 0; 37 59 38 memset(szNativePath, 0xAA, sizeof(szNativePath));39 errno = 0;40 rc = __libc_back_fsResolve("/tmp", BACKFS_FLAGS_RESOLVE_PARENT, szNativePath, NULL);41 printf("+ '/tmp' (parent) -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath);42 60 43 memset(szNativePath, 0xAA, sizeof(szNativePath)); 44 errno = 0; 45 rc = __libc_back_fsResolve("/nosuchdir", BACKFS_FLAGS_RESOLVE_PARENT, szNativePath, NULL); 46 printf("+ '/nosuchdir' (parent) -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath); 47 48 memset(szNativePath, 0xAA, sizeof(szNativePath)); 49 errno = 0; 50 rc = __libc_back_fsResolve("/nosuchdir/nosuchsubdir", BACKFS_FLAGS_RESOLVE_PARENT, szNativePath, NULL); 51 printf("- '/nosuchdir/nosuchsubdir' (parent) -> rc=%d errno=%d szNativePath=%s\n", rc, errno, szNativePath); 52 61 rcRet += testit(".", BACKFS_FLAGS_RESOLVE_FULL, 0); 62 rcRet += testit("/", BACKFS_FLAGS_RESOLVE_FULL, 0); 63 rcRet += testit("/tmp", BACKFS_FLAGS_RESOLVE_FULL, 0); 64 rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_FULL, -ENOENT); 65 rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, 0); 66 rcRet += testit("/tmp", BACKFS_FLAGS_RESOLVE_PARENT, 0); 67 rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_PARENT, -ENOENT); 68 rcRet += testit("/tmp/", BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, 0); 69 rcRet += testit("/tmp/NoSuchSubDir", BACKFS_FLAGS_RESOLVE_PARENT, 0); 70 rcRet += testit("/tmp/NoSuchSubDir/", BACKFS_FLAGS_RESOLVE_PARENT, -ENOENT); 71 rcRet += testit("/tmp/NoSuchSubDir/", BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, 0); 72 rcRet += testit("/nosuchdir", BACKFS_FLAGS_RESOLVE_PARENT, 0); 73 rcRet += testit("/nosuchdir/nosuchsubdir", BACKFS_FLAGS_RESOLVE_PARENT, -ENOENT); 53 74 54 75 return 0; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.