示例#1
0
TEST(RASMemoryCategoriesTest, Agent)
{
	/* OMR VM data structures */
	OMRTestVM testVM;
	OMR_VMThread *vmthread = NULL;

	const char *agentName = "memorycategoriesagent";
	struct OMR_Agent *agent = NULL;

	OMRTEST_ASSERT_ERROR_NONE(omrTestVMInit(&testVM, rasTestEnv->getPortLibrary()));

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Init(&testVM.omrVM, NULL, &vmthread, "memoryCategoriesTest"));

	/* load memorycategoriesagent */
	agent = omr_agent_create(&testVM.omrVM, agentName);
	ASSERT_FALSE(NULL == agent) << "createAgent(" << agentName << ") failed";

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnLoad(agent));

	/** The test code is actually in the OnLoadFunction **/

	/* Unload the agent */
	omr_agent_callOnUnload(agent);
	omr_agent_destroy(agent);

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Free(vmthread));

	/* Now clear up the VM we started for this test case. */
	OMRTEST_ASSERT_ERROR_NONE(omrTestVMFini(&testVM));
}
示例#2
0
/*
 * Test scenarios for InvalidAgentC and InvalidAgentCPP:
 *  - missing OnLoad entry point in agent
 *  - missing OnUnload entry point in agent
 *  - <dllpath> indicates nonexistent file
 *
 *  Please see INSTANTIATE_TEST_CASE_P for GetParam() values
 */
TEST_P(RASAgentNegativeTest, InvalidAgentC)
{
	struct OMR_Agent *agent = omr_agent_create(&testVM.omrVM, GetParam());
	ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() failed";
	OMRTEST_ASSERT_ERROR(OMR_ERROR_ILLEGAL_ARGUMENT, omr_agent_openLibrary(agent));
	OMRTEST_ASSERT_ERROR(OMR_ERROR_ILLEGAL_ARGUMENT, omr_agent_callOnLoad(agent));
	OMRTEST_ASSERT_ERROR(OMR_ERROR_INTERNAL, omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);
}
示例#3
0
/*
 * Test scenarios for AgentReturnErrorC and AgentReturnErrorCPP:
 *  - agent's OnLoad() function returns OMR_ERROR_OUT_OF_NATIVE_MEMORY
 *  - agent's OnUnload() function returns OMR_ERROR_ILLEGAL_ARGUMENT
 */
TEST_F(RASAgentNegativeTest, AgentReturnErrorC)
{
	struct OMR_Agent *agent = omr_agent_create(&testVM.omrVM, "invalidAgentReturnError=abc");
	ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() failed";
	OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));
	OMRTEST_ASSERT_ERROR(OMR_ERROR_OUT_OF_NATIVE_MEMORY, omr_agent_callOnLoad(agent));
	OMRTEST_ASSERT_ERROR(OMR_ERROR_ILLEGAL_ARGUMENT, omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);
}
示例#4
0
TEST(RASTraceOptionTest, TraceOptionAgent)
{
	/* OMR VM data structures */
	OMRTestVM testVM;
	OMR_VMThread *vmthread = NULL;

	/* OMR Trace data structures */
	const char *trcOpts = "print=all";

	struct OMR_Agent *agent = NULL;
	OMRPORT_ACCESS_FROM_OMRPORT(rasTestEnv->getPortLibrary());
	char *datDir = NULL;

	OMRTEST_ASSERT_ERROR_NONE(omrTestVMInit(&testVM, OMRPORTLIB));

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Init(&testVM.omrVM, NULL, &vmthread, "traceOptionTest"));

	datDir = getTraceDatDir(rasTestEnv->_argc, (const char **)rasTestEnv->_argv);

	OMRTEST_ASSERT_ERROR_NONE(omr_ras_initTraceEngine(&testVM.omrVM, trcOpts, datDir));
	OMRTEST_ASSERT_ERROR_NONE(omr_trc_startThreadTrace(vmthread, "initialization thread"));

	/* load agent */
	agent = omr_agent_create(&testVM.omrVM, "traceOptionAgent");
	ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() traceOptionAgent failed";

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnLoad(agent));

	/* Initialise the omr_test module for tracing */
	UT_OMR_TEST_MODULE_LOADED(testVM.omrVM._trcEngine->utIntf);

	/* Fire some trace points! */
	Trc_OMR_Test_Init();
	Trc_OMR_Test_Ptr(vmthread, vmthread);
	Trc_OMR_Test_Int(vmthread, 10);
	Trc_OMR_Test_Int(vmthread, 99);
	Trc_OMR_Test_ManyParms(vmthread, "Hello again!", vmthread, 10);

	UT_OMR_TEST_MODULE_UNLOADED(testVM.omrVM._trcEngine->utIntf);

	/* Unload the agent */
	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);

	Trc_OMR_Test_String(vmthread, "This tracepoint should be ignored.");

	OMRTEST_ASSERT_ERROR_NONE(omr_ras_cleanupTraceEngine(vmthread));

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Free(vmthread));

	/* Now clear up the VM we started for this test case. */
	OMRTEST_ASSERT_ERROR_NONE(omrTestVMFini(&testVM));
}
示例#5
0
TEST(RASTraceTest, TraceAgent)
{
	struct OMR_Agent *agent = NULL;

	/* OMR VM data structures */
	OMRTestVM testVM;
	OMR_VMThread *vmthread = NULL;

	/* child thread data */
	omrthread_t childThread = NULL;
	TestChildThreadData *childData = NULL;


	OMRPORT_ACCESS_FROM_OMRPORT(rasTestEnv->getPortLibrary());
	char *datDir = getTraceDatDir(rasTestEnv->_argc, (const char **)rasTestEnv->_argv);

	OMRTEST_ASSERT_ERROR_NONE(omrTestVMInit(&testVM, OMRPORTLIB));

	/* WARNING: This negative test leaks memory. */
	OMRTEST_ASSERT_ERROR(omr_ras_initTraceEngine(&testVM.omrVM, "print=all:duck=quack", datDir), OMR_ERROR_ILLEGAL_ARGUMENT);

	OMRTEST_ASSERT_ERROR_NONE(omr_ras_initTraceEngine(&testVM.omrVM, "maximal=all", datDir));

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Init(&testVM.omrVM, NULL, &vmthread, "traceTest"));

