54 lines
2.8 KiB
Python
54 lines
2.8 KiB
Python
"""Exercise the opt-in early-IPA boot gate against fake remoteproc devices."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DSP = ROOT / "scripts/phone-dsp.openrc"
|
|
RMTFS = ROOT / "project/cellular/ipa-v2/rmtfs-early.conf"
|
|
|
|
|
|
class EarlyIpaBootTest(unittest.TestCase):
|
|
def test_exact_cmdline_token_required(self):
|
|
for cmdline, enabled in (("quiet platina.ipa_bringup=1 panic=10", True),
|
|
("quiet platina.ipa_bringup=0", False),
|
|
("xplatina.ipa_bringup=1", False),
|
|
("platina.ipa_bringup=10", False),
|
|
("quiet", False)):
|
|
with self.subTest(cmdline=cmdline), tempfile.TemporaryDirectory() as directory:
|
|
path = Path(directory) / "cmdline"
|
|
path.write_text(cmdline + "\n")
|
|
result = subprocess.run(["sh", "-c", '. "$1"; ipa_bringup_mode "$2"',
|
|
"sh", str(DSP), str(path)])
|
|
self.assertEqual(result.returncode == 0, enabled)
|
|
|
|
def test_only_modem_is_held_offline(self):
|
|
for mode in ("0", "1"):
|
|
with self.subTest(mode=mode), tempfile.TemporaryDirectory() as directory:
|
|
root = Path(directory)
|
|
for index, name in enumerate(("adsp", "cdsp", "4080000.remoteproc")):
|
|
node = root / f"remoteproc{index}"
|
|
node.mkdir()
|
|
(node / "name").write_text(name + "\n")
|
|
(node / "state").write_text("offline\n")
|
|
subprocess.run(["sh", "-c", '. "$1"; start_remoteprocs "$2" "$3"',
|
|
"sh", str(DSP), str(root), mode], check=True)
|
|
self.assertEqual((root / "remoteproc0/state").read_text(), "start\n")
|
|
self.assertEqual((root / "remoteproc1/state").read_text(), "start\n")
|
|
self.assertEqual((root / "remoteproc2/state").read_text(),
|
|
"offline\n" if mode == "1" else "start\n")
|
|
|
|
def test_rmtfs_sync_option_only_removed_in_test_boot(self):
|
|
for cmdline, expected in (("quiet", "-s -P -r -v"),
|
|
("quiet platina.ipa_bringup=1", "-P -r -v")):
|
|
with self.subTest(cmdline=cmdline):
|
|
script = ('cat() { printf "%s\\n" "$TEST_CMDLINE"; }; '
|
|
'command_args="-s -P -r -v"; . "$1"; '
|
|
'printf "%s" "$command_args"')
|
|
result = subprocess.run(["sh", "-c", script, "sh", str(RMTFS)],
|
|
env={"TEST_CMDLINE": cmdline}, capture_output=True,
|
|
text=True, check=True)
|
|
self.assertEqual(result.stdout, expected)
|