예제 #1
0
파일: testEgi.c 프로젝트: jsjohnst/appweb
    rc = httpRequest(http, "GET", uri);
    assert(rc == 0);
    if (rc != 0) {
        return;
    }
    code = mprGetHttpCode(http);
    if (code != 302) {
        mprLog(gp, 0, "Client failed for %s, response code: %d, msg %s\n", uri, code, mprGetHttpMessage(http));
    }
}


MprTestDef testEgi = {
    "egi", 0, 0, 0,
    {
        MPR_TEST(0, basic),
        MPR_TEST(0, queryString),
        MPR_TEST(0, encoding),
        MPR_TEST(0, alias),
        MPR_TEST(0, status),
        MPR_TEST(0, location),
        MPR_TEST(0, 0),
    },
};

#endif /* BLD_FEATURE_EGI */

/*
 *  @copy   default
 *
 *  Copyright (c) Embedthis Software LLC, 2003-2009. All Rights Reserved.
예제 #2
0
파일: testPath.c 프로젝트: ni-webtech/mpr-4
}

    
/*
    Make a unique filename for a given thread
 */
static char *makePath(cchar *name)
{
    return sfmt("%s-%d-%s", name, getpid(), mprGetCurrentThreadName());
}


MprTestDef testPath = {
    "path", 0, initPath, termPath,
    {
        MPR_TEST(0, testCopyPath),
        MPR_TEST(0, testAbsPath),
        MPR_TEST(0, testJoinPath),
        MPR_TEST(0, testMakeDir),
        MPR_TEST(0, testNormalize),
        MPR_TEST(0, testRelPath),
        MPR_TEST(0, testResolvePath),
        MPR_TEST(0, testSame),
        MPR_TEST(0, testTransform),
        MPR_TEST(0, testTemp),
        MPR_TEST(0, 0),
    },
};


/*
예제 #3
0
파일: testList.c 프로젝트: sunfirefox/mpr-4
    while (item > 0) {
        tassert(item == i);
        i++;
        item = (int) (long) mprGetNextItem(lp, &next);
    }
}


/*
    TODO -- add tests for
        mprCreateList(lp, different inc and max list values
 */
MprTestDef testList = {
    "list", 0, 0, 0,
    {
        MPR_TEST(0, testCreateList),
        MPR_TEST(0, testIsListEmpty),
        MPR_TEST(0, testInsertAndRemove),
        MPR_TEST(0, testLotsOfInserts),
        MPR_TEST(0, testListIterate),
        MPR_TEST(0, testOrderedInserts),
        MPR_TEST(0, 0),
    },
};

