From dccb75246a77de9aad0bb5a47f890b76c09b5f96 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Mon, 12 Jun 2023 14:18:18 +0200 Subject: [PATCH] os.Environment, os.MachineCmd: Add --tag, --time-stamp Add support for options --tag and --time-stamp to MachineCmd, and store them in Environment.tag and .time_stamp, respectively. .time_stamp defaults to current time if --time-stamp is not present. Signed-off-by: Jan Lindemann --- src/python/devtest/os/Environment.py | 7 ++++++- src/python/devtest/os/MachineCmd.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/python/devtest/os/Environment.py b/src/python/devtest/os/Environment.py index efa3026..7450ea2 100644 --- a/src/python/devtest/os/Environment.py +++ b/src/python/devtest/os/Environment.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from datetime import datetime +#import dateutil.parser from .Connections import Connections from jwutils import Options from jwutils.log import * @@ -14,7 +15,11 @@ class Environment: for ft in self.features: slog(INFO, " {}".format(ft)) self.cmd = cmd - self.time_stamp = datetime.now().strftime("%Y%m%d-%H%M%S") + fmt = "%Y%m%d-%H%M%S" + #self.time_stamp = (datetime.now() if args.time_stamp is None else dateutil.parser.parse(args.time_stamp)).strftime("%Y%m%d-%H%M%S") + self.time_stamp = (datetime.now() if args.time_stamp is None else datetime.strptime(args.time_stamp, fmt)).strftime(fmt) + self.tag = args.tag + slog(INFO, "Tag = {}\n".format(self.tag)) self.connections = Connections() for spec in args.connection: self.connections.append(spec) diff --git a/src/python/devtest/os/MachineCmd.py b/src/python/devtest/os/MachineCmd.py index 395d9df..e335383 100644 --- a/src/python/devtest/os/MachineCmd.py +++ b/src/python/devtest/os/MachineCmd.py @@ -19,6 +19,8 @@ class MachineCmd(jwutils.Cmd): # export p.add_argument( "--shutdown-timeout", help="Timeout for a machine to complete an ACPI shutdown request in ms", default=60000) p.add_argument( "--poweroff-timeout", help="Timeout for a machine to complete a poweroff request in ms", default=100) p.add_argument( "--features", help="Comma-separated list of features that are passed to the test cases for interpretation", default='') + p.add_argument( "--time-stamp", help="Time stamp used for output tagging and file names", default=None) + p.add_argument( "--tag", help="Tag used for output tagging and file names", default=None) # TODO: Don't pollute list of generic machine options with Qemu specific stuff p.add_argument("-R", "--root-part-number", help="Number of root partition (starting from 1)")