extern "C" void
badReceiver(void *arg)
{
    epicsMessageQueue *q = (epicsMessageQueue *)arg;
    char cbuf[80];
    int len;

    cbuf[0] = '\0';
    len = q->receive(cbuf, 1);
    if (len < 0 && cbuf[0] == '\0')
        testPass("receive into undersized buffer returned error (%d)", len);
    else if (len == 1 && cbuf[0] == *msg1)
        testPass("receive into undersized buffer truncated message");
    else
        testFail("receive into undersized buffer returned %d", len);

    epicsThreadSleep(3.0);

    cbuf[0] = '\0';
    len = q->receive(cbuf, 1);
    if (len < 0 && cbuf[0] == '\0')
        testPass("receive into undersized buffer returned error (%d)", len);
    else if (len == 1 && cbuf[0] == *msg1)
        testPass("receive into undersized buffer truncated message");
    else
        testFail("receive into undersized buffer returned %d", len);
}
Esempio n. 2
0
static long initRec0(aoRecord *prec)
{
    DBLINK *plink = &prec->out;
    testDiag("init_record(%s)", prec->name);
    testOk(prec->val==2, "VAL %d==2 (pass0 value)", (int)prec->val);
    prec->val = 3;
    testOk(prec->val==3, "VAL %d==3", (int)prec->val);

    testOk1(plink->type==DB_LINK);
    if(plink->type==DB_LINK)
        testOk(strcmp(plink->value.pv_link.pvname,"rec0.SEVR")==0,
               "%s==rec0.SEVR (pass0 value)", plink->value.pv_link.pvname);
    else
        testFail("Wrong link type");

    plink = &prec->sdis;

    testOk1(plink->type==DB_LINK);
    if(plink->type==DB_LINK)
        testOk(strcmp(plink->value.pv_link.pvname,"rec0.STAT")==0,
               "%s==rec0.STAT (pass0 value)", plink->value.pv_link.pvname);
    else
        testFail("Wrong link type");

    iran |= 1;
    return 2; /* we set .VAL, so don't use RVAL */
}
Esempio n. 3
0
/* Action function for state "waitForActualToEqualRequested" in state set "monitorEvflagTest" */
static void A_monitorEvflagTest_0_waitForActualToEqualRequested(SS_ID ssId, struct UserVar *pVar, int transNum, int *pNextState)
{
	switch(transNum)
	{
	case 0:
		{
# line 47 "../monitorEvflag.st"
			if (pVar->actual != pVar->requested)
			{
# line 48 "../monitorEvflag.st"
				testFail("requested(%d)!=actual(%d)", pVar->requested, pVar->actual);
# line 49 "../monitorEvflag.st"
				pVar->UserVar_monitorEvflagTest.error = TRUE;
			}
			else
# line 50 "../monitorEvflag.st"
				if (pVar->UserVar_monitorEvflagTest.cycleCount % 500 == 0)
				{
# line 51 "../monitorEvflag.st"
					testDiag("passed %d cycles", pVar->UserVar_monitorEvflagTest.cycleCount);
				}
# line 53 "../monitorEvflag.st"
			pVar->UserVar_monitorEvflagTest.cycleCount++;
		}
		return;
	case 1:
		{
# line 57 "../monitorEvflag.st"
			testFail("timeout in cycle %d/%d (requested=%d, actual=%d)", pVar->UserVar_monitorEvflagTest.cycleCount + 1, (20 * 500), pVar->requested, pVar->actual);
		}
		return;
	}
}
Esempio n. 4
0
/* Action function for state "waitForActualToEqualRequested" in state set "monitorEvflagTest" */
static void seqg_action_monitorEvflagTest_0_waitForActualToEqualRequested(SS_ID seqg_env, int seqg_trn, int *seqg_pnst)
{
	switch(seqg_trn)
	{
	case 0:
		{
# line 47 "../monitorEvflag.st"
			if (seqg_var->actual != seqg_var->requested)
			{
# line 48 "../monitorEvflag.st"
				testFail("requested(%d)!=actual(%d)", seqg_var->requested, seqg_var->actual);
# line 49 "../monitorEvflag.st"
				seqg_var->seqg_vars_monitorEvflagTest.error = TRUE;
			}
			else
# line 50 "../monitorEvflag.st"
				if (seqg_var->seqg_vars_monitorEvflagTest.cycleCount % 500 == 0)
				{
# line 51 "../monitorEvflag.st"
					testDiag("passed %d cycles", seqg_var->seqg_vars_monitorEvflagTest.cycleCount);
				}
# line 53 "../monitorEvflag.st"
			seqg_var->seqg_vars_monitorEvflagTest.cycleCount++;
		}
		return;
	case 1:
		{
# line 57 "../monitorEvflag.st"
			testFail("timeout in cycle %d/%d (requested=%d, actual=%d)", seqg_var->seqg_vars_monitorEvflagTest.cycleCount + 1, (20 * 500), seqg_var->requested, seqg_var->actual);
		}
		return;
	}
}
Esempio n. 5
0
/**
 * Test for ethernet loopback (ethloop) driver packet acceptance.
 */