/*
    @copy   default

    Copyright (c) Embedthis Software LLC, 2003-2013. All Rights Reserved.

    This software is distributed under commercial and open source licenses.
예제 #4
0
파일: testTime.c 프로젝트: doghell/mpr-3
    when = 0;
    assert(mprParseTime(gp, &when, "today", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "tomorrow", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "12:00", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "12:30 pm", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "1/31/99", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "Jan 17 2011", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(mprParseTime(gp, &when, "March 17 2011", MPR_LOCAL_TIMEZONE, NULL) == 0);
    assert(when != 0);
}


MprTestDef testTime = {
    "time", 0, 0, 0,
    {
        MPR_TEST(0, testTimeBasics),
        MPR_TEST(0, testZones),
        MPR_TEST(0, testFormatTime),
        MPR_TEST(0, testParseTime),
        MPR_TEST(0, 0),
    },
};

/*
 *  @copy   default
 *  
 *  Copyright (c) Embedthis Software LLC, 2003-2011. All Rights Reserved.
 *  Copyright (c) Michael O'Brien, 1993-2011. All Rights Reserved.
 *  
 *  This software is distributed under commercial and open source licenses.
 *  You may use the GPL open source license described below or you may acquire 
예제 #5
0
파일: testArgv.c 프로젝트: ni-webtech/mpr-4
    assert(strcmp(argv[1], "-c") == 0);
    assert(strcmp(argv[2], "c:/home/mob/ejs/out/bin/ejs.exe ./args \"a b\" c") == 0);

    //  "\bin\sh" "-c" "/bin/ejs ./args \"a b\" c"
    argc = mprMakeArgv("\"\\bin\\sh\" \"-c\" \"/bin/ejs ./args \\\"a b\\\" c\"", &argv, 0);
    assert(argc == 3);
    assert(strcmp(argv[0], "\\bin\\sh") == 0);
    assert(strcmp(argv[1], "-c") == 0);
    assert(strcmp(argv[2], "/bin/ejs ./args \"a b\" c") == 0);
}


MprTestDef testArgv = {
    "makeArgv", 0, 0, 0,
    {
        MPR_TEST(0, testMakeArgv),
        MPR_TEST(0, testArgvRegressions),
        MPR_TEST(0, 0),
    },
};

/*
    @copy   default

    Copyright (c) Embedthis Software LLC, 2003-2012. All Rights Reserved.

    This software is distributed under commercial and open source licenses.
    You may use the Embedthis Open Source license or you may acquire a 
    commercial license from Embedthis Software. You agree to be fully bound
    by the terms of either license. Consult the LICENSE.md distributed with
    this software for full details and other copyrights.
예제 #6
0
파일: testAuth.c 프로젝트: jsjohnst/appweb
    if (expectCode != 200) {
        contentLength = mprGetHttpContentLength(http);
        content = mprGetHttpContent(http);
        if (! assert(content != 0 && contentLength > 0)) {
            return 0;
        }
    }
    return 1;
}


MprTestDef testAuth = {
    "auth", 0, 0, 0,
    {
        MPR_TEST(0, simple),
        MPR_TEST(0, badPassword),
        MPR_TEST(0, userAccess),
        MPR_TEST(0, groupAccess),
        MPR_TEST(0, switchToDigest),
        MPR_TEST(0, simple),
        MPR_TEST(0, badPassword),
        MPR_TEST(0, userAccess),
        MPR_TEST(0, groupAccess),
        MPR_TEST(0, 0),
    },
};


/*
 *  @copy   default
예제 #7
0
    if (strcmp(expectedHtml, escaped) == 0) {
        mprFree(escaped);
        return 1;
    }
    mprLog(gp, 0, "HTML \"%s\" is escaped to be \n"
        "\"%s\" instead of \n"
        "\"%s\"\n", html, escaped, expectedHtml);
    mprFree(escaped);
    return 0;
}


MprTestDef testHttp = {
    "http", 0, 0, 0,
    {
        MPR_TEST(0, setup),
        MPR_TEST(0, validateUri),
        MPR_TEST(0, escape),
        MPR_TEST(0, descape),
        MPR_TEST(0, 0),
    },
};


/*
 *  @copy   default
 *
 *  Copyright (c) Embedthis Software LLC, 2003-2012. All Rights Reserved.
 *  Copyright (c) Michael O'Brien, 1993-2012. All Rights Reserved.
 *
 *  This software is distributed under commercial and open source licenses.
예제 #8
0
파일: testAlloc.c 프로젝트: doghell/mpr-3
            continue;
        }
        cp = (uchar*) blocks[i];
        size = 1 << ((i + 6) / 100);
        for (j = 0; j < size; j++) {
            assert(cp[j] == (i % 0xff));
        }
        mprFree(blocks[i]);
    }
}


MprTestDef testAlloc = {
    "alloc", 0, 0, 0,
    {
        MPR_TEST(0, testBasicAlloc),
        MPR_TEST(1, testLotsOfAlloc),
        MPR_TEST(2, testBigAlloc),
        MPR_TEST(0, testAllocIntegrityChecks),
        MPR_TEST(0, 0),
    },
};

/*
 *  @copy   default
 *  
 *  Copyright (c) Embedthis Software LLC, 2003-2011. All Rights Reserved.
 *  Copyright (c) Michael O'Brien, 1993-2011. All Rights Reserved.
 *  
 *  This software is distributed under commercial and open source licenses.
 *  You may use the GPL open source license described below or you may acquire 
예제 #9
0
파일: testVhost.c 프로젝트: jsjohnst/appweb
    if (code != expectCode) {
        mprLog(gp, 0, "get: HTTP response code %d, expected %d", code, expectCode);
        return 0;
    }

    assert(mprGetHttpError(http) != 0);
    assert(mprGetHttpContent(http) != 0);

    return 1;
}


MprTestDef testVhost = {
    "vhost", 0, 0, 0,
    {
        MPR_TEST(0, basic),
        MPR_TEST(0, mainServer),
        MPR_TEST(0, ipHost),
        MPR_TEST(0, namedHost),
        MPR_TEST(0, inheritHandlers),
        MPR_TEST(0, nestedLocation),
        MPR_TEST(0, auth),
        MPR_TEST(0, 0),
    },
};


/*
 *  @copy   default
 *
 *  Copyright (c) Embedthis Software LLC, 2003-2009. All Rights Reserved.
예제 #10
0
파일: testLock.c 프로젝트: sunfirefox/mpr-4
    size = sizeof(critical) / sizeof(MprOsThread);
    for (i = 0; i < size; i++) {
        critical[i] = mprGetCurrentOsThread();
    }
    for (i = 0; i < size; i++) {
        tassert(critical[i] == mprGetCurrentOsThread());
    }
    mprUnlock(mutex);
    tassert(mutex != 0);
}


MprTestDef testLock = {
    "lock", 0, initLock, termLock,
    {
        MPR_TEST(0, testCriticalSection),
        MPR_TEST(0, 0),
    },
};


/*
    @copy   default

    Copyright (c) Embedthis Software LLC, 2003-2013. All Rights Reserved.

    This software is distributed under commercial and open source licenses.
    You may use the Embedthis Open Source license or you may acquire a 
    commercial license from Embedthis Software. You agree to be fully bound
    by the terms of either license. Consult the LICENSE.md distributed with
    this software for full details and other copyrights.
예제 #11
0
    /*
     *  Can only run this test if the worker is greater than the number of threads.
     */
    if (mprGetMaxWorkers(gp) > gp->service->numThreads) {
        rc = mprStartWorker(gp, workerProc, (void*) gp, MPR_NORMAL_PRIORITY);
        assert(rc == 0);
        assert(mprWaitForTestToComplete(gp, MPR_TEST_SLEEP));
    }
}


