@@ -1,6 +1,9 @@
+import asyncio
import os
import pathlib
import subprocess
+import tempfile
+import unittest.mock
from oeqa.selftest.case import OESelftestTestCase
@@ -49,3 +52,58 @@ class RunFVPTests(OESelftestTestCase):
def test_fvp_options(self):
# test-parameter sets one argument, add another manually
self.run_fvp(testdir / "test-parameter.json", "--", "--parameter", "board.dog=woof")
+
+class ConfFileTests(OESelftestTestCase):
+ def test_no_exe(self):
+ from fvp import conffile
+ with tempfile.NamedTemporaryFile('w') as tf:
+ tf.write('{}')
+ tf.flush()
+
+ with self.assertRaises(ValueError):
+ conffile.load(tf.name)
+
+ def test_minimal(self):
+ from fvp import conffile
+ with tempfile.NamedTemporaryFile('w') as tf:
+ tf.write('{"exe": "FVP_Binary"}')
+ tf.flush()
+
+ conf = conffile.load(tf.name)
+ self.assertTrue('fvp-bindir' in conf)
+ self.assertTrue('fvp-bindir' in conf)
+ self.assertTrue("exe" in conf)
+ self.assertTrue("parameters" in conf)
+ self.assertTrue("data" in conf)
+ self.assertTrue("applications" in conf)
+ self.assertTrue("terminals" in conf)
+ self.assertTrue("args" in conf)
+ self.assertTrue("console" in conf)
+
+
+class RunnerTests(OESelftestTestCase):
+ def create_mock(self):
+ return unittest.mock.patch("asyncio.create_subprocess_exec")
+
+ def test_start(self):
+ from fvp import runner
+ with self.create_mock() as m:
+ fvp = runner.FVPRunner(self.logger)
+ asyncio.run(fvp.start({
+ "fvp-bindir": "/usr/bin",
+ "exe": "FVP_Binary",
+ "parameters": {'foo': 'bar'},
+ "data": ['data1'],
+ "applications": {'a1': 'file'},
+ "terminals": {},
+ "args": ['--extra-arg'],
+ }))
+
+ m.assert_called_once_with('/usr/bin/FVP_Binary',
+ '--parameter', 'foo=bar',
+ '--data', 'data1',
+ '--application', 'a1=file',
+ '--extra-arg',
+ stdin=unittest.mock.ANY,
+ stdout=unittest.mock.ANY,
+ stderr=unittest.mock.ANY)