summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiakai Zhang <jiakaiz@google.com> 2024-08-21 13:35:17 +0100
committer Jiakai Zhang <jiakaiz@google.com> 2024-08-29 12:13:12 +0000
commit4fad1f2882128a3683153405fb0a24ad9d912e6d (patch)
treee32482bee6474215e1d92183dba898f966301f22
parentdd06f773e8c9f2a54191d38f8fbc7b6925335380 (diff)
Use a fake libartpalette in chroot tests and disable libartpalette_test.
Bug: 357802879 Test: - 1. art/tools/buildbot-build.sh --host --installclean 2. m test-art-host-gtest 3. art/test/testrunner/testrunner.py --verbose --host --ndebug --optimizing Test: - 1. art/tools/buildbot-build.sh --target --installclean 2. art/tools/run-gtests.sh -j4 Change-Id: If646b68130ba6c3e52e1388a0e465d6683e9de4b
-rw-r--r--build/Android.gtest.mk2
-rw-r--r--build/apex/Android.bp1
-rwxr-xr-xbuild/apex/art_apex_test.py1
-rw-r--r--libartpalette/Android.bp26
-rw-r--r--libartpalette/apex/palette_test.cc17
-rwxr-xr-xtools/buildbot-build.sh19
6 files changed, 40 insertions, 26 deletions
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 58cf89a4a3..ae40d01db4 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -113,7 +113,6 @@ ART_TEST_MODULES_COMMON := \
art_hiddenapi_tests \
art_imgdiag_tests \
art_libartbase_tests \
- art_libartpalette_tests \
art_libdexfile_external_tests \
art_libdexfile_support_static_tests \
art_libdexfile_support_tests \
@@ -134,6 +133,7 @@ ART_TEST_MODULES_TARGET := $(ART_TEST_MODULES_COMMON) \
art_odrefresh_tests \
ART_TEST_MODULES_HOST := $(ART_TEST_MODULES_COMMON) \
+ art_libartpalette_tests \
art_libartservice_tests \
art_libarttools_tests \
diff --git a/build/apex/Android.bp b/build/apex/Android.bp
index 690ee4f7f5..312d40477d 100644
--- a/build/apex/Android.bp
+++ b/build/apex/Android.bp
@@ -348,7 +348,6 @@ art_gtests = [
"art_dexoptanalyzer_tests",
"art_imgdiag_tests",
"art_libartbase_tests",
- "art_libartpalette_tests",
"art_libdexfile_tests",
"art_libdexfile_support_tests",
"art_libprofile_tests",
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 86059255a2..1b82302d7a 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -720,7 +720,6 @@ class TestingTargetChecker:
self._checker.check_art_test_executable('art_disassembler_tests')
self._checker.check_art_test_executable('art_imgdiag_tests')
self._checker.check_art_test_executable('art_libartbase_tests')
- self._checker.check_art_test_executable('art_libartpalette_tests')
self._checker.check_art_test_executable('art_libdexfile_support_tests')
self._checker.check_art_test_executable('art_libdexfile_tests')
self._checker.check_art_test_executable('art_libprofile_tests')
diff --git a/libartpalette/Android.bp b/libartpalette/Android.bp
index f43697a972..89607219cc 100644
--- a/libartpalette/Android.bp
+++ b/libartpalette/Android.bp
@@ -27,8 +27,10 @@ package {
cc_defaults {
name: "libartpalette_defaults",
defaults: ["art_defaults"],
- host_supported: true,
export_include_dirs: ["include"],
+ header_libs: [
+ "jni_headers",
+ ],
}
cc_library_headers {
@@ -47,6 +49,7 @@ cc_library_headers {
art_cc_library {
name: "libartpalette",
defaults: ["libartpalette_defaults"],
+ host_supported: true,
visibility: [
// TODO(b/183483755): Please visibility checks when the prebuilt
// libartpalette is present but not preferred, and the prebuilt
@@ -57,7 +60,6 @@ art_cc_library {
],
header_libs: [
"libbase_headers",
- "jni_headers",
],
export_header_lib_headers: [
"jni_headers",
@@ -112,6 +114,23 @@ art_cc_library {
],
}
+art_cc_library {
+ name: "libartpalette_fake",
+ defaults: ["libartpalette_defaults"],
+ srcs: ["system/palette_fake.cc"],
+ stem: "libartpalette-system",
+ relative_install_path: "art_fake", // Avoid conflict with the real lib.
+ shared_libs: [
+ "libbase",
+ "liblog",
+ ],
+ compile_multilib: "both",
+ visibility: [
+ "//visibility:override",
+ "//visibility:private",
+ ],
+}
+
art_cc_defaults {
name: "art_libartpalette_tests_defaults",
srcs: ["apex/palette_test.cc"],
@@ -122,7 +141,7 @@ art_cc_defaults {
},
}
-// Version of ART gtest `art_libartpalette_tests` bundled with the ART APEX on target.
+// Version of ART gtest `art_libartpalette_tests` for host.
// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
art_cc_test {
name: "art_libartpalette_tests",
@@ -131,6 +150,7 @@ art_cc_test {
"art_libartpalette_tests_defaults",
],
host_supported: true,
+ device_supported: false,
}
// Standalone version of ART gtest `art_libartpalette_tests`, not bundled with the ART APEX on
diff --git a/libartpalette/apex/palette_test.cc b/libartpalette/apex/palette_test.cc
index cbdfafa733..47eec51df9 100644
--- a/libartpalette/apex/palette_test.cc
+++ b/libartpalette/apex/palette_test.cc
@@ -22,16 +22,15 @@
#include <unistd.h>
#include <cstring>
-#include <filesystem>
+
+#include "base/common_art_test.h"
+#include "gtest/gtest.h"
#ifdef ART_TARGET_ANDROID
#include "android-modules-utils/sdk_level.h"
#include "android/api-level.h"
#endif
-#include "base/common_art_test.h"
-#include "gtest/gtest.h"
-
namespace {
pid_t GetTid() {
@@ -130,11 +129,6 @@ TEST_F(PaletteClientTest, SetTaskProfiles) {
#ifndef ART_TARGET_ANDROID
GTEST_SKIP() << "SetTaskProfiles is only supported on Android";
#else
- if (!std::filesystem::exists("/sys/fs/cgroup/cgroup.controllers")) {
- // This is intended to detect ART chroot setups, where SetTaskProfiles won't work.
- GTEST_SKIP() << "Kernel cgroup support missing";
- }
-
const char* profiles[] = {"ProcessCapacityHigh", "TimerSlackNormal"};
palette_status_t res = PaletteSetTaskProfiles(GetTid(), &profiles[0], 2);
if (PaletteSetTaskProfilesIsSupported(res)) {
@@ -153,11 +147,6 @@ TEST_F(PaletteClientTest, SetTaskProfilesCpp) {
#ifndef ART_TARGET_ANDROID
GTEST_SKIP() << "SetTaskProfiles is only supported on Android";
#else
- if (!std::filesystem::exists("/sys/fs/cgroup/cgroup.controllers")) {
- // This is intended to detect ART chroot setups, where SetTaskProfiles won't work.
- GTEST_SKIP() << "Kernel cgroup support missing";
- }
-
std::vector<std::string> profiles = {"ProcessCapacityHigh", "TimerSlackNormal"};
palette_status_t res = PaletteSetTaskProfiles(GetTid(), profiles);
if (PaletteSetTaskProfilesIsSupported(res)) {
diff --git a/tools/buildbot-build.sh b/tools/buildbot-build.sh
index 22034df1f4..3a14e6b3d9 100755
--- a/tools/buildbot-build.sh
+++ b/tools/buildbot-build.sh
@@ -61,7 +61,7 @@ if [[ $TARGET_ARCH = "riscv64" && ! ( -d frameworks/base ) ]]; then
fi
java_libraries_dir=${out_dir}/target/common/obj/JAVA_LIBRARIES
-common_targets="vogar core-tests core-ojtests apache-harmony-jdwp-tests-hostdex jsr166-tests libartpalette-system mockito-target desugar"
+common_targets="vogar core-tests core-ojtests apache-harmony-jdwp-tests-hostdex jsr166-tests mockito-target desugar"
# These build targets have different names on device and host.
specific_targets="libjavacoretests libwrapagentproperties libwrapagentpropertiesd"
build_host="no"
@@ -110,11 +110,6 @@ fi
implementation_libs=(
"heapprofd_client_api"
- "libartpalette-system"
- "libdebugstore_cxx" # Needed by "libartpalette-system".
- "libcutils"
- "libutils"
- "libvndksupport"
)
if [ -d frameworks/base ]; then
@@ -164,6 +159,7 @@ if [[ $build_target == "yes" ]]; then
make_command+=" build-art-target-gtests"
test $skip_run_tests_build == "yes" || make_command+=" build-art-target-run-tests"
make_command+=" debuggerd sh su toybox"
+ make_command+=" libartpalette_fake"
# Indirect dependencies in the platform, e.g. through heapprofd_client_api.
# These are built to go into system/lib(64) to be part of the system linker
# namespace.
@@ -210,6 +206,17 @@ if [[ $build_target == "yes" ]]; then
ANDROID_HOST_OUT=$out_dir/host/linux-x86
fi
+ # Use a fake libartpalette implementation to prevent chroot tests from talking to the platform
+ # through libartpalette.
+ for l in lib lib64; do
+ if [ ! -d "$ANDROID_PRODUCT_OUT/system/$l" ]; then
+ continue
+ fi
+ cmd="cp -p \"$ANDROID_PRODUCT_OUT/system/$l/art_fake/libartpalette-system.so\" \"$ANDROID_PRODUCT_OUT/system/$l/libartpalette-system.so\""
+ msginfo "Executing" "$cmd"
+ eval "$cmd"
+ done
+
# Extract prebuilt APEXes.
debugfs=$ANDROID_HOST_OUT/bin/debugfs_static
fsckerofs=$ANDROID_HOST_OUT/bin/fsck.erofs