#if TEST_TRACEAGENT
	/* load traceagent */
	{
		agent = omr_agent_create(&testVM.omrVM, "traceagent");
		ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() traceagent failed";

		OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));

		OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnLoad(agent));
	}
#endif /* TEST_TRACEAGENT */

	/* Initialise the omr_test module for tracing */
	UT_OMR_TEST_MODULE_LOADED(testVM.omrVM._trcEngine->utIntf);

	/* Fire some trace points! */
	Trc_OMR_Test_Init();
	Trc_OMR_Test_String(vmthread, "Hello World!");
	Trc_OMR_Test_Ptr(vmthread, vmthread);
	Trc_OMR_Test_Int(vmthread, 10);
	Trc_OMR_Test_ManyParms(vmthread, "Hello again!", vmthread, 10);

	/* Fire some trace points in another thread. */
	OMRTEST_ASSERT_ERROR_NONE(startTestChildThread(&testVM, vmthread, &childThread, &childData));

	OMRTEST_ASSERT_ERROR_NONE(waitForTestChildThread(&testVM, childThread, childData));

	/* Confirm that the test worked! */
	/* OMRTODO Check something */

	UT_OMR_TEST_MODULE_UNLOADED(testVM.omrVM._trcEngine->utIntf);

#if TEST_TRACEAGENT
	/* Unload the traceagent */
	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);
#endif /* TEST_TRACEAGENT */

	/* Load sampleSubscriber agent */
#if defined(WIN32)
	agent = omr_agent_create(&testVM.omrVM, "sampleSubscriber=NUL");
#else /* defined(WIN32) */
	agent = omr_agent_create(&testVM.omrVM, "sampleSubscriber=/dev/null");
#endif /* defined(WIN32) */
	ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() sampleSubscriber failed";

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnLoad(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);

	/* Load bindthreadagent agent */
	agent = omr_agent_create(&testVM.omrVM, "bindthreadagent");
	ASSERT_FALSE(NULL == agent) << "testAgent: createAgent() bindthreadagent failed";

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_openLibrary(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnLoad(agent));

	OMRTEST_ASSERT_ERROR_NONE(omr_agent_callOnUnload(agent));
	omr_agent_destroy(agent);

	OMRTEST_ASSERT_ERROR_NONE(omr_ras_cleanupTraceEngine(vmthread));

	OMRTEST_ASSERT_ERROR_NONE(OMR_Thread_Free(vmthread));

	/* Now clear up the VM we started for this test case. */
	OMRTEST_ASSERT_ERROR_NONE(omrTestVMFini(&testVM));
}