mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-07-16 15:57:19 +00:00
arm/oeqa: Add selftests for FVP library
Create basic tests for conffile and runner in meta-arm/lib/fvp Issue-Id: SCM-4957 Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com> Change-Id: I1684b0c99fb4fd5299df19f00abb30e8faab3495 Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest.mock
|
||||||
|
|
||||||
from oeqa.selftest.case import OESelftestTestCase
|
from oeqa.selftest.case import OESelftestTestCase
|
||||||
|
|
||||||
@@ -49,3 +52,58 @@ class RunFVPTests(OESelftestTestCase):
|
|||||||
def test_fvp_options(self):
|
def test_fvp_options(self):
|
||||||
# test-parameter sets one argument, add another manually
|
# test-parameter sets one argument, add another manually
|
||||||
self.run_fvp(testdir / "test-parameter.json", "--", "--parameter", "board.dog=woof")
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user