Beispiel #1
0
MAIN(testMain, int argc, char *argv[]) 
{
    Mpr             *mpr;
    MprTestService  *ts;
    MprTestGroup    *gp;
    int             rc;

    mpr = mprCreate(argc, argv, 0);

#if VXWORKS || WINCE
    /*
     *  These platforms pass an arg string in via the argc value. Assumes 32-bit.
     */
    mprMakeArgv(mpr, "testMpr", (char*) argc, &argc, &argv);
#endif

    ts = mprCreateTestService(mpr);
    if (ts == 0) {
        mprError(mpr, "Can't create test service");
        exit(2);
    }
    
    if (mprParseTestArgs(ts, argc, argv) < 0) {
        mprFree(mpr);
        exit(3);
    }
    
    gp = mprAddTestGroup(ts, &master);
    if (gp == 0) {
        exit(4);
    }

#if BLD_FEATURE_SSL && (BLD_FEATURE_MATRIXSSL || BLD_FEATURE_OPENSSL)
    if (!mprLoadSsl(mpr, 0)) {
        exit(5);
    }
#endif

    /*
     *  Need a background event thread as we use the main thread to run the tests.
     */
    if (mprStart(mpr, 0)) {
        mprError(mpr, "Can't start mpr services");
        exit(4);
    }

    /*
     *  Run the tests and return zero if 100% success
     */
    rc = mprRunTests(ts);
    mprReportTestResults(ts);

    return (rc == 0) ? 0 : 6;
}
Beispiel #2
0
int main(int argc, char *argv[]) 
{
    Mpr             *mpr;
    int             rc;

    mpr = mprCreate(argc, argv, MPR_USER_EVENTS_THREAD);
    mprAddStandardSignals();

    app = mprAllocObj(App, manageApp);
    mprAddRoot(app);

    app->host = sclone("127.0.0.1");
    app->port = 4100;

    if ((ts = mprCreateTestService(mpr)) == 0) {
        mprLog("appweb test", 0, "Cannot create test service");
        exit(2);
    }
    if (mprParseTestArgs(ts, argc, argv, parseArgs) < 0) {
        mprEprintf("\n"
            "  Commands specifically for %s\n"
            "    --host ip:port      # Set the default host address for testing\n\n",
            mprGetAppName(mpr));
        exit(3);
    }
    if (mprAddTestGroup(ts, &master) == 0) {
        exit(4);
    }

#if BIT_PACK_SSL
    if (mprLoadSsl(0) < 0) {
        return 0;
    }
#endif
    /*
        Need a background event thread as we use the main thread to run the tests.
     */
    if (mprStart(mpr)) {
        mprLog("appweb test", 0, "Cannot start mpr services");
        exit(5);
    }
    /*
        Run the tests and return zero if 100% success
     */
    rc = mprRunTests(ts);
    mprReportTestResults(ts);
    mprDestroy();
    return (rc == 0) ? 0 : -1;
}