Debian Codegraph @

crt/aws-c-common/AWSCRTAndroidTestRunner/app/src/main/cpp/native-lib.cpp

raw symbols SCIP
1 #include <jni.h>
2 #include <string>
3 #include <sstream>
4
5 #include <dlfcn.h>
6
7 #include <android/log.h>
8
9 typedef int(test_fn_t)(int, char**);
10
11 extern "C" JNIEXPORT jint JNICALL
12 Java_software_amazon_awssdk_crt_awscrtandroidtestrunner_NativeTestFixture_runTest(
13 JNIEnv *env,
14 jobject /* this */,
15 jstring jni_name) {
16 const char *test_name = env->GetStringUTFChars(jni_name, nullptr);
17 __android_log_print(ANDROID_LOG_INFO, "native-test", "RUNNING %s", test_name);
18
19 test_fn_t *test_fn = (test_fn_t*)dlsym(RTLD_DEFAULT, test_name);
20 if (!test_fn) {
21 __android_log_print(ANDROID_LOG_WARN, "native-test", "%s NOT FOUND", test_name);
22 return -1;
23 }
24
25 int result = test_fn(0, nullptr);
26 __android_log_print(
27 result ? ANDROID_LOG_FATAL : ANDROID_LOG_INFO,
28 "native-test",
29 "%s %s", test_name, result ? "FAILED" : "OK");
30 return result;
31 }