Skip to contentSkip to conversation

support/testing: new openocd runtime test

PATCH Applied Julien Olivain 2 participants 2 messages Nov 26, 2024 – May 2, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support/testing: new openocd runtime test

---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/8477140333

---
 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
DEVELOPERS +1 -0
index d75df5cc55..1045324a52 100644
@@ -1953,6 +1953,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_pciutils.py
 F:	support/testing/tests/package/test_perftest.py
support/testing/tests/package/test_openocd.py new file +37 -0
new file mode 100644
index 0000000000..fe4d203073
@@ -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)
Signature · 6 lines
2.47.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 1 line · Julien Olivain

Applied to 2025.02.x, thanks.

Regards,
Arnout

Quoted 54 lines

---
Patch tested in:
https://gitlab.com/jolivain/buildroot/-/jobs/8477140333

---
  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

DEVELOPERS +1 -0
index d75df5cc55..1045324a52 100644
@@ -1953,6 +1953,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_pciutils.py
  F:	support/testing/tests/package/test_perftest.py
support/testing/tests/package/test_openocd.py new file +27 -0
new file mode 100644
index 0000000000..fe4d203073
@@ -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:

support/testing/tests/package/test_openocd.py line 37

Quoted 10 lines
support/testing/tests/package/test_openocd.py new file +10 -0
+        # 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)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot