summaryrefslogtreecommitdiff
path: root/runtime/hidden_api_test.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2019-03-15 11:35:51 +0000
committer David Brazdil <dbrazdil@google.com> 2019-03-16 07:34:43 +0000
commitbfaba288427e80e7941e49c4264ba8f6cd6d97d1 (patch)
treedb8e893b87c2406275c82599d43e9b9a5b0f895c /runtime/hidden_api_test.cc
parent7dd0f0f2b4af0b15389ca8624bde93e1fb7ed776 (diff)
Fix buildbots hidden_api_test
Target buildbots set /system to be the runtime module root because they are running without an apex. The test assumes that /system dex files are assigned to the application domain but here they get assigned to the core-platform domain. Adjust the domain setting logic to check if the runtime module root is distict from the android root (as a proxy for 'is running with apex'). If not (as is the case with the buildbots), skip checks against apex locations. Test: m test-art-target-gtest-hidden_api_test Change-Id: Iff3890ec69cb04a1e4ed5bc2a3b5c652ada05f36
Diffstat (limited to 'runtime/hidden_api_test.cc')
-rw-r--r--runtime/hidden_api_test.cc42
1 files changed, 33 insertions, 9 deletions
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index be6407963b..70fafe6587 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -17,6 +17,7 @@
#include "hidden_api.h"
#include <fstream>
+#include <sstream>
#include "base/file_utils.h"
#include "base/sdk_version.h"
@@ -431,20 +432,25 @@ static bool LoadDexFiles(const std::string& path,
static bool CheckAllDexFilesInDomain(ObjPtr<mirror::ClassLoader> loader,
const std::vector<std::unique_ptr<const DexFile>>& dex_files,
- hiddenapi::Domain expected_domain)
+ hiddenapi::Domain expected_domain,
+ /* out */ std::string* error_msg)
REQUIRES_SHARED(Locks::mutator_lock_) {
for (const auto& dex_file : dex_files) {
hiddenapi::AccessContext context(loader, dex_file.get());
if (context.GetDomain() != expected_domain) {
- LOG(ERROR) << dex_file->GetLocation() << ": access context domain does not match "
+ std::stringstream ss;
+ ss << dex_file->GetLocation() << ": access context domain does not match "
<< "(expected=" << static_cast<uint32_t>(expected_domain)
<< ", actual=" << static_cast<uint32_t>(context.GetDomain()) << ")";
+ *error_msg = ss.str();
return false;
}
if (dex_file->GetHiddenapiDomain() != expected_domain) {
- LOG(ERROR) << dex_file->GetLocation() << ": dex file domain does not match "
+ std::stringstream ss;
+ ss << dex_file->GetLocation() << ": dex file domain does not match "
<< "(expected=" << static_cast<uint32_t>(expected_domain)
<< ", actual=" << static_cast<uint32_t>(dex_file->GetHiddenapiDomain()) << ")";
+ *error_msg = ss.str();
return false;
}
}
@@ -466,7 +472,10 @@ TEST_F(HiddenApiTest, DexDomain_DataDir) {
ASSERT_TRUE(LoadDexFiles(data_location_path, soa, &dex_files, &class_loader, &error_msg))
<< error_msg;
ASSERT_GE(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kApplication));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(data_location_path.c_str()));
@@ -486,7 +495,10 @@ TEST_F(HiddenApiTest, DexDomain_SystemDir) {
ASSERT_TRUE(LoadDexFiles(system_location_path, soa, &dex_files, &class_loader, &error_msg))
<< error_msg;
ASSERT_GE(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kApplication));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(system_location_path.c_str()));
@@ -510,7 +522,10 @@ TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir) {
&class_loader,
&error_msg)) << error_msg;
ASSERT_GE(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kPlatform));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kPlatform,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(system_framework_location_path.c_str()));
@@ -531,7 +546,10 @@ TEST_F(HiddenApiTest, DexDomain_DataDir_MultiDex) {
ASSERT_TRUE(LoadDexFiles(data_multi_location_path, soa, &dex_files, &class_loader, &error_msg))
<< error_msg;
ASSERT_GE(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kApplication));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(data_multi_location_path.c_str()));
@@ -553,7 +571,10 @@ TEST_F(HiddenApiTest, DexDomain_SystemDir_MultiDex) {
ASSERT_TRUE(LoadDexFiles(system_multi_location_path, soa, &dex_files, &class_loader, &error_msg))
<< error_msg;
ASSERT_GT(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kApplication));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kApplication,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(system_multi_location_path.c_str()));
@@ -579,7 +600,10 @@ TEST_F(HiddenApiTest, DexDomain_SystemFrameworkDir_MultiDex) {
&class_loader,
&error_msg)) << error_msg;
ASSERT_GT(dex_files.size(), 1u);
- ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader, dex_files, hiddenapi::Domain::kPlatform));
+ ASSERT_TRUE(CheckAllDexFilesInDomain(class_loader,
+ dex_files,
+ hiddenapi::Domain::kPlatform,
+ &error_msg)) << error_msg;
dex_files.clear();
ASSERT_EQ(0, remove(system_framework_multi_location_path.c_str()));