Changeset 1944


Ignore:
Timestamp:
May 2, 2005, 4:17:01 AM (20 years ago)
Author:
bird
Message:

more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/testcase/libc/miscinnotek/sys/fsResolver.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1943 r1944  
    4141int __libc_gfNoUnix = 0;
    4242
     43char g_aszCleanupDirs[PATH_MAX][5];
     44
     45
    4346static int isValid(const char *pszDir)
    4447{
     
    162165
    163166    /*
    164      * Try non-existing filename (as for create).
     167     * Try non-existing filename/dir (as for create).
    165168     */
    166169    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
    167170    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
     171    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL, szPath2, NULL);
     172    if (rc != -ENOENT)
     173    {
     174        printf("(negative) Resolving '%s' failed!. Got rc=%d and '%s' expected rc=%d\n", szPath1, rc, szPath2, -ENOENT);
     175        return 1;
     176    }
     177
     178    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     179    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
     180    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
     181    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     182    if (rc || strcmp(szPath2, szPath3))
     183    {
     184        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     185        return 1;
     186    }
     187
     188    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     189    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
    168190    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     191    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
    169192    if (rc != -ENOENT)
    170193    {
    171         printf("(negative) Resolving '%s' failed!. Got rc=%d and '%s' expected rc=%d\n", szPath1, rc, szPath2, -ENOENT);
     194        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
     195        return 1;
     196    }
     197
     198    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     199    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     200    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     201    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     202    if (rc || strcmp(szPath2, szPath3))
     203    {
     204        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     205        return 1;
     206    }
     207
     208    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     209    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     210    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     211    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     212    if (rc || strcmp(szPath2, szPath3))
     213    {
     214        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     215        return 1;
     216    }
     217
     218    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     219    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     220    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
     221    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     222    if (rc || strcmp(szPath2, szPath3))
     223    {
     224        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     225        return 1;
     226    }
     227
     228    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     229    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     230    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
     231    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     232    if (rc || strcmp(szPath2, szPath3))
     233    {
     234        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     235        return 1;
     236    }
     237
     238    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     239    strcat(strcpy(szPath1, szPathCorrect), "/\\//my-not-Existing-file---");
     240    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, szPath2, NULL);
     241    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     242    if (rc || strcmp(szPath2, szPath3))
     243    {
     244        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
    172245        return 1;
    173246    }
     
    175248    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
    176249    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---");
    177     rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
    178     strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
    179     if (rc || strcmp(szPath2, szPath3))
    180     {
    181         printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
    182         return 1;
    183     }
     250    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE, szPath2, NULL);
     251    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     252    if (rc || strcmp(szPath2, szPath3))
     253    {
     254        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     255        return 1;
     256    }
     257
     258    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     259    strcat(strcpy(szPath1, szPathCorrect), "//my-not-Existing-file---");
     260    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
     261    strcat(strcpy(szPath3, szPathCorrect), szPathCorrect[3] != '\0' ? "/my-not-Existing-file---" : "my-not-Existing-file---");
     262    if (rc || strcmp(szPath2, szPath3))
     263    {
     264        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     265        return 1;
     266    }
     267
     268#if 0
     269    /* negative */
     270    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     271    strcat(strcpy(szPath1, szPathCorrect), "/my-not-Existing-file---/");
     272    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_PARENT, szPath2, NULL);
     273    if (rc != -ENOTDIR)
     274    {
     275        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
     276        return 1;
     277    }
     278#endif
     279
     280    /*
     281     * Create a directory and play with casing and 'maybe' expansion.
     282     */
     283    strcat(strcpy(szPath3, szPathCorrect), "/--Testase--fsResolver--TmpDir--");
     284    rc = mkdir(szPath3, 0777);
     285    if (rc)
     286    {
     287        printf("Failed to create subdir '%s', errno=%d\n", szPath3, errno);
     288        return 1;
     289    }
     290    strcpy(g_aszCleanupDirs[0], szPath3);
     291
     292    /* mismatching casing. */
     293    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     294    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
     295    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     296    if (rc || strcmp(szPath2, szPath3))
     297    {
     298        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     299        return 1;
     300    }
     301
     302    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     303    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
     304    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     305    if (rc || strcmp(szPath2, szPath3))
     306    {
     307        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     308        return 1;
     309    }
     310
     311    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     312    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
     313    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     314    if (rc || strcmp(szPath2, szPath3))
     315    {
     316        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     317        return 1;
     318    }
     319
     320    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     321    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
     322    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     323    if (rc || strcmp(szPath2, szPath3))
     324    {
     325        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     326        return 1;
     327    }
     328
     329    /* dirslash */
     330    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     331    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
     332    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR, szPath2, NULL);
     333    if (rc || strcmp(szPath2, szPath3))
     334    {
     335        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     336        return 1;
     337    }
     338
     339    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     340    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
     341    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK_MAYBE | BACKFS_FLAGS_RESOLVE_DIR_MAYBE, szPath2, NULL);
     342    if (rc || strcmp(szPath2, szPath3))
     343    {
     344        printf("Resolving '%s' failed. got rc=%d '%s', expected '%s'\n", szPath1, rc, szPath2, szPath3);
     345        return 1;
     346    }
     347
     348#if 0
     349    /* negative */
     350    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     351    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--/");
     352    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
     353    if (rc != -ENOTDIR)
     354    {
     355        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
     356        return 1;
     357    }
     358
     359    memset(szPath2, 0xff, sizeof(szPath2)); szPath2[0] = '\0';
     360    strcat(strcpy(szPath1, szPathCorrect), "/--TESTASE--FSRESOLVER--TMPDIR--");
     361    rc = __libc_back_fsResolve(szPath1, BACKFS_FLAGS_RESOLVE_FULL_SYMLINK, szPath2, NULL);
     362    if (rc != -ENOTDIR)
     363    {
     364        printf("(negative) Resolving '%s' failed. got rc=%d '%s', expected rc=%d\n", szPath1, rc, szPath2, -ENOTDIR);
     365        return 1;
     366    }
     367#endif
    184368
    185369    /* more later */
    186370    return 0;
    187371}
     372
     373
     374static void cleanup(void)
     375{
     376    int i = sizeof(g_aszCleanupDirs) / sizeof(g_aszCleanupDirs[0]);
     377    while (i-- > 0)
     378        if (g_aszCleanupDirs[i])
     379            rmdir(g_aszCleanupDirs[i]);
     380}
     381
    188382
    189383int main(int argc, char **argv)
     
    191385    int cErrors = 0;
    192386    if (argc == 1)
     387    {
    193388        cErrors += tstDir(".");
     389        cleanup();
     390    }
    194391    else
    195392    {
    196393        int i;
    197394        for (i = 1; i < argc; i++)
     395        {
    198396            cErrors += tstDir(argv[i]);
     397            cleanup();
     398        }
    199399    }
    200400
Note: See TracChangeset for help on using the changeset viewer.