diff mbox series

[1/1] support/testing: add strace runtime test

Message ID 20240118211148.70993-1-ju.o@free.fr
State Accepted
Headers show
Series [1/1] support/testing: add strace runtime test | expand

Commit Message

Julien Olivain Jan. 18, 2024, 9:11 p.m. UTC
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on branch master at commit b200632 with commands:

    make check-package
    ...
    0 warnings generated

    support/testing/run-tests \
        -d dl -o output_folder \
        tests.package.test_strace
    ...
    OK
---
 DEVELOPERS                                   |  1 +
 support/testing/tests/package/test_strace.py | 37 ++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 support/testing/tests/package/test_strace.py

Comments

Peter Korsgaard Feb. 5, 2024, 10:32 a.m. UTC | #1
On 18/01/2024 22.11, Julien Olivain wrote:
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested on branch master at commit b200632 with commands:
> 
>      make check-package
>      ...
>      0 warnings generated
> 
>      support/testing/run-tests \
>          -d dl -o output_folder \
>          tests.package.test_strace
>      ...
>      OK

Committed, thanks.
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index f5b04937b6..9b14b4a495 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1811,6 +1811,7 @@  F:	support/testing/tests/package/test_python_spake2.py
 F:	support/testing/tests/package/test_rdma_core.py
 F:	support/testing/tests/package/test_rdma_core/
 F:	support/testing/tests/package/test_screen.py
+F:	support/testing/tests/package/test_strace.py
 F:	support/testing/tests/package/test_stress_ng.py
 F:	support/testing/tests/package/test_tcl.py
 F:	support/testing/tests/package/test_tcl/
diff --git a/support/testing/tests/package/test_strace.py b/support/testing/tests/package/test_strace.py
new file mode 100644
index 0000000000..c1cba2173f
--- /dev/null
+++ b/support/testing/tests/package/test_strace.py
@@ -0,0 +1,37 @@ 
+import os
+
+import infra.basetest
+
+
+class TestStrace(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_STRACE=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()
+
+        # Check the program can execute.
+        self.assertRunOk("strace --version")
+
+        test_file = "buildroot-strace-test.txt"
+        test_file_mode = "0600"
+        strace_log = "strace.log"
+
+        # Create a test file.
+        self.assertRunOk(f"touch {test_file}")
+
+        # Run strace on a chmod
+        cmd = f"strace -o {strace_log} chmod {test_file_mode} {test_file}"
+        self.assertRunOk(cmd)
+
+        # Check the strace log contain a call to chmod()
+        expected_str = f"chmod(\"{test_file}\", {test_file_mode}) = 0"
+        self.assertRunOk(f"grep -F '{expected_str}' {strace_log}")