Beispiel #1
0
void MojTestRunner::test(MojTestCase& test)
{
	if (!testEnabled(test))
		return;

	MojPrintF(_T("%-24s: "), test.name());
	fflush(stdout);

	m_curTest = &test;
	test.cleanup();
	MojErr err = test.run();
	test.cleanup();
	m_curTest = NULL;

	if (err == MojErrNone) {
		m_numSucceeded++;
		MojPrintF(_T("Succeeded\n"));
	} else {
		m_numFailed++;
	}
}
Beispiel #2
0
static int32_t
testHookInterface(OMRPortLibrary *portLib, uintptr_t *passCount, uintptr_t *failCount, J9HookInterface **hookInterface)
{
	int32_t rc = 0;
	uintptr_t agent1, agent2, agent2andAHalf, agent3;

	/* all events should be enabled initially */
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, TRUE);

	/* disable event1 */
	testDisable(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, 0);
	testReserve(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, -1);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, FALSE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, TRUE);

	/* reserve event2 */
	testReserve(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, 0);
	testDisable(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, -1);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, FALSE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, TRUE);

	/* register event3 */
	testRegister(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, 0);
	testDisable(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, -1);
	testReserve(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, 0);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT1, FALSE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, TRUE);
	testEnabled(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, TRUE);

	/* register event2 (which was previously reserved) twice */
	/* (the second register should have no effect) */
	testRegister(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, 0);
	testRegister(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2, 0);

	/* trigger an event */
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT1, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT2, 1);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 1);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT4, 0);

	/* unregister the twice hooked event */
	testUnregister(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT2);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT1, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT2, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 1);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT4, 0);

	/* unregister the once hooked event */
	testUnregister(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT1, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT2, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT4, 0);

	/* allocate some agent IDs */
	agent1 = testAllocateAgentID(portLib, passCount, failCount, hookInterface);
	agent2 = testAllocateAgentID(portLib, passCount, failCount, hookInterface);
	agent2andAHalf = testAllocateAgentID(portLib, passCount, failCount, hookInterface);
	agent3 = testAllocateAgentID(portLib, passCount, failCount, hookInterface);

	/* register the agents in order */
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, agent1, 1, 0);
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, agent2, 2, 0);
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT4, agent3, 3, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT4, 3);

	/* register the agents in reverse order */
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, agent3, 3, 0);
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, agent2, 2, 0);
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, agent1, 1, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 3);

	/* unregister an agent */
	testUnregisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, 2);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 2);

	/* register it again with another agent in the same list position*/
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, agent2andAHalf, 2, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 3);

	/* register a first chance istener */
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, J9HOOK_AGENTID_FIRST, 0, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 4);

	/* and a last chance listener */
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, J9HOOK_AGENTID_LAST, 4, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 5);

	/* registering a duplicate listener should have no effect, even if it's a different agent */
	testRegisterWithAgent(portLib, passCount, failCount, hookInterface, TESTHOOK_EVENT3, agent2, 3, 0);
	testDispatch(portLib, passCount, failCount, TESTHOOK_EVENT3, 5);

	return rc;
}