Dependency cleanup: Move test.utils.ResetCommitTime to utils.sys_utils.
The ResetCommitTime uses only standard Python module and utils API and
can be in sys_utils. This helps to prevent pulling extra dependency.
BUG=chromium:403712
TEST=make test
Change-Id: Icc20fa14679959360ca45ae21fa55773d32bb277
Reviewed-on: https://chromium-review.googlesource.com/321031
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Wei-Han Chen <stimim@chromium.org>
diff --git a/py/goofy/goofy.py b/py/goofy/goofy.py
index 1967b90..49f1516 100755
--- a/py/goofy/goofy.py
+++ b/py/goofy/goofy.py
@@ -332,7 +332,7 @@
# Before starting state server, remount stateful partitions with
# no commit flag. The default commit time (commit=600) makes corruption
# too likely.
- utils.ResetCommitTime()
+ sys_utils.ResetCommitTime()
self.state_instance, self.state_server = (
state.create_server(bind_address='0.0.0.0'))
diff --git a/py/test/utils/__init__.py b/py/test/utils/__init__.py
index 4f468e7..3ba3cee 100644
--- a/py/test/utils/__init__.py
+++ b/py/test/utils/__init__.py
@@ -13,11 +13,6 @@
import traceback
import factory_common # pylint: disable=W0611
-from cros.factory.utils import process_utils
-from cros.factory.utils import sync_utils
-from cros.factory.utils import sys_utils
-from cros.factory.utils import type_utils
-from cros.factory.utils import sys_utils
def var_log_messages_before_reboot(lines=100,
@@ -73,29 +68,3 @@
"""
return '\n'.join(
traceback.format_exception_only(*sys.exc_info()[:2])).strip()
-
-
-def ResetCommitTime():
- """Remounts partitions with commit=0.
-
- The standard value on CrOS (commit=600) is likely to result in
- corruption during factory testing. Using commit=0 reverts to the
- default value (generally 5 s).
- """
- if sys_utils.InChroot():
- return
-
- devices = set()
- with open('/etc/mtab', 'r') as f:
- for line in f.readlines():
- cols = line.split(' ')
- device = cols[0]
- options = cols[3]
- if 'commit=' in options:
- devices.add(device)
-
- # Remount all devices in parallel, and wait. Ignore errors.
- for process in [
- process_utils.Spawn(['mount', p, '-o', 'commit=0,remount'], log=True)
- for p in sorted(devices)]:
- process.wait()
diff --git a/py/utils/sys_utils.py b/py/utils/sys_utils.py
index f9b2e06..4fc314c 100644
--- a/py/utils/sys_utils.py
+++ b/py/utils/sys_utils.py
@@ -249,6 +249,32 @@
return results
+def ResetCommitTime():
+ """Remounts partitions with commit=0.
+
+ The standard value on CrOS (commit=600) is likely to result in
+ corruption during factory testing. Using commit=0 reverts to the
+ default value (generally 5 s).
+ """
+ if InChroot():
+ return
+
+ devices = set()
+ with open('/etc/mtab', 'r') as f:
+ for line in f.readlines():
+ cols = line.split(' ')
+ device = cols[0]
+ options = cols[3]
+ if 'commit=' in options:
+ devices.add(device)
+
+ # Remount all devices in parallel, and wait. Ignore errors.
+ for process in [
+ Spawn(['mount', p, '-o', 'commit=0,remount'], log=True)
+ for p in sorted(devices)]:
+ process.wait()
+
+
def HasEC():
"""Return whether the platform has EC chip."""
try: