summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2018-10-12 02:12:41 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2018-10-12 02:12:41 +0000
commit30099cc635fbdf78be36d098e8bbd0fa17212278 (patch)
tree1cb2af8936af2c7cad7b6e2623955d2c03387d2a
parent83af5dd53e7d03d421a271038dc17cb107ba54ea (diff)
parent97548c361d9481f331bc950785e52b43b3871d7b (diff)
downloadplatform_test_vts-testcase_kernel-master-cuttlefish-testing-release.tar.gz
platform_test_vts-testcase_kernel-master-cuttlefish-testing-release.tar.bz2
platform_test_vts-testcase_kernel-master-cuttlefish-testing-release.zip
Snap for 5061196 from 97548c361d9481f331bc950785e52b43b3871d7b to master-cuttlefish-testing-releasemaster-cuttlefish-testing-release
Change-Id: Ibb5328b509ba32f2d0b1c41e9d149ab5d2795e4d
-rw-r--r--checkpoint/Android.mk22
-rw-r--r--checkpoint/AndroidTest.xml28
-rw-r--r--checkpoint/CheckpointTest.py122
-rw-r--r--checkpoint/__init__.py0
4 files changed, 172 insertions, 0 deletions
diff --git a/checkpoint/Android.mk b/checkpoint/Android.mk
new file mode 100644
index 00000000..e07d2e45
--- /dev/null
+++ b/checkpoint/Android.mk
@@ -0,0 +1,22 @@
+#
+# 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 := CheckpointTest
+-include test/vts/tools/build/Android.host_config.mk
diff --git a/checkpoint/AndroidTest.xml b/checkpoint/AndroidTest.xml
new file mode 100644
index 00000000..a2498b70
--- /dev/null
+++ b/checkpoint/AndroidTest.xml
@@ -0,0 +1,28 @@
+<?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 CheckpointTest 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" />
+ <option name="cleanup" value="true" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-module-name" value="VtsKernelCheckpointTest" />
+ <option name="test-timeout" value="6m" />
+ <option name="runtime-hint" value="5m" />
+ <option name="test-case-path" value="vts/testcases/kernel/checkpoint/CheckpointTest" />
+ </test>
+</configuration>
diff --git a/checkpoint/CheckpointTest.py b/checkpoint/CheckpointTest.py
new file mode 100644
index 00000000..e6d03445
--- /dev/null
+++ b/checkpoint/CheckpointTest.py
@@ -0,0 +1,122 @@
+#!/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.
+#
+
+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
+
+
+class VtsKernelCheckpointTest(base_test.BaseTestClass):
+
+ _CHECKPOINTTESTFILE = "/data/local/tmp/checkpointtest"
+ _ORIGINALVALUE = "original value"
+ _MODIFIEDVALUE = "modified value"
+
+ def getFstab(self):
+ self.dut.adb.root()
+
+ for prop in ["hardware", "hardware.platform"]:
+ extension = self.dut.adb.shell("getprop ro.boot." + prop, no_except = True)
+ extension = extension[const.STDOUT]
+ if not extension:
+ continue
+
+ for filename in ["/odm/etc/fstab.", "/vendor/etc/fstab.", "/fstab."]:
+ contents = self.dut.adb.shell("cat " + filename + extension, no_except = True)
+ if contents[const.EXIT_CODE] != 0:
+ continue
+
+ return contents[const.STDOUT]
+
+ return ""
+
+ def isCheckpoint(self):
+ fstab = self.getFstab().splitlines()
+ for line in fstab:
+ parts = line.split()
+ if len(parts) != 5: # fstab has five parts for each entry:
+ # [device-name] [mount-point] [type] [mount_flags] [fsmgr_flags]
+ continue
+
+ flags = parts[4] # the fsmgr_flags field is the fifth one, thus index 4
+ flags = flags.split(',')
+ if any(flag.startswith("checkpoint=") for flag in flags):
+ return True
+
+ return False
+
+ def setUpClass(self):
+ self.dut = self.android_devices[0]
+ self.shell = self.dut.shell
+ self.isCheckpoint_ = self.isCheckpoint()
+
+ def reboot(self):
+ self.dut.reboot()
+ self.dut.adb.root()
+
+ def testRollback(self):
+ if not self.isCheckpoint_:
+ return
+
+ # Create a file and initiate checkpoint
+ self.dut.adb.root()
+ self.dut.adb.shell("echo " + self._ORIGINALVALUE + " > " + self._CHECKPOINTTESTFILE)
+ result = self.dut.adb.shell("vdc checkpoint startCheckpoint 1", no_except = True)
+ asserts.assertEqual(result[const.EXIT_CODE], 1)
+ self.reboot()
+
+ # Modify the file but do not commit
+ self.dut.adb.shell("echo " + self._MODIFIEDVALUE + " > " + self._CHECKPOINTTESTFILE)
+ self.reboot()
+
+ # Check the file is unchanged
+ result = self.dut.adb.shell("cat " + self._CHECKPOINTTESTFILE)
+ asserts.assertEqual(result.strip(), self._ORIGINALVALUE)
+
+ # Clean up
+ result = self.dut.adb.shell("vdc checkpoint commitChanges", no_except = True)
+ asserts.assertEqual(result[const.EXIT_CODE], 1)
+ self.reboot()
+ self.dut.adb.shell("rm " + self._CHECKPOINTTESTFILE)
+
+ def testCommit(self):
+ if not self.isCheckpoint_:
+ return
+
+ # Create a file and initiate checkpoint
+ self.dut.adb.root()
+ self.dut.adb.shell("echo " + self._ORIGINALVALUE + " > " + self._CHECKPOINTTESTFILE)
+ result = self.dut.adb.shell("vdc checkpoint startCheckpoint 1", no_except = True)
+ asserts.assertEqual(result[const.EXIT_CODE], 1)
+ self.reboot()
+
+ # Modify the file and commit the checkpoint
+ self.dut.adb.shell("echo " + self._MODIFIEDVALUE + " > " + self._CHECKPOINTTESTFILE)
+ result = self.dut.adb.shell("vdc checkpoint commitChanges", no_except = True)
+ asserts.assertEqual(result[const.EXIT_CODE], 1)
+ self.reboot()
+
+ # Check file has changed
+ result = self.dut.adb.shell("cat " + self._CHECKPOINTTESTFILE)
+ asserts.assertEqual(result.strip(), self._MODIFIEDVALUE)
+
+ # Clean up
+ self.dut.adb.shell("rm " + self._CHECKPOINTTESTFILE)
+
+if __name__ == "__main__":
+ test_runner.main()
diff --git a/checkpoint/__init__.py b/checkpoint/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/checkpoint/__init__.py