thread test_ethloop(bool verbose)
{
#if NETHLOOP
    /* the failif macro depends on 'passed' and 'verbose' vars */
    bool passed = TRUE;
    int i;

    for (i = 0; i < NETHLOOP; i++)
    {
        passed &= ethloopn_test(verbose, i + ELOOP);
    }

    /* always print out the overall tests status */
    if (passed)
    {
        testPass(TRUE, "");
    }
    else
    {
        testFail(TRUE, "");
    }

#else /* NETHLOOP */
    testSkip(TRUE, "");
#endif /* !NETHLOOP */
    return OK;
}
Esempio n. 6
0
static void channelRegisterPost(dbChannel *chan, void *user,
    chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
{
    myStruct *my = (myStruct*)user;

    if (my == puser1) {
        testOk(e1 & e_reg_post, "register_post (1) called");
        testOk(!(c2 & e_reg_post),
            "register_post (2) was not called before register_post (1)");
        c1 |= e_reg_post;
    } else if (my == puser2) {
        testOk(e2 & e_reg_post, "register_post (2) called");
        testOk(!(e1 & e_reg_post) || c1 & e_reg_post,
            "register_post (1) was called before register_post (2)");
        c2 |= e_reg_post;
    } else {
        testFail("register_post: user pointer invalid");
        testSkip(1, "Can't check order of register_post(1)/register_post(2)");
    }
    testOk(!(e1 & e_reg_pre) || c1 & e_reg_pre,
        "register_pre (1) was called before register_post (%c)", inst(user));
    testOk(!(e2 & e_reg_pre) || c2 & e_reg_pre,
        "register_pre (2) was called before register_post (%c)", inst(user));

    my->offpost = offset++;
    probe->field_type++;
    *cb_out  = post;
    *arg_out = user;
}
static void myCallback(CALLBACK *pCallback)
{
    myPvt *pmyPvt;
    epicsTimeStamp now;
    double delay, error;

    epicsTimeGetCurrent(&now);
    callbackGetUser(pmyPvt, pCallback);

    if (pmyPvt->pass++ == 0) {
        delay = 0.0;
        error = epicsTimeDiffInSeconds(&now, &pmyPvt->start);
        pmyPvt->start = now;
        callbackRequestDelayed(&pmyPvt->cb2, pmyPvt->delay);
    } else if (pmyPvt->pass == 2) {
        double diff = epicsTimeDiffInSeconds(&now, &pmyPvt->start);
        delay = pmyPvt->delay;
        error = fabs(delay - diff);
    } else {
        testFail("pass = %d for delay = %f", pmyPvt->pass, pmyPvt->delay);
        return;
    }
    testOk(error < 0.05, "delay %f seconds, callback time error %f",
        delay, error);
}
Esempio n. 8
0
File: testlib.c Progetto: pdo/aldor
void
testIntEqual(String testName, int i1, int i2)
{
	count++;
	if (i1 == i2) {
		return;
	}
	testFail(testName, "failed; expected %d, got %d", i1, i2);
}
Esempio n. 9
0
File: testlib.c Progetto: pdo/aldor
void
testIntIsNotZero(String testName, int i1)
{
	count++;
	if (i1 != 0) {
		return;
	}
	testFail(testName, "failed; expected non-zero value");
}
Esempio n. 10
0
File: testlib.c Progetto: pdo/aldor
void
testPointerEqual(String testName, void *i1, void *i2)
{
	count++;
	if (i1 == i2) {
		return;
	}
	testFail(testName, "failed; expected %p, got %p", i1, i2);
}
Esempio n. 11
0
File: testlib.c Progetto: pdo/aldor
void
testIsNull(String testName, void *p)
{
	count++;
	if (p == NULL) {
		return;
	}
	testFail(testName, "failed; expected null, got %d", p);
}
Esempio n. 12
0
File: testlib.c Progetto: pdo/aldor
void
testAIntEqual(String testName, AInt i1, AInt i2)
{
	count++;
	if (i1 == i2) {
		return;
	}
	testFail(testName, "failed; expected %pAInt, got %pAInt", i1, i2);
}
Esempio n. 13
0
File: testlib.c Progetto: pdo/aldor
void
testFalse(String testName, Bool flg)
{
	count++;
	if (!flg) {
		return;
	}
	testFail(testName, "failed; expected false, got %d", flg);
}
Esempio n. 14
0
File: testlib.c Progetto: pdo/aldor
void
testStringEqual(String testName, String s1, String s2)
{
	count++;
	if (strcmp(s1, s2) == 0) {
		return;
	}
	testFail(testName, "failed; expected %s, got %s", s1, s2);
}
Esempio n. 15
0
File: testlib.c Progetto: pdo/aldor
void
testTrue(String testName, Bool flg)
{
	count++;
	if (flg) {
		return;
	}
	testFail(testName, "failed; expected true, got %d", flg);
}
Esempio n. 16
0
static void parse_error(void *user)
{
    if (user == puser1) {
        testOk(e1 & e_error, "parse_error (1) called");
        c1 |= e_error;
    } else if (user == puser2) {
        testOk(e2 & e_error, "parse_error (2) called");
        c2 |= e_error;
    } else
        testFail("parse_error: user pointer invalid");
}
Esempio n. 17
0
void TestChannelGetRequester::channelGetConnect(const epics::pvData::Status &status,
                                                const epics::pvAccess::ChannelGet::shared_pointer &get,
                                                const epics::pvData::Structure::const_shared_pointer &structure)
{
    if(connected)
        testFail("channelGetConnect() called twice");
    statusConnect = status;
    channelGet = get;
    fielddesc = structure;
    connected = true;
}
Esempio n. 18
0
static void channel_close(dbChannel *chan, void *user)
{
    if (user == puser1) {
        testOk(e1 & e_close, "channel_close (1) called");
        c1 |= e_close;
    } else if (user == puser2) {
        testOk(e2 & e_close, "channel_close (2) called");
        c2 |= e_close;
    } else
        testFail("channel_close: user pointer invalid");
}
Esempio n. 19
0
void assertTest(void *given, void *expected, char info[])
{
	if (given == expected)
	{
		testPass(info);
	}
	else
	{
		testFail(info, given, expected);
		
	}
}
Esempio n. 20
0
bool8 test_checkSemCount(sid32 s, short c, bool8 verbose)
{
    char msg[50];

    if (!isbadsem(s) && c != semcount(s))
    {
        sprintf(msg, "count = %d, not %d", semcount(s), c);
        testFail(verbose, msg);
        return FALSE;
    }
    return TRUE;
}
Esempio n. 21
0
static void channel_report(dbChannel *chan, void *user, int level,
    const unsigned short indent)
{
    testOk(level == R_LEVEL - 1, "channel_report: level correct");
    if (user == puser1) {
        testOk(e1 & e_report, "channel_report (1) called");
        c1 |= e_report;
    } else if (user == puser2) {
        testOk(e2 & e_report, "channel_report (2) called");
        c2 |= e_report;
    } else
        testFail("channel_report: user pointer invalid");
}
Esempio n. 22
0
static long channel_open(dbChannel *chan, void *user)
{
    if (user == puser1) {
        testOk(e1 & e_open, "channel_open (1) called");
        c1 |= e_open;
    } else if (user == puser2) {
        testOk(e2 & e_open, "channel_open (2) called");
        c2 |= e_open;
    } else
        testFail("channel_open: user pointer invalid");

    return c_open_return;
}
Esempio n. 23
0
static int parse_ok(void *user)
{
    if (user == puser1) {
        testOk(e1 & e_ok, "parse_ok (1) called");
        c1 |= e_ok;
    } else if (user == puser2) {
        testOk(e2 & e_ok, "parse_ok (2) called");
        c2 |= e_ok;
    } else
        testFail("parse_ok: user pointer invalid");

    return p_ok_return;
}
Esempio n. 24
0
bool8 test_checkProcState(pid32 pid, byte state, bool8 verbose)
{
    char msg[50];

    if (state != proctab[pid].prstate)
    {
        sprintf(msg, "pid %d state %d, not %d",
                pid, proctab[pid].prstate, state);
        testFail(verbose, msg);
        return FALSE;
    }
    return TRUE;
}
Esempio n. 25
0
static void hookPass1(initHookState state)
{
    DBENTRY entry;
    DBADDR  addr;
    if(state!=initHookAfterInitDatabase)
        return;
    testDiag("initHookAfterInitDatabase");

    dbInitEntry(pdbbase, &entry);

    if(dbFindRecord(&entry, "rec0.VAL")==0) {
        aoRecord *prec = entry.precnode->precord;
        testOk(prec->val==3, "VAL %d==3 (init_record value)", (int)prec->val);
        testOk1(dbPutString(&entry, "4")==0);
        testOk(prec->val==4, "VAL %d==4", (int)prec->val);
    } else{
        testFail("Missing rec0");
        testSkip(1, "missing record");
    }

    /* Can't restore links in pass 1 */

    if(dbNameToAddr("rec1.VAL", &addr)) {
        testFail("missing rec1");
        testSkip(3, "missing record");
    } else {
        struct rset *prset = dbGetRset(&addr);
        dbfType ftype = addr.field_type;
        long count=-1, offset=-1, maxcount = addr.no_elements;
        testOk1(prset && prset->get_array_info && prset->put_array_info);
        testOk1((*prset->get_array_info)(&addr, &count, &offset)==0);
        /* count is ignored */
        testOk1((*dbPutConvertRoutine[DBF_DOUBLE][ftype])(&addr, values, NELEMENTS(values), maxcount,offset)==0);
        testOk1((*prset->put_array_info)(&addr, NELEMENTS(values))==0);
    }

    dbFinishEntry(&entry);
}
Esempio n. 26
0
bool8 test_checkResult(byte testResult, byte expected, bool8 verbose)
{
    char msg[80];

    if (expected != testResult)
    {
        sprintf(msg,
                "process didn't seem to wait, expected %d, saw %d",
                expected, testResult);
        testFail(verbose, msg);
        return FALSE;
    }
    return TRUE;
}
Esempio n. 27
0
void testFailingSetUint32(ParamVal *param, int pass){
    try {
  	  param->setUInt32(0,0,0);
  	  testFail("Should not be able to setUInt32 on asynParamInt32");
    }
    catch (ParamValWrongType& e){
    	if (pass == 0){
    		catchWrongTypeTestsInitialPass(param, "setUInt32", &e );
    	}
    	else {
    		catchWrongTypeTestsSecondPass(param, "setUInt32", &e );
    	}
    }
}
Esempio n. 28
0
void testFailingSetInteger(ParamVal *param, int pass){
    try {
  	  param->setInteger(0);
  	  testFail("Should not be able to setInteger on asynParamFloat64");
    }
    catch (ParamValWrongType& e){
    	if (pass == 0){
    		catchWrongTypeTestsInitialPass(param, "setInteger", &e);
    	}
    	else {
    		catchWrongTypeTestsSecondPass(param, "setInteger", &e);
    	}
    }

}
Esempio n. 29
0
static void freePvt(void *user)
{
    if (user == puser1) {
        testOk(e1 & e_free, "freePvt (1) called");
        c1 |= e_free;
        free(user);
        puser1 = NULL;
    } else if (user == puser2) {
        testOk(e2 & e_free, "freePvt (2) called");
        c2 |= e_free;
        free(user);
        puser2 = NULL;
    } else
        testFail("freePvt: user pointer invalid");
}
Esempio n. 30
0
void testFailingSetDouble(ParamVal *param, int pass){
    try {
  	  param->setDouble(0.0);
  	  testFail("Should not be able to setDouble on %s", param->getTypeName());
    }
    catch (ParamValWrongType& e){
    	if (pass == 0) {
    		catchWrongTypeTestsInitialPass(param, "setDouble", &e );
    	}
    	else {
    		catchWrongTypeTestsSecondPass(param, "setDouble", &e );
    	}
    }

}