From 313f557b932786a426f6f613c111005f507f1b24 Mon Sep 17 00:00:00 2001 From: Gabriel Busnot Date: Tue, 3 Jan 2023 15:37:38 +0000 Subject: [PATCH] ext-testlib: Support str-convertible args in gem5_verify_config gem5_verify_config dit not support string-convertible args due to log_call() not trying to call str() on them. This patch maps str() on the command paramters. It is now possible to pass native integers or even string-like types like pathlib.Path as arguments without manually converting them to string. Change-Id: Ifa987f5f1a20f17c8710e1a36d99d424e4c9ce6c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/66893 Reviewed-by: Bobby Bruce Maintainer: Bobby Bruce Tested-by: kokoro --- ext/testlib/helper.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ext/testlib/helper.py b/ext/testlib/helper.py index ed6e325158..ea102f262b 100644 --- a/ext/testlib/helper.py +++ b/ext/testlib/helper.py @@ -149,7 +149,14 @@ def log_call(logger, command, time, *popenargs, **kwargs): if isinstance(command, str): cmdstr = command else: - cmdstr = ' '.join(command) + try: + command = list(map(str, command)) + cmdstr = " ".join(command) + except TypeError as e: + logger.trace( + "Argument must be an iterable of string-convertible types" + ) + raise e logger_callback = logger.trace logger.trace('Logging call to command: %s' % cmdstr)