Add init_tests to CTS

Test: atest CtsInitTestCases
Test: Cts in presubmit still passes
Change-Id: Ic16dafbaacfbace904947bd3ce2b8586f981348f
This commit is contained in:
Tom Cherry 2019-08-20 10:43:48 -07:00
parent 61bffa5fc0
commit 17b2be05a2
6 changed files with 61 additions and 11 deletions

View File

@ -3,6 +3,9 @@
{
"name": "adbd_test"
},
{
"name": "CtsInitTestCases"
},
{
"name": "debuggerd_test"
},
@ -12,9 +15,6 @@
{
"name": "fs_mgr_vendor_overlay_test"
},
{
"name": "init_tests"
},
{
"name": "libbase_test"
},

View File

@ -206,9 +206,18 @@ cc_binary {
// ------------------------------------------------------------------------------
cc_test {
name: "init_tests",
name: "CtsInitTestCases",
defaults: ["init_defaults"],
compile_multilib: "first",
compile_multilib: "both",
multilib: {
lib32: {
suffix: "32",
},
lib64: {
suffix: "64",
},
},
srcs: [
"devices_test.cpp",
"init_test.cpp",
@ -225,7 +234,12 @@ cc_test {
"util_test.cpp",
],
static_libs: ["libinit"],
test_suites: ["device-tests"],
test_suites: [
"cts",
"device-tests",
"vts",
],
}
cc_benchmark {

31
init/AndroidTest.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2019 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<configuration description="Config for CTS init test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="systems" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
<option name="config-descriptor:metadata" key="parameter" value="multi_abi" />
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
<option name="cleanup" value="true" />
<option name="push" value="CtsInitTestCases->/data/local/tmp/CtsInitTestCases" />
<option name="append-bitness" value="true" />
</target_preparer>
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
<option name="module-name" value="CtsInitTestCases" />
<option name="runtime-hint" value="65s" />
</test>
</configuration>

View File

@ -56,6 +56,11 @@ TEST(property_service, very_long_name_35166374) {
}
TEST(property_service, non_utf8_value) {
if (getuid() != 0) {
GTEST_SKIP() << "Skipping test, must be run as root.";
return;
}
ASSERT_TRUE(SetProperty("property_service_utf8_test", "base_success"));
EXPECT_FALSE(SetProperty("property_service_utf8_test", "\x80"));
EXPECT_FALSE(SetProperty("property_service_utf8_test", "\xC2\x01"));

View File

@ -43,7 +43,7 @@ namespace init {
template <typename F>
void RunTest(F&& test_function) {
if (getuid() != 0) {
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
GTEST_SKIP() << "Skipping test, must be run as root.";
return;
}

View File

@ -68,7 +68,7 @@ void WriteFromMultipleThreads(std::vector<std::pair<std::string, T>>& files_and_
TEST(ueventd, setegid_IsPerThread) {
if (getuid() != 0) {
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
GTEST_SKIP() << "Skipping test, must be run as root.";
return;
}
@ -92,11 +92,11 @@ TEST(ueventd, setegid_IsPerThread) {
TEST(ueventd, setfscreatecon_IsPerThread) {
if (getuid() != 0) {
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
GTEST_SKIP() << "Skipping test, must be run as root.";
return;
}
if (!is_selinux_enabled() || security_getenforce() == 1) {
GTEST_LOG_(INFO) << "Skipping test, SELinux must be enabled and in permissive mode.";
GTEST_SKIP() << "Skipping test, SELinux must be enabled and in permissive mode.";
return;
}
@ -127,7 +127,7 @@ TEST(ueventd, setfscreatecon_IsPerThread) {
TEST(ueventd, selabel_lookup_MultiThreaded) {
if (getuid() != 0) {
GTEST_LOG_(INFO) << "Skipping test, must be run as root.";
GTEST_SKIP() << "Skipping test, must be run as root.";
return;
}