From 9d91e898317fe19051d486fb76271a89603b5de8 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 30 Mar 2018 20:43:45 -0700 Subject: tests: Pick up testdata with LOCAL_TEST_DATA. Also push the testdata in AndroidTest.xml for `atest`. LOCAL_TEST_DATA was added in commit [1], which ships testdata next to native tests. With this CL, 1) manually sync-ing via `adb sync` and running tests with `adb shell` keep working. 2) both of 32- and 64-bit recovery_{unit,component}_test now work in APCT continuous tests. Note that 64-bit tests were failing previously in APCT, due to missing testdata. 3) `atest recovery_unit_test` works, as the testdata gets pushed to /data/local/tmp. [1] commit d07ba4e2a625a8f000d042c1953adb612bccbbe2 in https://android-review.googlesource.com/c/platform/build/+/312567. Bug: 77320514 Test: Build recovery_{unit,component,manual}_test. Setup the test via `adb sync data`. Run both of 32- and 64-bit versions on device. Test: Build and run recovery_host_test on host, for both of 32- and 64-bit versions. Test: `atest recovery_component_test` Change-Id: Ie54037726043a3a659a80030b83db1f8c1de318d --- tests/manual/recovery_test.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/manual/recovery_test.cpp') diff --git a/tests/manual/recovery_test.cpp b/tests/manual/recovery_test.cpp index 64e3b59e6..224ed5b68 100644 --- a/tests/manual/recovery_test.cpp +++ b/tests/manual/recovery_test.cpp @@ -34,7 +34,6 @@ static const std::string myFilename = "/data/misc/recovery/inject.txt"; static const std::string myContent = "Hello World\nWelcome to my recovery\n"; static const std::string kLocale = "zu"; -static const std::string kResourceTestDir = "/data/nativetest/recovery/"; // Failure is expected on systems that do not deliver either the // recovery-persist or recovery-refresh executables. Tests also require @@ -108,19 +107,20 @@ static int png_filter(const dirent* de) { return 1; } -// Find out all png files to test under /data/nativetest/recovery/. +// Find out all the PNG files to test, which stay under the same dir with the executable. static std::vector add_files() { + std::string exec_dir = android::base::GetExecutableDirectory(); std::vector files; - for (const std::string& str : image_dir) { - std::string dir_path = kResourceTestDir + str; + for (const std::string& image : image_dir) { + std::string dir_path = exec_dir + "/" + image; dirent** namelist; int n = scandir(dir_path.c_str(), &namelist, png_filter, alphasort); if (n == -1) { - printf("Failed to scan dir %s: %s\n", kResourceTestDir.c_str(), strerror(errno)); + printf("Failed to scan dir %s: %s\n", exec_dir.c_str(), strerror(errno)); return files; } if (n == 0) { - printf("No file is added for test in %s\n", kResourceTestDir.c_str()); + printf("No file is added for test in %s\n", exec_dir.c_str()); } while (n--) { -- cgit v1.2.3