dev: add initial APIs to devserver to support cros auto-update.
This CL adds three APIs on devserver:
1. 'cros_au' API: to support 'start cros auto-update'.
2. 'get_au_status' API: to check the status of cros auto-update.
3. 'collect_au_log' API: to collect auto-update log from devserver.
4. 'handler_cleanup' API: delete the status file for tracking the progress of
CrOS auto-update.
5. 'kill_au_proc' API: to kill unexpected auto-update process for DUT.
Also it updates the unittests and integration test.
The 'cros_au' API triggers a background process to support the whole
auto-update processes for a CrOS host, includes:
1. Transfer devserver/stateful update package.
2. If devserver cannot run on the host, restore the stateful partition.
3. If restore_stateful_partiton is not required, and stateful_update is
required, do stateful_update.
4. If stateful_update fails, or rootfs_update is required, do rootfs update.
5. Final check after the whole auto-update process.
BUG=chromium:613765
TEST=Locally ran 'ds.auto_update([dut], [image_path])';
Ran 'repair' for dut from local autotest instance;
Ran unittest, devserver_integration_test.
Changes to be committed:
modified: Makefile
new file: cros_update.py
new file: cros_update_logging.py
new file: cros_update_progress.py
new file: cros_update_unittest.py
modified: devserver.py
modified: devserver_integration_test.py
Change-Id: I2e9c116bc1e0b07d37b540266fd252aee4fd6e84
Reviewed-on: https://chromium-review.googlesource.com/346199
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/cros_update_unittest.py b/cros_update_unittest.py
new file mode 100755
index 0000000..9aae815
--- /dev/null
+++ b/cros_update_unittest.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python2
+
+# Copyright (c) 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Unit tests for cros_update_parser.py."""
+
+from __future__ import print_function
+
+import sys
+import unittest
+
+import cros_update
+
+class CrosUpdateParserTest(unittest.TestCase):
+ """Tests for the autoupdate.Autoupdate class."""
+
+ def setUp(self):
+ self.orig_sys_argv = sys.argv
+
+ def tearDown(self):
+ self.argv = self.orig_sys_argv
+
+ def _get_parser(self):
+ return cros_update.CrOSAUParser()
+
+ def test_parse_args(self):
+ host_name = '100.0.0.1'
+ build_name = 'fake/image'
+ sys.argv = ['run.py', '-d', host_name, '-b', build_name, '-q', 'test']
+ parser = self._get_parser()
+ parser.ParseArgs()
+ self.assertEqual(host_name, parser.options.host_name)
+ self.assertEqual(build_name, parser.options.build_name)
+ self.assertEqual(['-q', 'test'], parser.removed_args)
+
+
+if __name__ == '__main__':
+ unittest.main()