void ShockerScriptableControlObject::CaptureMultipleImages (const NPVariant *args, uint32_t arg_count, NPVariant *result) { const char *path; g_assert (arg_count == 9); g_assert (NPVARIANT_IS_STRING (args [0])); g_assert (NPVARIANT_IS_STRING (args [1])); g_assert (NPVARIANT_IS_NUMBER (args [2])); g_assert (NPVARIANT_IS_NUMBER (args [3])); g_assert (NPVARIANT_IS_NUMBER (args [4])); g_assert (NPVARIANT_IS_NUMBER (args [5])); g_assert (NPVARIANT_IS_NUMBER (args [6])); g_assert (NPVARIANT_IS_NUMBER (args [7])); g_assert (NPVARIANT_IS_NUMBER (args [8])); path = STR_FROM_VARIANT (args [1]); if (path == NULL || path [0] == 0) path = GetTestPath (); LOG_PLUGIN ("[%i shocker] ShockerScriptableControlObject::CaptureMultipleImages (base_dir: '%s', file_name: '%s', x: %i, y: %i, width: %i, height: %i, count: %i, interval: %i, initial_delay: %i)\n", getpid (), STR_FROM_VARIANT (args [0]), STR_FROM_VARIANT (args [1]), NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]), NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]),NUMBER_TO_INT32 (args [6]), NUMBER_TO_INT32 (args [7]), NUMBER_TO_INT32 (args [8])); GetImageCaptureProvider ()->CaptureMultipleImages (path, NUMBER_TO_INT32 (args [2]), NUMBER_TO_INT32 (args [3]), NUMBER_TO_INT32 (args [4]), NUMBER_TO_INT32 (args [5]),NUMBER_TO_INT32 (args [6]), NUMBER_TO_INT32 (args [7]), NUMBER_TO_INT32 (args [8])); BOOLEAN_TO_NPVARIANT (true, *result); }
ShockerScriptableControlObject::ShockerScriptableControlObject (NPP instance) : ShockerScriptableObject (instance) { image_capture = new ImageCaptureProvider (); test_path = NULL; render_data_capturer = NULL; LogProvider::GetInstance ()->SetTestName (GetTestPath ()); }
// This test tests the situation that ranges of functions covered by .eh_frame and .ARM.exidx // overlap with each other, which appears in /system/lib/libart.so. TEST(libbacktrace, offline_unwind_mix_eh_frame_and_arm_exidx) { // TODO: For now, only run on the given arch. if (std::string(ABI_STRING) != "arm") { GTEST_LOG_(INFO) << "Skipping test since offline for arm on " << ABI_STRING << " isn't supported."; return; } const std::string testlib_path(GetTestPath("libart.so")); struct stat st; ASSERT_EQ(0, stat(testlib_path.c_str(), &st)) << "can't find testlib " << testlib_path; const std::string offline_testdata_path(GetTestPath("offline_testdata_for_libart")); OfflineTestData testdata; ASSERT_TRUE(ReadOfflineTestData(offline_testdata_path, &testdata)); // Fix path of /system/lib/libart.so. for (auto& map : testdata.maps) { if (map.name.find("libart.so") != std::string::npos) { map.name = testlib_path; } } // Do offline backtrace. std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(testdata.pid, testdata.maps)); ASSERT_TRUE(map != nullptr); std::unique_ptr<Backtrace> backtrace( Backtrace::CreateOffline(testdata.pid, testdata.tid, map.get(), testdata.stack_info)); ASSERT_TRUE(backtrace != nullptr); ucontext_t ucontext = GetUContextFromUnwContext(testdata.unw_context); ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); // The last frame is outside of libart.so ASSERT_EQ(testdata.symbols.size() + 1, backtrace->NumFrames()); for (size_t i = 0; i + 1 < backtrace->NumFrames(); ++i) { uintptr_t vaddr_in_file = backtrace->GetFrame(i)->pc - testdata.maps[0].start + testdata.maps[0].load_bias; std::string name = FunctionNameForAddress(vaddr_in_file, testdata.symbols); ASSERT_EQ(name, testdata.symbols[i].name); } }
CStdString CTestUtils::GetTestFileFolder(bool bForwardSlashes) { CStdString sModuleName = GetLongModuleName(); CStdString sTestPath = GetTestPath(sModuleName); if (bForwardSlashes) { sTestPath.Replace(_T('\\'), _T('/')); } return sTestPath; }
static void BacktraceOfflineTest(const char* arch, const std::string& testlib_name) { // TODO: For now, we can only run this on the same arch as the library arch. if (std::string(ABI_STRING) != arch) { GTEST_LOG_(INFO) << "Ignoring arch " << arch << " for lib " << testlib_name; return; } const std::string testlib_path(GetTestPath(testlib_name)); const std::string offline_testdata_path(GetTestPath("offline_testdata")); OfflineTestData testdata; ASSERT_TRUE(ReadOfflineTestData(offline_testdata_path, &testdata)); // Fix path of libbacktrace_testlib.so. for (auto& map : testdata.maps) { if (map.name.find("libbacktrace_test.so") != std::string::npos) { map.name = testlib_path; } } // Do offline backtrace. std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(testdata.pid, testdata.maps)); ASSERT_TRUE(map != nullptr); std::unique_ptr<Backtrace> backtrace( Backtrace::CreateOffline(testdata.pid, testdata.tid, map.get(), testdata.stack_info)); ASSERT_TRUE(backtrace != nullptr); ucontext_t ucontext = GetUContextFromUnwContext(testdata.unw_context); ASSERT_TRUE(backtrace->Unwind(0, &ucontext)); // Collect pc values of the call stack frames. std::vector<uintptr_t> pc_values; for (size_t i = 0; i < backtrace->NumFrames(); ++i) { pc_values.push_back(backtrace->GetFrame(i)->pc); } size_t test_one_index = 0; for (size_t i = 0; i < pc_values.size(); ++i) { if (FunctionNameForAddress(pc_values[i], testdata.symbols) == "test_level_one") { test_one_index = i; break; } } ASSERT_GE(test_one_index, 3u); ASSERT_EQ("test_level_one", FunctionNameForAddress(pc_values[test_one_index], testdata.symbols)); ASSERT_EQ("test_level_two", FunctionNameForAddress(pc_values[test_one_index - 1], testdata.symbols)); ASSERT_EQ("test_level_three", FunctionNameForAddress(pc_values[test_one_index - 2], testdata.symbols)); ASSERT_EQ("test_level_four", FunctionNameForAddress(pc_values[test_one_index - 3], testdata.symbols)); }