testlog: refactor event_log and testlog
This refactoring involves several parts:
- Split the log_writer.py (which a large portion is borrowed from
event_log.py) into testlog_goofy.py, testlog.py, testlog_helper.py.
In addition, make functions serve for similar purposes in event_log.py
to call testlog_goofy.py directly as a preparation work toward
deprecating the event_log.py. Unittest of event_log.py is partially
removed because the manipulation of its internal variable is moved to
testlog_goofy.py. Coverage is then covered by testlog_goofy_unittest.py.
- Introduce the session JSON file for tests run in a separate process
and merge back when the harness aware its finish. This removes the
previous EventServer and EventClient that depends heavily on the factory
framework. Besides the goofy code, unittest TestlogE2ETest demonstrates
how the harness and the test should interact with each other.
- file_utils.py changed because the file descriptor will not be freed
until the end of process, which might deplete the available descriptors
of a single process.
- Move TimeUuid() from event_log.py to time_utils. All function calls
are changed as well as a preparation of removing event_log.py
- We removed the HeratBeat thread per offline discussion, the heatbeat
will be trigger on purpose from test program.
BUG=chromium:609069
TEST=make lint LINT_WHITELIST="py/test/factory.py \
py/test/testlog.py py/test/testlog_unittest.py\
py/test/testlog_goofy.py py/test/testlog_goofy_unittest.py \
py/test/testlog_seq.py py/test/testlog_seq_unittest.py \
py/test/event_log.py py/test/event_log_unittest.py \
py/utils/file_utils.py py/utils/file_utils_unittest.py \
py/goofy/goofy.py py/goofy/invocation.py py/test/event.py"
TEST=Run locally on DUT
Change-Id: I750aefa6da99e9e3d196e1fdb2db7ad7f76fa69c
Reviewed-on: https://chromium-review.googlesource.com/352410
Commit-Ready: Chun-ta Lin <itspeter@chromium.org>
Tested-by: Chun-ta Lin <itspeter@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
diff --git a/py/gooftool/commands.py b/py/gooftool/commands.py
index cfa5fee..a439fc8 100755
--- a/py/gooftool/commands.py
+++ b/py/gooftool/commands.py
@@ -51,6 +51,7 @@
from cros.factory.utils.argparse_utils import verbosity_cmd_arg
from cros.factory.utils import file_utils
from cros.factory.utils import sys_utils
+from cros.factory.utils import time_utils
from cros.factory.utils.debug_utils import SetupLogging
from cros.factory.utils.process_utils import Spawn
from cros.factory.utils.type_utils import Error
@@ -925,7 +926,7 @@
device_sn = ro_vpd.get('serial_number', None)
if device_sn is None:
logging.warning('RO_VPD missing device serial number')
- device_sn = 'MISSING_SN_' + event_log.TimedUuid()
+ device_sn = 'MISSING_SN_' + time_utils.TimedUUID()
target_path = CreateReportArchive(device_sn)
if options.upload_method is None or options.upload_method == 'none':