Index: trunk/src/emx/testcase/libc/miscinnotek/sys/fsResolver.c
===================================================================
--- trunk/src/emx/testcase/libc/miscinnotek/sys/fsResolver.c	(revision 1943)
+++ trunk/src/emx/testcase/libc/miscinnotek/sys/fsResolver.c	(revision 1944)
@@ -41,4 +41,7 @@
 int __libc_gfNoUnix = 0;
 
+char g_aszCleanupDirs[PATH_MAX][5];
+
+
 static int isValid(const char *pszDir)
 {
@@ -162,12 +165,82 @@
 
     /*
-     * Try non-existing filename (as for create).
+     * Try non-existing filename/dir (as for create).
      */
     memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL, szPath2, NULL);
+    if (rc != -ENOENT)
+    {
+        printf("(negative) Resolving '%s' failed!. Got rc=%d and '%s' expected rc=%d\n", szPath1, rc, szPath2, -ENOENT);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     if (rc != -ENOENT)
     {
-        printf("(negative) Resolving '%s' failed!. Got rc=%d and '%s' expected rc=%d\n", szPath1, rc, szPath2, -ENOENT);
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/\\//my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
         return 1;
     }
@@ -175,15 +248,136 @@
     memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
-    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
-    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
-    if (rc || strcmp(szPath2, szPath3))
-    {
-        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
-        return 1;
-    }
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "//my-not-Existing-file---");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+#if 0
+    /* negative */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+#endif
+
+    /*
+     * Create a directory and play with casing and 'maybe' expansion.
+     */
+    strcat(strcpy(szPath3, szPathCorrect), "/--Testase--fsResolver--TmpDir--");
+    rc = mkdir(szPath3, 0777);
+    if (rc)
+    {
+        printf("Failed to create subdir '%s', errno=%d\n", szPath3, errno);
+        return 1;
+    }
+    strcpy(g_aszCleanupDirs[0], szPath3);
+
+    /* mismatching casing. */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    /* dirslash */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
+    if (rc || strcmp(szPath2, szPath3))
+    {
+        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
+        return 1;
+    }
+
+#if 0
+    /* negative */
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+
+    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
+    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
+    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
+    if (rc != -ENOTDIR)
+    {
+        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
+        return 1;
+    }
+#endif
 
     /* more later */
     return 0;
 }
+
+
+static void cleanup(void)
+{
+    int i = sizeof(g_aszCleanupDirs) / sizeof(g_aszCleanupDirs[0]);
+    while (i-- > 0)
+        if (g_aszCleanupDirs[i])
+            rmdir(g_aszCleanupDirs[i]);
+}
+
 
 int main(int argc, char **argv)
@@ -191,10 +385,16 @@
     int cErrors = 0;
     if (argc == 1)
+    {
         cErrors += tstDir(".");
+        cleanup();
+    }
     else
     {
         int i;
         for (i = 1; i < argc; i++)
+        {
             cErrors += tstDir(argv[i]);
+            cleanup();
+        }
     }
 
