summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 17:16:40 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-06-08 17:16:40 +0000
commit39fb9e3f16fbc5caa25aec19312593e3f0bf0a10 (patch)
tree95b44f2aecfe3d21c009ae3e302169862e45056f
parent6a14ab1c6a53e05dbe50718afcc277fe29c6c1e8 (diff)
parentbd5dcb956941bd839897ec6ddc81f1aa39875b9a (diff)
downloadart-android13-platform-release.tar.gz
Change-Id: Ifb30cbfe3daea52a1430aab0fa98fae9a6259166
-rw-r--r--TEST_MAPPING51
-rw-r--r--dex2oat/dex2oat_cts_test.cc45
-rw-r--r--libartbase/base/common_art_test.h4
-rw-r--r--libartpalette/apex/palette_test.cc27
-rw-r--r--libnativeloader/native_loader_test.cpp24
-rw-r--r--libnativeloader/public_libraries.cpp6
-rw-r--r--runtime/dex2oat_environment_test.h74
-rw-r--r--test/924-threads/src/art/Test924.java24
-rwxr-xr-xtest/utils/regen-test-files24
9 files changed, 167 insertions, 112 deletions
diff --git a/TEST_MAPPING b/TEST_MAPPING
index e799c0a565..2caaad1e4d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1232,18 +1232,6 @@
"name": "art_standalone_cmdline_tests[com.google.android.art.apex]"
},
{
- "name": "art_standalone_compiler_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_dexdump_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_dexlist_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_dexoptanalyzer_tests[com.google.android.art.apex]"
- },
- {
"name": "art_standalone_libartpalette_tests[com.google.android.art.apex]"
},
{
@@ -1262,18 +1250,6 @@
"name": "art_standalone_libprofile_tests[com.google.android.art.apex]"
},
{
- "name": "art_standalone_oatdump_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_profman_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_runtime_compiler_tests[com.google.android.art.apex]"
- },
- {
- "name": "art_standalone_runtime_tests[com.google.android.art.apex]"
- },
- {
"name": "art_standalone_sigchain_tests[com.google.android.art.apex]"
},
{
@@ -2524,18 +2500,6 @@
"name": "art_standalone_cmdline_tests"
},
{
- "name": "art_standalone_compiler_tests"
- },
- {
- "name": "art_standalone_dexdump_tests"
- },
- {
- "name": "art_standalone_dexlist_tests"
- },
- {
- "name": "art_standalone_dexoptanalyzer_tests"
- },
- {
"name": "art_standalone_libartpalette_tests"
},
{
@@ -2554,21 +2518,6 @@
"name": "art_standalone_libprofile_tests"
},
{
- "name": "art_standalone_oatdump_tests"
- },
- {
- "name": "art_standalone_odrefresh_tests"
- },
- {
- "name": "art_standalone_profman_tests"
- },
- {
- "name": "art_standalone_runtime_compiler_tests"
- },
- {
- "name": "art_standalone_runtime_tests"
- },
- {
"name": "art_standalone_sigchain_tests"
},
{
diff --git a/dex2oat/dex2oat_cts_test.cc b/dex2oat/dex2oat_cts_test.cc
index 41c7015090..254126446d 100644
--- a/dex2oat/dex2oat_cts_test.cc
+++ b/dex2oat/dex2oat_cts_test.cc
@@ -14,11 +14,54 @@
* limitations under the License.
*/
+#include "base/file_utils.h"
#include "dex2oat_environment_test.h"
namespace art {
-class Dex2oatCtsTest : public Dex2oatEnvironmentTest {};
+class Dex2oatCtsTest : public CommonArtTest, public Dex2oatScratchDirs {
+ public:
+ void SetUp() override {
+ CommonArtTest::SetUp();
+ Dex2oatScratchDirs::SetUp(android_data_);
+ }
+
+ void TearDown() override {
+ Dex2oatScratchDirs::TearDown();
+ CommonArtTest::TearDown();
+ }
+
+ protected:
+ // Stripped down counterpart to Dex2oatEnvironmentTest::Dex2Oat that only adds
+ // enough arguments for our purposes.
+ int Dex2Oat(const std::vector<std::string>& dex2oat_args,
+ std::string* output,
+ std::string* error_msg) {
+ // This command line should work regardless of bitness, ISA, etc.
+ std::vector<std::string> argv = {std::string(kAndroidArtApexDefaultPath) + "/bin/dex2oat"};
+ argv.insert(argv.end(), dex2oat_args.begin(), dex2oat_args.end());
+
+ // We must set --android-root.
+ const char* android_root = getenv("ANDROID_ROOT");
+ CHECK(android_root != nullptr);
+ argv.push_back("--android-root=" + std::string(android_root));
+
+ // We need dex2oat to actually log things.
+ auto post_fork_fn = []() { return setenv("ANDROID_LOG_TAGS", "*:d", 1) == 0; };
+ ForkAndExecResult res = ForkAndExec(argv, post_fork_fn, output);
+ if (res.stage != ForkAndExecResult::kFinished) {
+ *error_msg = strerror(errno);
+ ::testing::AssertionFailure() << "Failed to finish dex2oat invocation: " << *error_msg;
+ }
+
+ if (!res.StandardSuccess()) {
+ // We cannot use ASSERT_TRUE since the method returns an int and not void.
+ ::testing::AssertionFailure() << "dex2oat fork/exec failed: " << *error_msg;
+ }
+
+ return res.status_code;
+ }
+};
// Run dex2oat with --enable-palette-compilation-hooks to force calls to
// PaletteNotify{Start,End}Dex2oatCompilation.
diff --git a/libartbase/base/common_art_test.h b/libartbase/base/common_art_test.h
index 6124ed9e2a..bd06043907 100644
--- a/libartbase/base/common_art_test.h
+++ b/libartbase/base/common_art_test.h
@@ -139,6 +139,8 @@ class CommonArtTestImpl {
static void TearDownAndroidDataDir(const std::string& android_data, bool fail_on_error);
+ static void ClearDirectory(const char* dirpath, bool recursive = true);
+
// Get the names of the libcore modules.
virtual std::vector<std::string> GetLibCoreModuleNames() const;
@@ -231,8 +233,6 @@ class CommonArtTestImpl {
std::unique_ptr<const DexFile> LoadExpectSingleDexFile(const char* location);
- void ClearDirectory(const char* dirpath, bool recursive = true);
-
// Open a file (allows reading of framework jars).
std::vector<std::unique_ptr<const DexFile>> OpenDexFiles(const char* filename);
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index 853dc29f58..0bcc09329b 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -21,7 +21,6 @@
#include <sys/syscall.h>
#include <unistd.h>
-#include "common_runtime_test.h"
#include "gtest/gtest.h"
namespace {
@@ -70,14 +69,32 @@ TEST_F(PaletteClientTest, Ashmem) {
#endif
}
-class PaletteClientJniTest : public art::CommonRuntimeTest {};
-
-TEST_F(PaletteClientJniTest, JniInvocation) {
+TEST_F(PaletteClientTest, JniInvocation) {
+#ifndef ART_TARGET_ANDROID
+ // On host we need to set up a boot classpath and pass it in here. Let's not
+ // bother since this test is only for native API coverage on target.
+ GTEST_SKIP() << "Will only spin up a VM on Android";
+#else
bool enabled;
EXPECT_EQ(PALETTE_STATUS_OK, PaletteShouldReportJniInvocations(&enabled));
- JNIEnv* env = art::Thread::Current()->GetJniEnv();
+ JavaVMInitArgs vm_args;
+ JavaVMOption options[] = {
+ {.optionString = "-verbose:jni", .extraInfo = nullptr},
+ };
+ vm_args.version = JNI_VERSION_1_6;
+ vm_args.nOptions = std::size(options);
+ vm_args.options = options;
+ vm_args.ignoreUnrecognized = JNI_TRUE;
+
+ JavaVM* jvm = nullptr;
+ JNIEnv* env = nullptr;
+ EXPECT_EQ(JNI_OK, JNI_CreateJavaVM(&jvm, &env, &vm_args));
ASSERT_NE(nullptr, env);
+
PaletteNotifyBeginJniInvocation(env);
PaletteNotifyEndJniInvocation(env);
+
+ EXPECT_EQ(JNI_OK, jvm->DestroyJavaVM());
+#endif
}
diff --git a/libnativeloader/native_loader_test.cpp b/libnativeloader/native_loader_test.cpp
index 9648713e70..1dc778abcd 100644
--- a/libnativeloader/native_loader_test.cpp
+++ b/libnativeloader/native_loader_test.cpp
@@ -31,6 +31,7 @@ namespace android {
namespace nativeloader {
using ::testing::Eq;
+using ::testing::MatchesRegex;
using ::testing::NotNull;
using ::testing::StrEq;
using internal::ConfigEntry;
@@ -224,7 +225,7 @@ class NativeLoaderTest_Create : public NativeLoaderTest {
EXPECT_CALL(*mock, NativeBridgeInitialized()).Times(testing::AnyNumber());
EXPECT_CALL(*mock, mock_create_namespace(
- Eq(IsBridged()), StrEq(expected_namespace_name), nullptr,
+ Eq(IsBridged()), MatchesRegex(expected_namespace_name), nullptr,
StrEq(expected_library_path), expected_namespace_flags,
StrEq(expected_permitted_path), NsEq(expected_parent_namespace.c_str())))
.WillOnce(Return(TO_MOCK_NAMESPACE(TO_ANDROID_NAMESPACE(dex_path.c_str()))));
@@ -344,7 +345,7 @@ TEST_P(NativeLoaderTest_Create, UnbundledVendorApp) {
expected_permitted_path = expected_permitted_path + ":/vendor/" LIB_DIR;
expected_shared_libs_to_platform_ns =
default_public_libraries() + ":" + llndk_libraries_vendor();
- expected_link_with_vndk_ns = true;
+ expected_link_with_vndk_ns = !get_vndk_version(/*is_product_vndk=*/false).empty();
SetExpectations();
RunTest();
}
@@ -375,13 +376,28 @@ TEST_P(NativeLoaderTest_Create, UnbundledProductApp) {
is_shared = false;
if (is_product_vndk_version_defined()) {
- expected_namespace_name = "vendor-classloader-namespace";
+ expected_namespace_name = "(vendor|product)-classloader-namespace";
expected_library_path = expected_library_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
expected_permitted_path =
expected_permitted_path + ":/product/" LIB_DIR ":/system/product/" LIB_DIR;
+ expected_link_with_vndk_product_ns = true;
+
+ // The handling of extended libraries for product apps changed in the
+ // M-2022-10 release of the ART module (https://r.android.com/2194871).
+ // Since this test is in CTS for T, we need to accept both new and old
+ // behaviour, i.e. with and without the extended public libraries appended
+ // at the end. Skip the EXPECT_CALL in
+ // NativeLoaderTest_Create::SetExpectations and create a more lenient
+ // variant of it here.
+ expected_link_with_platform_ns = false;
expected_shared_libs_to_platform_ns =
default_public_libraries() + ":" + llndk_libraries_product();
- expected_link_with_vndk_product_ns = true;
+ EXPECT_CALL(*mock,
+ mock_link_namespaces(Eq(IsBridged()),
+ _,
+ NsEq("system"),
+ ::testing::StartsWith(expected_shared_libs_to_platform_ns)))
+ .WillOnce(Return(true));
}
SetExpectations();
RunTest();
diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp
index ffebe0b4c7..433a9095ef 100644
--- a/libnativeloader/public_libraries.cpp
+++ b/libnativeloader/public_libraries.cpp
@@ -212,6 +212,9 @@ static std::string InitExtendedPublicLibraries() {
}
static std::string InitLlndkLibrariesVendor() {
+ if (get_vndk_version(/*is_product_vndk=*/false).empty()) {
+ return "";
+ }
std::string config_file = kLlndkLibrariesFile;
InsertVndkVersionStr(&config_file, false);
auto sonames = ReadConfig(config_file, always_true);
@@ -237,6 +240,9 @@ static std::string InitLlndkLibrariesProduct() {
}
static std::string InitVndkspLibrariesVendor() {
+ if (get_vndk_version(/*is_product_vndk=*/false).empty()) {
+ return "";
+ }
std::string config_file = kVndkLibrariesFile;
InsertVndkVersionStr(&config_file, false);
auto sonames = ReadConfig(config_file, always_true);
diff --git a/runtime/dex2oat_environment_test.h b/runtime/dex2oat_environment_test.h
index 964b7f3fff..e867c4f915 100644
--- a/runtime/dex2oat_environment_test.h
+++ b/runtime/dex2oat_environment_test.h
@@ -41,21 +41,17 @@ namespace art {
static constexpr bool kDebugArgs = false;
-// Test class that provides some helpers to set a test up for compilation using dex2oat.
-class Dex2oatEnvironmentTest : public CommonRuntimeTest {
+class Dex2oatScratchDirs {
public:
- void SetUp() override {
- CommonRuntimeTest::SetUp();
- const ArtDexFileLoader dex_file_loader;
-
+ void SetUp(const std::string& android_data) {
// Create a scratch directory to work from.
// Get the realpath of the android data. The oat dir should always point to real location
// when generating oat files in dalvik-cache. This avoids complicating the unit tests
// when matching the expected paths.
- UniqueCPtr<const char[]> android_data_real(realpath(android_data_.c_str(), nullptr));
+ UniqueCPtr<const char[]> android_data_real(realpath(android_data.c_str(), nullptr));
ASSERT_TRUE(android_data_real != nullptr)
- << "Could not get the realpath of the android data" << android_data_ << strerror(errno);
+ << "Could not get the realpath of the android data" << android_data << strerror(errno);
scratch_dir_.assign(android_data_real.get());
scratch_dir_ += "/Dex2oatEnvironmentTest";
@@ -67,6 +63,41 @@ class Dex2oatEnvironmentTest : public CommonRuntimeTest {
odex_dir_ = odex_oat_dir_ + "/" + std::string(GetInstructionSetString(kRuntimeISA));
ASSERT_EQ(0, mkdir(odex_dir_.c_str(), 0700));
+ }
+
+ void TearDown() {
+ CommonArtTest::ClearDirectory(odex_dir_.c_str());
+ ASSERT_EQ(0, rmdir(odex_dir_.c_str()));
+
+ CommonArtTest::ClearDirectory(odex_oat_dir_.c_str());
+ ASSERT_EQ(0, rmdir(odex_oat_dir_.c_str()));
+
+ CommonArtTest::ClearDirectory(scratch_dir_.c_str());
+ ASSERT_EQ(0, rmdir(scratch_dir_.c_str()));
+ }
+
+ // Scratch directory, for dex and odex files (oat files will go in the
+ // dalvik cache).
+ const std::string& GetScratchDir() const { return scratch_dir_; }
+
+ // Odex directory is the subdirectory in the scratch directory where odex
+ // files should be located.
+ const std::string& GetOdexDir() const { return odex_dir_; }
+
+ private:
+ std::string scratch_dir_;
+ std::string odex_oat_dir_;
+ std::string odex_dir_;
+};
+
+// Test class that provides some helpers to set a test up for compilation using dex2oat.
+class Dex2oatEnvironmentTest : public Dex2oatScratchDirs, public CommonRuntimeTest {
+ public:
+ void SetUp() override {
+ CommonRuntimeTest::SetUp();
+ Dex2oatScratchDirs::SetUp(android_data_);
+
+ const ArtDexFileLoader dex_file_loader;
// Verify the environment is as we expect
std::vector<uint32_t> checksums;
@@ -122,15 +153,7 @@ class Dex2oatEnvironmentTest : public CommonRuntimeTest {
}
void TearDown() override {
- ClearDirectory(odex_dir_.c_str());
- ASSERT_EQ(0, rmdir(odex_dir_.c_str()));
-
- ClearDirectory(odex_oat_dir_.c_str());
- ASSERT_EQ(0, rmdir(odex_oat_dir_.c_str()));
-
- ClearDirectory(scratch_dir_.c_str());
- ASSERT_EQ(0, rmdir(scratch_dir_.c_str()));
-
+ Dex2oatScratchDirs::TearDown();
CommonRuntimeTest::TearDown();
}
@@ -165,18 +188,6 @@ class Dex2oatEnvironmentTest : public CommonRuntimeTest {
return GetTestDexFileName("Nested");
}
- // Scratch directory, for dex and odex files (oat files will go in the
- // dalvik cache).
- const std::string& GetScratchDir() const {
- return scratch_dir_;
- }
-
- // Odex directory is the subdirectory in the scratch directory where odex
- // files should be located.
- const std::string& GetOdexDir() const {
- return odex_dir_;
- }
-
int Dex2Oat(const std::vector<std::string>& dex2oat_args,
std::string* output,
std::string* error_msg) {
@@ -232,11 +243,6 @@ class Dex2oatEnvironmentTest : public CommonRuntimeTest {
return res.status_code;
}
-
- private:
- std::string scratch_dir_;
- std::string odex_oat_dir_;
- std::string odex_dir_;
};
} // namespace art
diff --git a/test/924-threads/src/art/Test924.java b/test/924-threads/src/art/Test924.java
index e97c9c6b35..355572044f 100644
--- a/test/924-threads/src/art/Test924.java
+++ b/test/924-threads/src/art/Test924.java
@@ -337,6 +337,19 @@ public class Test924 {
}
}
+ private static List<String> filterForThread(Object[] thread_messages, String thread_name) {
+ List<String> messageListForThread = new ArrayList<String>();
+
+ for (int i = 0; i < thread_messages.length; i++) {
+ String message = (String)thread_messages[i];
+ if (message.startsWith("Thread(" + thread_name + ")")) {
+ messageListForThread.add(message);
+ }
+ }
+
+ return messageListForThread;
+ }
+
private static void doTestEvents() throws Exception {
enableThreadEvents(true);
@@ -354,21 +367,24 @@ public class Test924 {
}
}
};
- Thread t = new Thread(r, "EventTestThread");
+ String thread_name = "EventTestThread";
+ Thread t = new Thread(r, thread_name);
System.out.println("Constructed thread");
Thread.yield();
Thread.sleep(100);
- System.out.println(Arrays.toString(getThreadEventMessages()));
+
+ // Check that there are no events related to EventTestThread that we just created.
+ System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
t.start();
cdl1.await();
- System.out.println(Arrays.toString(getThreadEventMessages()));
+ System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
cdl2.countDown();
t.join();
- System.out.println(Arrays.toString(getThreadEventMessages()));
+ System.out.println(filterForThread(getThreadEventMessages(), thread_name).toString());
System.out.println("Thread joined");
diff --git a/test/utils/regen-test-files b/test/utils/regen-test-files
index b6c2fb624c..ed8c1b51a2 100755
--- a/test/utils/regen-test-files
+++ b/test/utils/regen-test-files
@@ -209,11 +209,11 @@ known_failing_tests = frozenset([
art_gtest_user_module_names = [
"art_libnativebridge_cts_tests",
"art_standalone_cmdline_tests",
- "art_standalone_compiler_tests",
+ ###"art_standalone_compiler_tests", # b/275289981
# Temporarily disable this test as it is failing with ART module prebuilts (see b/243510263).
### "art_standalone_dex2oat_tests",
- "art_standalone_dexdump_tests",
- "art_standalone_dexlist_tests",
+ ###"art_standalone_dexdump_tests", # b/275289981
+ ###"art_standalone_dexlist_tests", # b/275289981
# Temporarily disable this test as it is failing with ART module prebuilts (see b/243507635).
### "art_standalone_libartbase_tests",
"art_standalone_libartpalette_tests",
@@ -222,18 +222,18 @@ art_gtest_user_module_names = [
"art_standalone_libdexfile_support_tests",
"art_standalone_libdexfile_tests",
"art_standalone_libprofile_tests",
- "art_standalone_oatdump_tests",
- "art_standalone_odrefresh_tests",
- "art_standalone_runtime_compiler_tests",
- "art_standalone_runtime_tests",
+ ###"art_standalone_oatdump_tests", # b/275289981
+ ###"art_standalone_odrefresh_tests", # b/275289981
+ ###"art_standalone_runtime_compiler_tests", # b/275289981
+ ###"art_standalone_runtime_tests", # b/275289981
"art_standalone_sigchain_tests",
"libnativeloader_test",
]
# ART gtests that need root access to the device.
art_gtest_eng_only_module_names = [
- "art_standalone_dexoptanalyzer_tests",
- "art_standalone_profman_tests",
+ ###"art_standalone_dexoptanalyzer_tests", # b/275289981
+ ###"art_standalone_profman_tests", # b/275289981
]
# All supported ART gtests.
@@ -247,7 +247,8 @@ art_gtest_mts_user_module_names = copy.copy(art_gtest_user_module_names)
# to land.
#
# TODO(b/206335809): Re-enable this test when the fix has landed.
-art_gtest_mts_user_module_names.remove("art_standalone_odrefresh_tests")
+if "art_standalone_odrefresh_tests" in art_gtest_mts_user_module_names:
+ art_gtest_mts_user_module_names.remove("art_standalone_odrefresh_tests")
# ART gtests supported in Mainline presubmits.
art_gtests_mainline_presubmit_module_names = copy.copy(art_gtest_module_names)
@@ -257,7 +258,8 @@ art_gtests_mainline_presubmit_module_names = copy.copy(art_gtest_module_names)
# land.
#
# TODO(b/206335809): Re-enable this test when the fix has landed.
-art_gtests_mainline_presubmit_module_names.remove("art_standalone_odrefresh_tests")
+if "art_standalone_odrefresh_tests" in art_gtests_mainline_presubmit_module_names:
+ art_gtests_mainline_presubmit_module_names.remove("art_standalone_odrefresh_tests")
# Tests exhibiting a flaky behavior, currently exluded from MTS for
# the stake of stability / confidence (b/209958457).