Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Ziegler <br025@umbiko.net>
To: buildroot@buildroot.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Marcus Hoffmann <buildroot@bubu1.eu>,
	Andreas Ziegler <br025@umbiko.net>
Subject: [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd
Date: Sat,  5 Sep 2026 06:02:53 +0200	[thread overview]
Message-ID: <20260905040256.2221199-3-br025@umbiko.net> (raw)
In-Reply-To: <20260905040256.2221199-1-br025@umbiko.net>

The test determines if mpd was started by the init system by querying
mpd status via the built-in protocol and evaluating the result.

Signed-off-by: Andreas Ziegler <br025@umbiko.net>
---
Changes v2 -> v3:
	simplify test to be used without test data
	remove mpd.conf rootfs overlay

 DEVELOPERS                                    |  2 +
 support/testing/tests/package/test_mpd.py     | 49 +++++++++++++++++++
 .../tests/package/test_mpd/busybox.fragment   |  4 ++
 .../test_mpd/rootfs-overlay/root/test_mpd.sh  | 35 +++++++++++++
 4 files changed, 90 insertions(+)
 create mode 100644 support/testing/tests/package/test_mpd.py
 create mode 100644 support/testing/tests/package/test_mpd/busybox.fragment
 create mode 100755 support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh

diff --git a/DEVELOPERS b/DEVELOPERS
index 53104cc60b..409e8fcaaa 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -205,6 +205,8 @@ F:	package/qt6/qt6opcua/
 
 N:	Andreas Ziegler <br025@umbiko.net>
 F:	package/mpd/
+F:	support/testing/tests/package/test_mpd
+F:	support/testing/tests/package/test_mpd.py
 
 N:	Andrey Smirnov <andrew.smirnov@gmail.com>
 F:	package/python-decorator/
diff --git a/support/testing/tests/package/test_mpd.py b/support/testing/tests/package/test_mpd.py
new file mode 100644
index 0000000000..4ce297c2b8
--- /dev/null
+++ b/support/testing/tests/package/test_mpd.py
@@ -0,0 +1,49 @@
+#!/bin/python
+
+import os
+import infra.basetest
+
+class TestMpd(infra.basetest.BRTest):
+
+    rootfs_overlay = \
+        infra.filepath("tests/package/test_mpd/rootfs-overlay")
+    busybox_fragment = \
+        infra.filepath("tests/package/test_mpd/busybox.fragment")
+
+    # use a custom configuration
+    config = \
+        """
+        BR2_x86_64=y
+        BR2_x86_x86_64_v2=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_GLIBC_BLEEDING_EDGE=y
+        BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
+        BR2_ROOTFS_OVERLAY="{}"
+        BR2_LINUX_KERNEL=y
+        BR2_LINUX_KERNEL_LATEST_VERSION=y
+        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
+        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+        BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
+        BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="{}"
+        BR2_PACKAGE_MPD=y
+        BR2_TARGET_ROOTFS_INITRAMFS=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """.format(rootfs_overlay, busybox_fragment)
+
+    def test_run(self):
+        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
+        kern = os.path.join(self.builddir, "images", "bzImage")
+        self.emulator.boot(arch="x86_64",
+            kernel=kern,
+            kernel_cmdline=["console=ttyS0"],
+            options=[
+                "-M", "q35",
+                "-cpu", "Westmere",
+                "-smp", "2",
+                "-initrd", cpio_file,
+                ])
+
+        self.emulator.login()
+
+        self.assertRunOk("/root/test_mpd.sh", timeout=30)
diff --git a/support/testing/tests/package/test_mpd/busybox.fragment b/support/testing/tests/package/test_mpd/busybox.fragment
new file mode 100644
index 0000000000..0c92d86c49
--- /dev/null
+++ b/support/testing/tests/package/test_mpd/busybox.fragment
@@ -0,0 +1,4 @@
+#
+# Networking Utilities
+#
+CONFIG_NC=y
diff --git a/support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh b/support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh
new file mode 100755
index 0000000000..4cc6895602
--- /dev/null
+++ b/support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+mpd_command() {
+	mpd_result=""
+	mpd_state=""
+	printf "Execute %s" "$1"
+	while IFS= read -r line; do
+		case $line in
+			OK) 						mpd_result=$line ;;
+			OK\ MPD*)					mpd_protocol=${line##* } ;;
+			state:*)					mpd_state=${line##*: } ;;
+			ACK\ \[[0-9]*@[0-9]*\]*)	mpd_error=${line##*\} } ;;
+		esac
+	done <<- EOF
+	$( ( echo "$1"; echo "close" ) | nc localhost 6600 )
+EOF
+
+	if [ "$mpd_result" != "OK" ]; then
+		printf "\nmpd protocol error: %s\n" "$mpd_error"
+		return 1
+	else
+		printf " [OK]\n"
+	fi
+
+	export mpd_protocol
+	export mpd_state
+}
+
+test_mpd() {
+	mpd_command "status" || return 1
+	printf "MPD protocol version: %s\n" "$mpd_protocol"
+}
+
+# run main function if invoked from a subshell
+[ "$0" = "-sh" ] || test_mpd
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2026-09-05  4:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05  4:02 [Buildroot] [PATCH v4 0/2] Add runtime test for mpd Andreas Ziegler
2026-09-05  4:02 ` [Buildroot] [PATCH v4 1/2] package/mpd: remove unused, add mandatory configuration items Andreas Ziegler
2026-09-05 14:14   ` Thomas Petazzoni via buildroot
2026-09-06  4:34     ` Andreas Ziegler
2026-09-05  4:02 ` Andreas Ziegler [this message]
2026-09-05 14:17   ` [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd Thomas Petazzoni via buildroot
2026-09-06  4:54     ` Andreas Ziegler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260905040256.2221199-3-br025@umbiko.net \
    --to=br025@umbiko.net \
    --cc=buildroot@bubu1.eu \
    --cc=buildroot@buildroot.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox