[test] Minor updates to pytest usage
- Add logging varibale
- Allow pytest to log to file when variable supplied
Signed-off-by: Timothy Chen <timothytim@google.com>
diff --git a/test/systemtest/conftest.py b/test/systemtest/conftest.py
index 6111534..2d5130b 100644
--- a/test/systemtest/conftest.py
+++ b/test/systemtest/conftest.py
@@ -22,6 +22,7 @@
parser.addoption("--uart_timeout", action="store", default="60")
parser.addoption("--fpga_uart", action="store", default="")
parser.addoption("--spiflash", action="store", default="")
+ parser.addoption("--log", action="store", default="")
@pytest.hookimpl(tryfirst=True)
def pytest_exception_interact(node, call, report):
@@ -125,3 +126,13 @@
path = Path(pytestconfig.getoption('spiflash')).resolve()
assert path.is_file()
return path
+
+@pytest.fixture(scope="session")
+def logfile(pytestconfig):
+ """Return path to logfile."""
+ log = pytestconfig.getoption('log')
+ if not log:
+ return
+ path = Path(log).resolve()
+ assert not path.is_dir()
+ return path