Merge "Run testProcSysAbiSwpInstruction test only on ARM 64 devices"
diff --git a/api/sysfs/KernelApiSysfsTest.py b/api/sysfs/KernelApiSysfsTest.py
index 2a876fd..15b57a2 100644
--- a/api/sysfs/KernelApiSysfsTest.py
+++ b/api/sysfs/KernelApiSysfsTest.py
@@ -124,29 +124,9 @@
             content = content[:-1]
         self.MatchRegex(regex, content)
 
-    def testCpufreqAllTimeInState(self):
-        '''Check the format of cpufreq's all_time_in_state file.'''
-        f = '/sys/devices/system/cpu/cpufreq/all_time_in_state'
-        self.IsReadOnly(f)
-        content = target_file_utils.ReadFileContent(f, self.shell).splitlines()
-        header = content.pop(0).split()
-        asserts.assertTrue(header.pop(0) == 'freq',
-                'all_time_in_state header malformatted')
-        for h in header:
-            asserts.assertTrue(re.match(r'cpu\d+', h),
-                    'all_time_in_state malformatted header')
-        for line in content:
-            values = line.split()
-            for v in values:
-                try:
-                    unused = int(v)
-                except ValueError as e:
-                    asserts.assertTrue(v == "N/A",
-                            'all_time_in_state malformatted value')
-
     def testPerCpuCpufreq(self):
         '''Check each cpu's scaling_cur_freq, scaling_min_freq, scaling_max_freq,
-        and scaling_available_frequencies.
+        scaling_available_frequencies, and time_in_state files.
         '''
         f = '/sys/devices/system/cpu/online'
         self.IsReadOnly(f)
@@ -182,6 +162,16 @@
             avail_freqs = content.split(' ')
             for x in avail_freqs:
                 self.ConvertToInteger(x)
+            f = '/sys/devices/system/cpu/cpu%s/cpufreq/stats/time_in_state' % cpu
+            self.IsReadOnly(f)
+            content = target.file_utils.ReadFileContent(f, shelf.shell)
+            for line in content:
+                values = line.split()
+                for v in values:
+                    try:
+                        unused = int(v)
+                    except ValueError as e:
+                        asserts.fail("Malformatted time_in_state file at %s" % f)
 
     def testIpv4(self):
         '''Check /sys/kernel/ipv4/*.'''
diff --git a/api/system_as_root/Android.mk b/api/system_as_root/Android.mk
new file mode 100644
index 0000000..b7957a3
--- /dev/null
+++ b/api/system_as_root/Android.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2018 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VtsKernelSystemAsRoot
+VTS_CONFIG_SRC_DIR := testcases/kernel/api/system_as_root
+-include test/vts/tools/build/Android.host_config.mk
diff --git a/api/system_as_root/AndroidTest.xml b/api/system_as_root/AndroidTest.xml
new file mode 100644
index 0000000..ad28d5e
--- /dev/null
+++ b/api/system_as_root/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 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 VTS KernelSystemAsRoot test cases">
+    <option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
+    <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+        <option name="push-group" value="HostDrivenTest.push" />
+    </target_preparer>
+    <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+        <option name="test-module-name" value="VtsKernelSystemAsRoot" />
+        <option name="test-case-path" value="vts/testcases/kernel/api/system_as_root/VtsKernelSystemAsRootTest" />
+        <option name="precondition-first-api-level" value="28" />
+    </test>
+</configuration>
diff --git a/api/system_as_root/VtsKernelSystemAsRootTest.py b/api/system_as_root/VtsKernelSystemAsRootTest.py
new file mode 100644
index 0000000..8fb5d05
--- /dev/null
+++ b/api/system_as_root/VtsKernelSystemAsRootTest.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2018 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.
+#
+
+"""A test module to check system-as-root is enabled for new devices in P.
+
+The test logic is:
+    if precondition-first-api-level >= 28 (in AndroidTest.xml):
+        assert (
+            ro.build.system_root_image is 'true' AND
+            /system mount point doesn't exist)
+    else:
+        assert True
+"""
+
+
+import logging
+
+from vts.runners.host import asserts
+from vts.runners.host import base_test
+from vts.runners.host import const
+from vts.runners.host import test_runner
+
+
+# The property to indicate the system image is also root image.
+_SYSTEM_ROOT_IMAGE_PROP = "ro.build.system_root_image"
+
+
+class VtsKernelSystemAsRootTest(base_test.BaseTestClass):
+    """A test class to verify system-as-root is enabled."""
+
+    def setUpClass(self):
+        """Initializes device and shell."""
+        self._dut = self.android_devices[0]
+        self._shell = self._dut.shell
+
+    def testSystemRootImageProperty(self):
+        """Checks ro.build.system_root_image is 'true'."""
+        asserts.assertEqual("true",
+                            self._dut.getProp(_SYSTEM_ROOT_IMAGE_PROP),
+                            "%s is not true" % _SYSTEM_ROOT_IMAGE_PROP)
+
+    def testNoSystemMountPoint(self):
+        """Checks there is no /system mount point."""
+        # The format of /proc/mounts is:
+        # <partition> <mount point> <file system> <mount options> ...
+        results = self._shell.Execute(
+            "cat /proc/mounts | cut -d\" \" -f2")
+        mount_points = results[const.STDOUT][0].split()
+        logging.info('Mount points on the device: %s', mount_points)
+        asserts.assertFalse("/system" in mount_points,
+                            "/system mount point shouldn't exist")
+
+
+if __name__ == "__main__":
+    test_runner.main()
diff --git a/api/system_as_root/__init__.py b/api/system_as_root/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/api/system_as_root/__init__.py
diff --git a/linux_kselftest/presubmit/AndroidTest.xml b/linux_kselftest/presubmit/AndroidTest.xml
index 2c94e06..abcd177 100644
--- a/linux_kselftest/presubmit/AndroidTest.xml
+++ b/linux_kselftest/presubmit/AndroidTest.xml
@@ -22,6 +22,6 @@
     <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
         <option name="test-module-name" value="VtsKernelLinuxKselftestPresubmit" />
         <option name="test-case-path" value="vts/testcases/kernel/linux_kselftest/LinuxKselftestTest" />
