diff options
author | Yuxin Hu <yuxinhu@google.com> | 2024-04-18 18:45:36 -0700 |
---|---|---|
committer | Lorenzo Dal Col <lorenzo@khronosgroup.org> | 2024-05-08 14:19:39 +0000 |
commit | bb82a4ee83b3906bf4f1b93682e1fcf7f12a0664 (patch) | |
tree | 84de3bd9e4cbb6c1cf74dd0b27b021fb80d766bd | |
parent | 9a6badfb4498afe947d5a4083e8bd2a5ad39f15d (diff) | |
download | deqp-upstream-vulkan-cts-1.3.8.tar.gz |
Add test log parser for new android activityupstream-vulkan-cts-1.3.8
This change adds four new signatures in ContainerFormatParser
To process the logs generated by the new Android
activity introduced in https://gerrit.khronos.org/c/vk-gl-cts/+/14242:
1) beginTestRunParamsCollection
2) endTestRunParamsCollection
3) beginTestRunParams
4) endTestRunParams
This change also adds a new class type KhronosCTSTestLogListener,
a subclass of TestLogListener. The new KhronosCTSTestLogListener
receives the processed log from the ContainerFormatParser,
and notifies the android instrumentation process
(code for the instrumentation process is in future changes) based on
the information received in the processed log. That way the instrumentation
process will know if the new android activity has finished the four tasks.
The instrumentation process is also able to get the test run parameters,
which is needed for the instrumentation process to launch the
Khronos GLES 3.2 CTS in Android test infra.
This change also modifies the function signature of
TestLogParser::parse() to take a TestLogListener pointer, instead of
a reference. So that both parent class TestLogListner instance,
and the child class KhronosCTSTestLogListener instance, can be
passed to the same function.
Affected tests: None
Components: Framework
VK-GL-CTS issue: 5024
Change-Id: I2ffad0684ae8be2220d1ad283f12b0d535babb0e
(cherry picked from commit 7a39bd60e349ca3a66c39a20990bc7aabc2a109d)
-rw-r--r-- | executor/xeContainerFormatParser.cpp | 16 | ||||
-rw-r--r-- | executor/xeContainerFormatParser.hpp | 7 | ||||
-rw-r--r-- | framework/platform/android/tcuTestLogParserJNI.cpp | 188 |
3 files changed, 194 insertions, 17 deletions
diff --git a/executor/xeContainerFormatParser.cpp b/executor/xeContainerFormatParser.cpp index 39deeb873..76b87fa83 100644 --- a/executor/xeContainerFormatParser.cpp +++ b/executor/xeContainerFormatParser.cpp @@ -124,6 +124,12 @@ int ContainerFormatParser::getChar (int offset) const return END_OF_BUFFER; } +const char* ContainerFormatParser::getTestRunsParams(void) const +{ + DE_ASSERT(m_element == CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN); + return m_value.c_str(); +} + void ContainerFormatParser::advance (void) { if (m_element != CONTAINERELEMENT_INCOMPLETE) @@ -198,7 +204,11 @@ void ContainerFormatParser::parseContainerLine (void) { "terminateTestCaseResult", CONTAINERELEMENT_TERMINATE_TEST_CASE_RESULT }, { "sessionInfo", CONTAINERELEMENT_SESSION_INFO }, { "beginSession", CONTAINERELEMENT_BEGIN_SESSION }, - { "endSession", CONTAINERELEMENT_END_SESSION } + { "endSession", CONTAINERELEMENT_END_SESSION }, + { "beginTestRunParamsCollection", CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_BEGIN}, + { "endTestRunParamsCollection", CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_END}, + { "beginTestRunParams", CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN}, + { "endTestRunParams", CONTAINERELEMENT_TEST_RUN_PARAM_END}, }; DE_ASSERT(m_elementLen >= 1); @@ -242,10 +252,14 @@ void ContainerFormatParser::parseContainerLine (void) case CONTAINERELEMENT_BEGIN_SESSION: case CONTAINERELEMENT_END_SESSION: case CONTAINERELEMENT_END_TEST_CASE_RESULT: + case CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_BEGIN: + case CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_END: + case CONTAINERELEMENT_TEST_RUN_PARAM_END: break; // No attribute or value. case CONTAINERELEMENT_BEGIN_TEST_CASE_RESULT: case CONTAINERELEMENT_TERMINATE_TEST_CASE_RESULT: + case CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN: if (getChar(offset) != ' ') error("Expected value after instruction"); offset += 1; diff --git a/executor/xeContainerFormatParser.hpp b/executor/xeContainerFormatParser.hpp index 5167ce857..9e935273e 100644 --- a/executor/xeContainerFormatParser.hpp +++ b/executor/xeContainerFormatParser.hpp @@ -40,6 +40,10 @@ enum ContainerElement CONTAINERELEMENT_END_TEST_CASE_RESULT, CONTAINERELEMENT_TERMINATE_TEST_CASE_RESULT, CONTAINERELEMENT_TEST_LOG_DATA, + CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_BEGIN, + CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_END, + CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN, + CONTAINERELEMENT_TEST_RUN_PARAM_END, CONTAINERELEMENT_LAST }; @@ -77,6 +81,9 @@ public: int getDataSize (void) const; void getData (deUint8* dst, int numBytes, int offset); + // TEST_RUN_PARAM + const char* getTestRunsParams (void) const; + private: ContainerFormatParser (const ContainerFormatParser& other); ContainerFormatParser& operator= (const ContainerFormatParser& other); diff --git a/framework/platform/android/tcuTestLogParserJNI.cpp b/framework/platform/android/tcuTestLogParserJNI.cpp index e436b9754..0404ad3d5 100644 --- a/framework/platform/android/tcuTestLogParserJNI.cpp +++ b/framework/platform/android/tcuTestLogParserJNI.cpp @@ -44,7 +44,7 @@ class TestLogListener { public: TestLogListener (JNIEnv* env, jobject object); - ~TestLogListener (void); + virtual ~TestLogListener (void); void beginSession (void); void endSession (void); @@ -58,7 +58,12 @@ public: void testLogData (const char* data); -private: + virtual void beginTestRunParamsCollection (void); + virtual void endTestRunParamsCollection (void); + virtual void beginTestRunParams (const char* testRunsParams); + virtual void endTestRunParams (void); + +protected: JNIEnv* m_env; jobject m_object; jclass m_class; @@ -164,13 +169,89 @@ void TestLogListener::testLogData (const char* data) m_env->DeleteLocalRef(logData); } +void TestLogListener::beginTestRunParamsCollection(void) +{ +} + +void TestLogListener::endTestRunParamsCollection(void) +{ +} + +void TestLogListener::beginTestRunParams(const char*) +{ +} + +void TestLogListener::endTestRunParams(void) +{ +} + +class KhronosCTSTestLogListener : public TestLogListener +{ +public: + KhronosCTSTestLogListener (JNIEnv* env, jobject object); + virtual ~KhronosCTSTestLogListener(); + + virtual void beginTestRunParamsCollection (void); + virtual void endTestRunParamsCollection (void); + virtual void beginTestRunParams (const char* testRunsParams); + virtual void endTestRunParams (void); + + +private: + jmethodID m_beginTestRunParamsCollectionID; + jmethodID m_endTestRunParamsCollectionID; + jmethodID m_beginTestRunParamsID; + jmethodID m_endTestRunParamsID; +}; + +KhronosCTSTestLogListener::KhronosCTSTestLogListener (JNIEnv* env, jobject object) + : TestLogListener(env, object) +{ + + m_beginTestRunParamsCollectionID = m_env->GetMethodID(m_class, "beginTestRunParamsCollection", "()V"); + m_endTestRunParamsCollectionID = m_env->GetMethodID(m_class, "endTestRunParamsCollection", "()V"); + m_beginTestRunParamsID = m_env->GetMethodID(m_class, "beginTestRunParams", "(Ljava/lang/String;)V"); + m_endTestRunParamsID = m_env->GetMethodID(m_class, "endTestRunParams", "()V"); + + TCU_CHECK_INTERNAL(m_beginTestRunParamsCollectionID); + TCU_CHECK_INTERNAL(m_endTestRunParamsCollectionID); + TCU_CHECK_INTERNAL(m_beginTestRunParamsID); + TCU_CHECK_INTERNAL(m_endTestRunParamsID); +} + +KhronosCTSTestLogListener::~KhronosCTSTestLogListener (void) +{ +} + +void KhronosCTSTestLogListener::beginTestRunParamsCollection(void) +{ + m_env->CallVoidMethod(m_object, m_beginTestRunParamsCollectionID); +} + +void KhronosCTSTestLogListener::endTestRunParamsCollection(void) +{ + m_env->CallVoidMethod(m_object, m_endTestRunParamsCollectionID); +} + +void KhronosCTSTestLogListener::beginTestRunParams(const char* testRunsParams) +{ + jstring jTestRunsParams = m_env->NewStringUTF(testRunsParams); + m_env->CallVoidMethod(m_object, m_beginTestRunParamsID, jTestRunsParams); + m_env->DeleteLocalRef(jTestRunsParams); +} + +void KhronosCTSTestLogListener::endTestRunParams(void) +{ + m_env->CallVoidMethod(m_object, m_endTestRunParamsID); +} + class TestLogParser { public: TestLogParser (bool logData); ~TestLogParser (void); - void parse (TestLogListener& listener, const char* buffer, size_t size); + void parse (TestLogListener* listener, const char* buffer, size_t size); private: const bool m_logData; @@ -196,7 +277,7 @@ TestLogParser::~TestLogParser (void) { } -void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t size) +void TestLogParser::parse (TestLogListener* listener, const char* buffer, size_t size) { m_containerParser.feed((const deUint8*)buffer, size); @@ -209,19 +290,19 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t break; case xe::CONTAINERELEMENT_BEGIN_SESSION: - listener.beginSession(); + listener->beginSession(); break; case xe::CONTAINERELEMENT_END_SESSION: - listener.endSession(); + listener->endSession(); break; case xe::CONTAINERELEMENT_SESSION_INFO: - listener.sessionInfo(m_containerParser.getSessionInfoAttribute(), m_containerParser.getSessionInfoValue()); + listener->sessionInfo(m_containerParser.getSessionInfoAttribute(), m_containerParser.getSessionInfoValue()); break; case xe::CONTAINERELEMENT_BEGIN_TEST_CASE_RESULT: - listener.beginTestCase(m_containerParser.getTestCasePath()); + listener->beginTestCase(m_containerParser.getTestCasePath()); m_inTestCase = DE_TRUE; m_loggedResult = DE_FALSE; @@ -233,7 +314,7 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t case xe::CONTAINERELEMENT_END_TEST_CASE_RESULT: if (m_testCaseResult.statusCode != xe::TESTSTATUSCODE_LAST && !m_loggedResult) { - listener.testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); + listener->testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); m_loggedResult = DE_TRUE; } @@ -247,10 +328,10 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t xe::writeTestResult(m_testCaseResult, xmlWriter); - listener.testLogData(testLog.str().c_str()); + listener->testLogData(testLog.str().c_str()); } - listener.endTestCase(); + listener->endTestCase(); m_inTestCase = DE_FALSE; break; @@ -266,16 +347,16 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t xe::writeTestResult(m_testCaseResult, xmlWriter); - listener.testLogData(testLog.str().c_str()); + listener->testLogData(testLog.str().c_str()); } if (m_testCaseResult.statusCode != xe::TESTSTATUSCODE_LAST && !m_loggedResult) { - listener.testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); + listener->testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); m_loggedResult = DE_TRUE; } - listener.terminateTestCase(m_containerParser.getTerminateReason()); + listener->terminateTestCase(m_containerParser.getTerminateReason()); m_inTestCase = DE_FALSE; break; @@ -292,7 +373,7 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t { if (m_testCaseResult.statusCode != xe::TESTSTATUSCODE_LAST && !m_loggedResult) { - listener.testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); + listener->testCaseResult(xe::getTestStatusCodeName(m_testCaseResult.statusCode), m_testCaseResult.statusDetails.c_str()); m_loggedResult = DE_TRUE; } } @@ -301,6 +382,22 @@ void TestLogParser::parse (TestLogListener& listener, const char* buffer, size_t break; } + case xe::CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_BEGIN: + listener->beginTestRunParamsCollection(); + break; + + case xe::CONTAINERELEMENT_TEST_RUN_PARAM_SESSION_END: + listener->endTestRunParamsCollection(); + break; + + case xe::CONTAINERELEMENT_TEST_RUN_PARAM_BEGIN: + listener->beginTestRunParams(m_containerParser.getTestRunsParams()); + break; + + case xe::CONTAINERELEMENT_TEST_RUN_PARAM_END: + listener->endTestRunParams(); + break; + default: DE_ASSERT(DE_FALSE); @@ -369,7 +466,66 @@ JNIEXPORT void JNICALL Java_com_drawelements_deqp_testercore_TestLogParser_nativ logData = env->GetByteArrayElements(buffer, NULL); - parser->parse(listener, (const char*)logData, (size_t)size); + parser->parse(&listener, (const char*)logData, (size_t)size); + env->ReleaseByteArrayElements(buffer, logData, JNI_ABORT); + logData = DE_NULL; + } + catch (const std::exception& e) + { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", e.what()); + + if (logData) + env->ReleaseByteArrayElements(buffer, logData, JNI_ABORT); + + throwJNIException(env, e); + } +} + +JNIEXPORT jlong JNICALL Java_org_khronos_cts_testercore_KhronosCTSTestLogParser_nativeCreate (JNIEnv* env, jclass, jboolean logData) +{ + DE_UNREF(env); + + try + { + return (jlong)new TestLogParser(logData); + } + catch (const std::exception& e) + { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", e.what()); + + throwJNIException(env, e); + return 0; + } +} + +JNIEXPORT void JNICALL Java_org_khronos_cts_testercore_KhronosCTSTestLogParser_nativeDestroy (JNIEnv* env, jclass, jlong nativePointer) +{ + DE_UNREF(env); + + try + { + delete ((TestLogParser*)nativePointer); + } + catch (const std::exception& e) + { + __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, "%s", e.what()); + + throwJNIException(env, e); + } +} + +JNIEXPORT void JNICALL Java_org_khronos_cts_testercore_KhronosCTSTestLogParser_nativeParse (JNIEnv* env, jclass, jlong nativePointer, jobject instrumentation, jbyteArray buffer, jint size) +{ + jbyte* logData = DE_NULL; + + try + { + TestLogParser* parser = (TestLogParser*)nativePointer; + TestLogListener listener (env, instrumentation); + + logData = env->GetByteArrayElements(buffer, NULL); + + parser->parse(&listener, (const char*)logData, (size_t)size); env->ReleaseByteArrayElements(buffer, logData, JNI_ABORT); logData = DE_NULL; } |