From db50ec7255a87410c86cc564f7a9b7e7d66cd862 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Tue, 26 Nov 2024 19:30:12 +0100 Subject: [PATCH] support/testing: new openocd runtime test Signed-off-by: Julien Olivain (cherry picked from commit aaf93ba27f58496e957155ade6213158f3114a34) Signed-off-by: Thomas Perale --- DEVELOPERS | 1 + support/testing/tests/package/test_openocd.py | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 support/testing/tests/package/test_openocd.py diff --git a/DEVELOPERS b/DEVELOPERS index 6f49308ab7..8d52249db2 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1974,6 +1974,7 @@ F: support/testing/tests/package/test_octave.py F: support/testing/tests/package/test_ola.py F: support/testing/tests/package/test_ola/ F: support/testing/tests/package/test_openblas.py +F: support/testing/tests/package/test_openocd.py F: support/testing/tests/package/test_parted.py F: support/testing/tests/package/test_patch.py F: support/testing/tests/package/test_patch/ diff --git a/support/testing/tests/package/test_openocd.py b/support/testing/tests/package/test_openocd.py new file mode 100644 index 0000000000..fe4d203073 --- /dev/null +++ b/support/testing/tests/package/test_openocd.py @@ -0,0 +1,37 @@ +import os + +import infra.basetest + + +class TestOpenOCD(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_OPENOCD=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + # We check the program can run. + self.assertRunOk("openocd --version") + + msg = "Buildroot" + + # We check openocd can run, load a "dummy" driver in the + # standard search path, and use some of its TCL commands. See: + # https://github.com/openocd-org/openocd/blob/v0.12.0/doc/manual/primer/commands.txt#L117 + # https://github.com/openocd-org/openocd/blob/v0.12.0/src/jtag/drivers/dummy.c + cmd = "openocd" + cmd += " -f interface/dummy.cfg" + cmd += f" -c 'dummy hello {msg}'" + cmd += " -c shutdown" + out, ret = self.emulator.run(cmd) + self.assertEqual(ret, 0) + expected_str = f"Greetings {msg}!" + self.assertIn(expected_str, out)