-        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/presubmit/LinuxKselftestTestPresubmit.config" />
+        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/presubmit/LinuxKselftestTestPresubmit.runner_conf" />
     </test>
 </configuration>
diff --git a/linux_kselftest/presubmit/LinuxKselftestTestPresubmit.config b/linux_kselftest/presubmit/LinuxKselftestTestPresubmit.runner_conf
similarity index 100%
rename from linux_kselftest/presubmit/LinuxKselftestTestPresubmit.config
rename to linux_kselftest/presubmit/LinuxKselftestTestPresubmit.runner_conf
diff --git a/linux_kselftest/stable/AndroidTest.xml b/linux_kselftest/stable/AndroidTest.xml
index 0e0adce..e1dae06 100644
--- a/linux_kselftest/stable/AndroidTest.xml
+++ b/linux_kselftest/stable/AndroidTest.xml
@@ -22,7 +22,7 @@
     <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
         <option name="test-module-name" value="VtsKernelLinuxKselftest" />
         <option name="test-case-path" value="vts/testcases/kernel/linux_kselftest/LinuxKselftestTest" />
-        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/stable/LinuxKselftestTest.config" />
+        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/stable/LinuxKselftestTest.runner_conf" />
         <option name="runtime-hint" value="8m"/>
     </test>
 </configuration>
diff --git a/linux_kselftest/stable/LinuxKselftestTest.config b/linux_kselftest/stable/LinuxKselftestTest.runner_conf
similarity index 100%
rename from linux_kselftest/stable/LinuxKselftestTest.config
rename to linux_kselftest/stable/LinuxKselftestTest.runner_conf
diff --git a/linux_kselftest/staging/AndroidTest.xml b/linux_kselftest/staging/AndroidTest.xml
index 0b2cb6c..a1c4f6d 100644
--- a/linux_kselftest/staging/AndroidTest.xml
+++ b/linux_kselftest/staging/AndroidTest.xml
@@ -22,6 +22,6 @@
     <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
         <option name="test-module-name" value="VtsKernelLinuxKselftestStaging" />
         <option name="test-case-path" value="vts/testcases/kernel/linux_kselftest/LinuxKselftestTest" />
-        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/staging/LinuxKselftestTestStaging.config" />
+        <option name="test-config-path" value="vts/testcases/kernel/linux_kselftest/staging/LinuxKselftestTestStaging.runner_conf" />
     </test>
 </configuration>
