Merge changes I3501f92a,I7cfcae2a,Ic942ef66,I2af0e957
am: e1a4f3bcc3
Change-Id: I336b90ed47d7450f5e60cf2e6625efd2e1328152
diff --git a/api/proc/KernelProcFileApiTest.py b/api/proc/KernelProcFileApiTest.py
index fe7b75e..dd1c040 100644
--- a/api/proc/KernelProcFileApiTest.py
+++ b/api/proc/KernelProcFileApiTest.py
@@ -144,7 +144,7 @@
logging.info("Testing format of %s", filepath)
asserts.assertTrue(
- test_object.prepare_test(self.shell), "Setup failed!")
+ test_object.prepare_test(self.shell, self.dut), "Setup failed!")
if not test_object.test_format():
return
diff --git a/api/proc/KernelProcFileTestBase.py b/api/proc/KernelProcFileTestBase.py
index a6e1890..cc909f2 100644
--- a/api/proc/KernelProcFileTestBase.py
+++ b/api/proc/KernelProcFileTestBase.py
@@ -175,7 +175,7 @@
"""Returns the full path of this proc file (string)."""
pass
- def prepare_test(self, shell):
+ def prepare_test(self, shell, dut):
"""Performs any actions necessary before testing the proc file.
Args:
diff --git a/api/proc/ProcFsFileTests.py b/api/proc/ProcFsFileTests.py
index 7f5956d..074151f 100644
--- a/api/proc/ProcFsFileTests.py
+++ b/api/proc/ProcFsFileTests.py
@@ -59,7 +59,7 @@
return False
return True
- def prepare_test(self, shell):
+ def prepare_test(self, shell, dut):
# Follow the symlink
results = shell.Execute('readlink /proc/mounts')
if results[const.EXIT_CODE][0] != 0:
diff --git a/api/proc/ProcModulesTest.py b/api/proc/ProcModulesTest.py
index 8fb1afd..4a8a585 100644
--- a/api/proc/ProcModulesTest.py
+++ b/api/proc/ProcModulesTest.py
@@ -15,12 +15,22 @@
#
import re
+from vts.utils.python.android import api
from vts.testcases.kernel.api.proc import KernelProcFileTestBase
class ProcModulesTest(KernelProcFileTestBase.KernelProcFileTestBase):
'''/proc/modules contains information about loaded kernel modules.'''
+ def prepare_test(self, shell, dut):
+ try:
+ first_api_level = int(dut.first_api_level)
+ except ValueError as e:
+ first_api_level = 0
+ self.require_module = (first_api_level > api.PLATFORM_API_LEVEL_O_MR1 or
+ first_api_level == 0)
+ return True
+
def parse_contents(self, contents):
module_present = False
# MODULE_NAME SIZE REFERENCE_COUNT USER1,USER2, STATE BASE_ADDRESS TAINT_FLAG
@@ -40,7 +50,7 @@
raise SyntaxError("Malformed entry in /proc/modules: %s" % line)
else:
module_present = True
- if not module_present:
+ if self.require_module and not module_present:
raise SyntaxError("There must be at least one entry in /proc/modules")
return ''
diff --git a/config/VtsKernelConfigTest.py b/config/VtsKernelConfigTest.py
index 52f392a..22dd726 100644
--- a/config/VtsKernelConfigTest.py
+++ b/config/VtsKernelConfigTest.py
@@ -30,6 +30,8 @@
from vts.utils.python.controllers import android_device
from vts.utils.python.file import target_file_utils
+from vts.testcases.kernel.lib import version
+
class VtsKernelConfigTest(base_test.BaseTestClass):
"""Test case which check config options in /proc/config.gz.
@@ -40,7 +42,6 @@
PROC_FILE_PATH = "/proc/config.gz"
KERNEL_CONFIG_FILE_PATH = "vts/testcases/kernel/config/data"
- SUPPORTED_KERNEL_VERSIONS = ["4.4", "4.9", "4.14"]
def setUpClass(self):
required_params = [keys.ConfigKeys.IKEY_DATA_FILE_PATH]
@@ -50,6 +51,7 @@
"KernelConfigTest") # creates a remote shell instance.
self.shell = self.dut.shell.KernelConfigTest
self._temp_dir = tempfile.mkdtemp()
+ self.supported_kernel_versions = version.getSupportedKernels(self.dut)
def checkKernelVersion(self):
"""Validate the kernel version of DUT is a valid kernel version.
@@ -61,18 +63,19 @@
results = self.shell.Execute(cmd)
logging.info("Shell command '%s' results: %s", cmd, results)
- match = re.search(r"\d+\.\d+", results[const.STDOUT][0])
+ match = re.search(r"(\d+)\.(\d+)", results[const.STDOUT][0])
if match is None:
asserts.fail("Failed to detect kernel version of device.")
else:
- kernel_version = match.group(0)
- logging.info("Detected kernel version: %s", kernel_version)
+ kernel_version = int(match.group(1))
+ kernel_patchlevel = int(match.group(2))
+ logging.info("Detected kernel version: %s", match.group(0))
- asserts.assertTrue(kernel_version in self.SUPPORTED_KERNEL_VERSIONS,
- "Detected kernel version '%s' is not one of %s" %
- (kernel_version, self.SUPPORTED_KERNEL_VERSIONS))
-
- return kernel_version
+ for v in self.supported_kernel_versions:
+ if (kernel_version == v[0] and kernel_patchlevel == v[1]):
+ return match.group(0)
+ asserts.fail("Detected kernel version is not one of %s" %
+ self.supported_kernel_versions)
def checkKernelArch(self, configs):
"""Find arch of the device kernel.
diff --git a/lib/__init__.py b/lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/__init__.py
diff --git a/lib/version.py b/lib/version.py
new file mode 100644
index 0000000..dd87cb5
--- /dev/null
+++ b/lib/version.py
@@ -0,0 +1,37 @@
+#
+# 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.
+
+from vts.utils.python.android import api
+
+def getSupportedKernels(dut):
+ """Returns a list of the supported kernel versions for this
+ devices' advertised API level.
+
+ Args:
+ dut: The AndroidDevice object corresponding to the device
+ under test.
+
+ Returns:
+ A list of supported kernel versions.
+ """
+ try:
+ first_api_level = int(dut.first_api_level)
+ except ValueError as e:
+ first_api_level = 0
+ if (first_api_level > api.PLATFORM_API_LEVEL_O_MR1 or
+ first_api_level == 0):
+ return [[4, 4, 0], [4, 9, 0], [4, 14, 0]]
+ else:
+ return [[3, 18, 0], [4, 4, 0], [4, 9, 0]]
diff --git a/version/VtsKernelVersionTest.py b/version/VtsKernelVersionTest.py
index d240ce7..0e999f0 100644
--- a/version/VtsKernelVersionTest.py
+++ b/version/VtsKernelVersionTest.py
@@ -23,10 +23,11 @@
from vts.runners.host import const
from vts.runners.host import keys
from vts.runners.host import test_runner
-from vts.utils.python.android import api
from vts.utils.python.controllers import android_device
from vts.utils.python.file import target_file_utils
+from vts.testcases.kernel.lib import version
+
class VtsKernelVersionTest(base_test.BaseTestClass):
"""Test case which verifies the version of the kernel on the DUT is
@@ -40,15 +41,7 @@
self.dut.shell.InvokeTerminal(
"KernelVersionTest") # creates a remote shell instance.
self.shell = self.dut.shell.KernelVersionTest
- try:
- first_api_level = int(self.dut.first_api_level)
- except ValueError as e:
- first_api_level = 0
- if (first_api_level > api.PLATFORM_API_LEVEL_O_MR1 or
- first_api_level == 0):
- self.supported_kernel_versions = [[4, 4, 0], [4, 9, 0], [4, 14, 0]]
- else:
- self.supported_kernel_versions = [[3, 18, 0], [4, 4, 0], [4, 9, 0]]
+ self.supported_kernel_versions = version.getSupportedKernels(self.dut)
def testKernelVersion(self):
"""Validate the kernel version of DUT is a valid kernel version.