summaryrefslogtreecommitdiff
path: root/tools/hiddenapi/hiddenapi_test.cc
diff options
context:
space:
mode:
author Mariia Feofanova <mfeofanova@google.com> 2019-09-04 17:49:42 +0100
committer satayev <satayev@google.com> 2019-09-11 14:39:43 +0000
commit4945b29e6ea494fffc924f5940601af58d2b28ab (patch)
treef762c8cee1cbfb7cf588378c09b674f3a9dbac17 /tools/hiddenapi/hiddenapi_test.cc
parent2afa19db9e344a119f6807f7c54102204795bc54 (diff)
hiddenapi: add 'test-api' flag into dex files.
Only tests should have access to @TestApi signatures. But now all of them are greylisted, hence can be accessed by anyone. This should be changed so that grey/black/whitelist properties would be orthogonal to test-api. The first step to fix this is to introduce extra flag and embed it into dex files. In the future access decisions will be made based on that flag. Bug: 133832325 Test: make -j32 test-art-host-gtest-hiddenapi_test Change-Id: I0db8938391d6aefe5e9a3bc51ec99b948ae41f6d
Diffstat (limited to 'tools/hiddenapi/hiddenapi_test.cc')
-rw-r--r--tools/hiddenapi/hiddenapi_test.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/tools/hiddenapi/hiddenapi_test.cc b/tools/hiddenapi/hiddenapi_test.cc
index 7c9a95cbfd..337fae4850 100644
--- a/tools/hiddenapi/hiddenapi_test.cc
+++ b/tools/hiddenapi/hiddenapi_test.cc
@@ -690,6 +690,40 @@ TEST_F(HiddenApiTest, StaticNativeMethodTwoListsMatch3) {
ASSERT_EQ(dex_file.get(), nullptr);
}
+TEST_F(HiddenApiTest, InstanceFieldCorePlatformApiMatch) {
+ ScratchFile dex, flags_csv;
+ OpenStream(flags_csv)
+ << "LMain;->ifield:LBadType1;,greylist" << std::endl
+ << "LMain;->ifield:LBadType2;,greylist-max-o" << std::endl
+ << "LMain;->ifield:I,greylist,core-platform-api" << std::endl;
+ auto dex_file = RunHiddenapiEncode(flags_csv, {}, dex);
+ ASSERT_NE(dex_file.get(), nullptr);
+ ASSERT_EQ(hiddenapi::ApiList::CorePlatformApi() |
+ hiddenapi::ApiList::Greylist(), GetIFieldHiddenFlags(*dex_file));
+}
+
+TEST_F(HiddenApiTest, InstanceFieldTestApiMatch) {
+ ScratchFile dex, flags_csv;
+ OpenStream(flags_csv)
+ << "LMain;->ifield:LBadType1;,greylist" << std::endl
+ << "LMain;->ifield:LBadType2;,greylist-max-o" << std::endl
+ << "LMain;->ifield:I,greylist,test-api" << std::endl;
+ auto dex_file = RunHiddenapiEncode(flags_csv, {}, dex);
+ ASSERT_NE(dex_file.get(), nullptr);
+ ASSERT_EQ(hiddenapi::ApiList::TestApi()
+ | hiddenapi::ApiList::Greylist(), GetIFieldHiddenFlags(*dex_file));
+}
+
+TEST_F(HiddenApiTest, InstanceFieldUnknownFlagMatch) {
+ ScratchFile dex, flags_csv;
+ OpenStream(flags_csv)
+ << "LMain;->ifield:LBadType1;,greylist" << std::endl
+ << "LMain;->ifield:LBadType2;,greylist-max-o" << std::endl
+ << "LMain;->ifield:I,greylist,unknown-flag" << std::endl;
+ auto dex_file = RunHiddenapiEncode(flags_csv, {}, dex);
+ ASSERT_EQ(dex_file.get(), nullptr);
+}
+
// The following tests use this class hierarchy:
//
// AbstractPackageClass PublicInterface