Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Ziegler <br025@umbiko.net>
To: buildroot@buildroot.org
Cc: Marcus Hoffmann <buildroot@bubu1.eu>, Andreas Ziegler <br025@umbiko.net>
Subject: [Buildroot] [PATCH v2 10/11] support/testing: add runtime test for mpd
Date: Thu,  9 Jul 2026 13:08:14 +0200	[thread overview]
Message-ID: <20260709110822.305873-11-br025@umbiko.net> (raw)
In-Reply-To: <20260709110822.305873-1-br025@umbiko.net>

Signed-off-by: Andreas Ziegler <br025@umbiko.net>
---
 support/testing/tests/package/test_mpd.py     | 57 ++++++++++++++
 .../tests/package/test_mpd/busybox.fragment   |  4 +
 .../tests/package/test_mpd/post-build.sh      |  6 ++
 .../test_mpd/rootfs-overlay/etc/mpd.conf      | 14 ++++
 .../test_mpd/rootfs-overlay/root/test_mpd.sh  | 74 +++++++++++++++++++
 5 files changed, 155 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/post-build.sh
 create mode 100644 support/testing/tests/package/test_mpd/rootfs-overlay/etc/mpd.conf
 create mode 100755 support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh

diff --git a/support/testing/tests/package/test_mpd.py b/support/testing/tests/package/test_mpd.py
new file mode 100644
index 0000000000..8564bb85e8
--- /dev/null
+++ b/support/testing/tests/package/test_mpd.py
@@ -0,0 +1,57 @@
+#!/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")
+    post_build_script = \
+        infra.filepath("tests/package/test_mpd/post-build.sh")
+
+    # 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_ROOTFS_POST_BUILD_SCRIPT="{}"
+        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_PACKAGE_MPD_FLAC=y
+        BR2_PACKAGE_MPD_LIBSNDFILE=y
+        # BR2_PACKAGE_MPD_MAD is not set
+        # BR2_PACKAGE_MPD_ALSA is not set
+        BR2_PACKAGE_MPD_ID3TAG=y
+        BR2_TARGET_ROOTFS_INITRAMFS=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """.format(rootfs_overlay, post_build_script, 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", "max",
+                "-smp", "2",
+                "-initrd", cpio_file,
+                ])
+
+        self.emulator.login()
+
+        self.assertRunOk("/root/test_mpd.sh", timeout=90)
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/post-build.sh b/support/testing/tests/package/test_mpd/post-build.sh
new file mode 100755
index 0000000000..21ba33df01
--- /dev/null
+++ b/support/testing/tests/package/test_mpd/post-build.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+src="${0%/*}"
+dst="$TARGET_DIR"
+### unpack test data into target
+cat "$src"/_test_data? | tar vxz -C "$dst"
diff --git a/support/testing/tests/package/test_mpd/rootfs-overlay/etc/mpd.conf b/support/testing/tests/package/test_mpd/rootfs-overlay/etc/mpd.conf
new file mode 100644
index 0000000000..210ac0467f
--- /dev/null
+++ b/support/testing/tests/package/test_mpd/rootfs-overlay/etc/mpd.conf
@@ -0,0 +1,14 @@
+music_directory "/var/lib/mpd/music"
+log_file "/var/log/mpd.log"
+pid_file "/var/run/mpd.pid"
+
+database {
+	plugin "simple"
+	path "/var/lib/mpd/mpd.db"
+	cache_directory "/var/lib/mpd/cache"
+}
+
+audio_output {
+	type "null"
+	name "sink hole"
+}
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..9b9fa53b6d
--- /dev/null
+++ b/support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh
@@ -0,0 +1,74 @@
+#!/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 ;;
+			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_state
+}
+
+dump_playlist() {
+( echo "playlistinfo"; echo "close" ) | \
+	nc localhost 6600 | \
+	awk ' \
+		BEGIN{FS=": "} \
+		{ \
+			if($1=="file") f=$2; \
+			if($1=="Title") t=$2; \
+			if($1=="Artist") a=$2; \
+			if($1=="Pos") print $2, a, "-", t, "(" f ")" \
+		}'
+}
+
+test_mpd() {
+	mpd_command "status" || return 1
+
+	# create playlist
+	mpd_command "findadd \"(artist == 'ffmpeg')\"" || return 2
+
+	# check playlist size
+	queue=$(dump_playlist)
+	[ "$(echo "$queue" | wc -l)" -eq 2 ] || return 3
+
+	# check if albumart is available
+	audio_file=$(echo "$queue" | head -1 | sed 's/.*(\(.*\))/\1/')
+	mpd_command "albumart \"$audio_file\" 0" || return 4
+
+	# play some music
+	mpd_command "play 0" || return 5
+
+	# wait for playback to end
+	playing=1
+	duration=0
+	while [ "$playing" -eq 1 ] && [ "$duration" -lt 60 ]; do
+		sleep 1
+		duration=$((duration+1))
+		mpd_command "status" > /dev/null
+		[ "$mpd_state" = "stop" ] && playing=0
+	done
+
+	# playback should have run for exactly 60 seconds
+	[ $duration -eq 59 ] && [ "$playing" -eq 0 ] || return 6
+
+	# clear songs from playlist
+	mpd_command "clear" || return 7
+}
+
+[ "$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-07-09 11:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 11:08 [Buildroot] [PATCH v2 00/11] add runtime test for mpd Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 01/11] package/mpd: install provided sample configuration file as mpd.conf Andreas Ziegler
2026-08-15 17:08   ` Thomas Petazzoni via buildroot
2026-08-17  3:18     ` Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 02/11] package/mpd: remove duplicated dependencies from sub-options Andreas Ziegler
2026-08-15 19:37   ` Thomas Petazzoni via buildroot
2026-08-17  3:27     ` Andreas Ziegler
2026-08-17  3:31     ` Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 03/11] package/mpd: reorder config items based on order in meson_options.txt Andreas Ziegler
2026-08-15 19:38   ` Thomas Petazzoni via buildroot
2026-08-17  3:40     ` Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 04/11] support/testing: add test data for mpd (1/6) Andreas Ziegler
2026-08-15 19:41   ` Thomas Petazzoni via buildroot
2026-08-17  3:47     ` Andreas Ziegler
2026-08-17  6:59       ` Thomas Petazzoni via buildroot
2026-08-17 11:27         ` Andreas Ziegler
2026-08-17 12:14           ` Thomas Petazzoni via buildroot
2026-08-18  3:10             ` Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 05/11] support/testing: add test data for mpd (2/6) Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 06/11] support/testing: add test data for mpd (3/6) Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 07/11] support/testing: add test data for mpd (4/6) Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 08/11] support/testing: add test data for mpd (5/6) Andreas Ziegler
2026-07-09 11:08 ` [Buildroot] [PATCH v2 09/11] support/testing: add test data for mpd (6/6) Andreas Ziegler
2026-07-09 11:08 ` Andreas Ziegler [this message]
2026-07-09 11:08 ` [Buildroot] [PATCH v2 11/11] DEVELOPERS: add entry for test_mpd Andreas Ziegler
2026-07-11 10:24 ` [Buildroot] [PATCH v2 00/11] add runtime test for mpd Fiona Klute via buildroot
2026-07-12  2: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=20260709110822.305873-11-br025@umbiko.net \
    --to=br025@umbiko.net \
    --cc=buildroot@bubu1.eu \
    --cc=buildroot@buildroot.org \
    /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