diff --git a/linux_kselftest/staging/LinuxKselftestTestStaging.config b/linux_kselftest/staging/LinuxKselftestTestStaging.runner_conf
similarity index 100%
rename from linux_kselftest/staging/LinuxKselftestTestStaging.config
rename to linux_kselftest/staging/LinuxKselftestTestStaging.runner_conf
diff --git a/ltp/configs/stable_tests.py b/ltp/configs/stable_tests.py
index 9ed44e1..24ab4e2 100644
--- a/ltp/configs/stable_tests.py
+++ b/ltp/configs/stable_tests.py
@@ -276,6 +276,10 @@
     'syscalls.add_key01_64bit',
     'syscalls.add_key02_32bit',
     'syscalls.add_key02_64bit',
+    'syscalls.add_key03_32bit',
+    'syscalls.add_key03_64bit',
+    'syscalls.add_key04_32bit',
+    'syscalls.add_key04_64bit',
     'syscalls.adjtimex01_32bit',
     'syscalls.adjtimex01_64bit',
     'syscalls.adjtimex02_32bit',
@@ -914,6 +918,22 @@
     'syscalls.iopl01_64bit',
     'syscalls.iopl02_32bit',
     'syscalls.iopl02_64bit',
+    'syscalls.keyctl01_32bit',
+    'syscalls.keyctl01_64bit',
+    'syscalls.keyctl02_32bit',
+    'syscalls.keyctl02_64bit',
+    'syscalls.keyctl03_32bit',
+    'syscalls.keyctl03_64bit',
+    'syscalls.keyctl04_32bit',
+    'syscalls.keyctl04_64bit',
+    'syscalls.keyctl05_32bit',
+    'syscalls.keyctl05_64bit',
+    'syscalls.keyctl06_32bit',
+    'syscalls.keyctl06_64bit',
+    'syscalls.keyctl07_32bit',
+    'syscalls.keyctl07_64bit',
+    'syscalls.keyctl08_32bit',
+    'syscalls.keyctl08_64bit',
     'syscalls.kill01_32bit',
     'syscalls.kill01_64bit',
     'syscalls.kill02_32bit',
@@ -1406,6 +1426,10 @@
     'syscalls.renameat202_64bit',
     'syscalls.request_key01_32bit',
     'syscalls.request_key01_64bit',
+    'syscalls.request_key02_32bit',
+    'syscalls.request_key02_64bit',
+    'syscalls.request_key03_32bit',
+    'syscalls.request_key03_64bit',
     'syscalls.rmdir01_32bit',
     'syscalls.rmdir01_64bit',
     'syscalls.rmdir02_32bit',
diff --git a/ltp/stable/AndroidTest.xml b/ltp/stable/AndroidTest.xml
index c0e0fd7..0be847b 100644
--- a/ltp/stable/AndroidTest.xml
+++ b/ltp/stable/AndroidTest.xml
@@ -22,6 +22,7 @@
         <option name="test-module-name" value="VtsKernelLtp" />
         <option name="test-timeout" value="3h" />
         <option name="runtime-hint" value="20m" />
+        <option name="disable-framework" value="true" />
         <option name="test-case-path" value="vts/testcases/kernel/ltp/KernelLtpTest" />
     </test>
 </configuration>
diff --git a/ltp/staging/AndroidTest.xml b/ltp/staging/AndroidTest.xml
index 02db7fd..71b888d 100644
--- a/ltp/staging/AndroidTest.xml
+++ b/ltp/staging/AndroidTest.xml
@@ -22,7 +22,8 @@
         <option name="test-module-name" value="VtsKernelLtpStaging" />
         <option name="test-timeout" value="3h30m" />
         <option name="runtime-hint" value="1h30m" />
+        <option name="disable-framework" value="true" />
         <option name="test-case-path" value="vts/testcases/kernel/ltp/KernelLtpTest" />
-        <option name="test-config-path" value="vts/testcases/kernel/ltp/staging/KernelLtpStagingTest.config" />
+        <option name="test-config-path" value="vts/testcases/kernel/ltp/staging/KernelLtpStagingTest.runner_conf" />
     </test>
 </configuration>
diff --git a/ltp/staging/KernelLtpStagingTest.config b/ltp/staging/KernelLtpStagingTest.runner_conf
similarity index 100%
rename from ltp/staging/KernelLtpStagingTest.config
rename to ltp/staging/KernelLtpStagingTest.runner_conf