MprTestDef testWorker = {
    "worker", 0, 0, 0,
    {
        MPR_TEST(0, testStartWorker),
        MPR_TEST(0, 0),
    },
};

#else
void dummyTestWorker() {}
#endif

/*
 *  @copy   default
 *  
 *  Copyright (c) Embedthis Software LLC, 2003-2012. All Rights Reserved.
 *  Copyright (c) Michael O'Brien, 1993-2012. All Rights Reserved.
 *  
 *  This software is distributed under commercial and open source licenses.
예제 #12
0
파일: testHash.c 프로젝트: ni-webtech/mpr-4
    count = 0;
    for (i = 0; i < HASH_COUNT; i++) {
        if (check[i]) {
            count++;
        }
    }
    assert(count == HASH_COUNT);
}


//  TODO -- test caseless and unicode

MprTestDef testHash = {
    "hash", 0, 0, 0,
    {
        MPR_TEST(0, testCreateTable),
        MPR_TEST(0, testIsTableEmpty),
        MPR_TEST(0, testInsertAndRemoveHash),
        MPR_TEST(0, testHashScale),
        MPR_TEST(0, testIterateHash),
        MPR_TEST(0, 0),
    },
};

/*
    @copy   default

    Copyright (c) Embedthis Software LLC, 2003-2012. All Rights Reserved.

    This software is distributed under commercial and open source licenses.
    You may use the Embedthis Open Source license or you may acquire a 
예제 #13
0
파일: testAlias.c 프로젝트: jsjohnst/appweb
{
    assert(simpleGet(gp, "/aliasDir/test.html", 0));
    assert(simpleGet(gp, "/aliasFile/", 0));
}


static void script(MprTestGroup *gp)
{
    assert(simpleGet(gp, "/cgi-bin/cgiProgram", 0));
}


MprTestDef testAlias = {
    "alias", 0, 0, 0,
    {
        MPR_TEST(0, simple),
        MPR_TEST(0, script),
        MPR_TEST(0, 0),
    },
};


/*
 *  @copy   default
 *
 *  Copyright (c) Embedthis Software LLC, 2003-2009. All Rights Reserved.
 *  Copyright (c) Michael O'Brien, 1993-2009. All Rights Reserved.
 *
 *  This software is distributed under commercial and open source licenses.
 *  You may use the GPL open source license described below or you may acquire
 *  a commercial license from Embedthis Software. You agree to be fully bound