Skip to contentSkip to conversation

Add runtime test for mpd

PATCH In review Andreas Ziegler 2 participants 7 messages Sep 5 – Sep 6

lore
Share & tools
lore
#0 lore raw

v4 cover Add runtime test for mpd

Unused presets have been removed from the mpd configuration:

Config.in: libmad, libalsa,
mpd.mk: Creation of directories.

The configuration file contains a minimum of presets to be able to start mpd.

Andreas Ziegler (2):
package/mpd: remove defaults, add minimum configuration support/testing: add runtime test for mpd

 DEVELOPERS                                    |  2 +
 package/mpd/Config.in                         |  2 -
 package/mpd/mpd.conf                          | 31 +++---------
 package/mpd/mpd.mk                            |  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 +++++++++++++
 7 files changed, 98 insertions(+), 27 deletions(-)
 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
Signature · 6 lines
2.53.0

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

PATCH v4 1/2 package/mpd: remove unused, add mandatory configuration items

The configuration file supplied by Buildroot is only a sample; it will not start MPD on a default installation. In a production build, a custom mpd.conf has to be supplied via rootfs overlay or on the target system.

Supply the necessary configuration items to start mpd in a default build, and discard unused customizations.

---
Changes v2 -> v3:
reintroduce Buildroot mpd.conf as fragment file
Changes v3 -> v4:
drop deployment of upstream config file

 package/mpd/Config.in |  2 --
 package/mpd/mpd.conf  | 31 ++++++++-----------------------
 package/mpd/mpd.mk    |  2 --
 3 files changed, 8 insertions(+), 27 deletions(-)
package/mpd/Config.in +0 -2
index 1b6815e904..bbd6fc16e5 100644
@@ -119,7 +119,6 @@ config BR2_PACKAGE_MPD_LIBSNDFILE
 
 config BR2_PACKAGE_MPD_MAD
 	bool "mad"
-	default y
 	select BR2_PACKAGE_MPD_ID3TAG
 	select BR2_PACKAGE_LIBMAD
 	help
@@ -244,7 +243,6 @@ comment "Output plugins"
 
 config BR2_PACKAGE_MPD_ALSA
 	bool "alsa"
-	default y
 	select BR2_PACKAGE_ALSA_LIB
 	select BR2_PACKAGE_ALSA_LIB_PCM
 	select BR2_PACKAGE_ALSA_LIB_MIXER
package/mpd/mpd.conf +8 -23
index 5956b75e24..b9fba3179a 100644
@@ -1,32 +1,17 @@
 #
-# Sample configuration file for mpd
-# This is a minimal configuration, see the manpage for more options
+# Buildroot mpd configuration
+# Example file: doc/mpdconf.example in the build directory
+# Documentation: http://mpd.readthedocs.io/latest/user.html
 #
 
-# Directory where the music is stored
-music_directory		"/var/lib/mpd/music"
-
-# Directory where user-made playlists are stored (RW)
-playlist_directory	"/var/lib/mpd/playlists"
-
-# Database file (RW)
-db_file			"/var/lib/mpd/database"
-
 # Log file (RW)
 log_file		"/var/log/mpd.log"
 
 # Process ID file (RW)
 pid_file		"/var/run/mpd.pid"
 
-# State file (RW)
-state_file		"/var/lib/mpd/state"
-
-# User id to run the daemon as
-#user			"nobody"
-
-# TCP socket binding
-bind_to_address		"any"
-#bind_to_address	"localhost"
-
-# Unix socket to listen on
-bind_to_address		"/var/lib/mpd/socket"
+# One output has to be defined
+audio_output {
+	type	"null"
+	name	"/dev/null"
+}
package/mpd/mpd.mk +0 -2
index 4db0aee7cb..5852bbe73f 100644
@@ -347,8 +347,6 @@ endif
 
 define MPD_INSTALL_EXTRA_FILES
 	$(INSTALL) -m 0644 -D package/mpd/mpd.conf $(TARGET_DIR)/etc/mpd.conf
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/music
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/playlists
 endef
 
 MPD_POST_INSTALL_TARGET_HOOKS += MPD_INSTALL_EXTRA_FILES
Signature · 6 lines
2.53.0

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

Re: [Buildroot] [PATCH v4 1/2] package/mpd: remove unused, add mandatory configuration items

Hello Andreas,

Quoted 8 lines · Andreas Ziegler

The configuration file supplied by Buildroot is only a sample; it will not start MPD on a default installation. In a production build, a custom mpd.conf has to be supplied via rootfs overlay or on the target system.

Supply the necessary configuration items to start mpd in a default build, and discard unused customizations.

Thanks for the new iteration.

package/mpd/Config.in config BR2_PACKAGE_MPD_LIBSNDFILE · line 122

Quoted 9 lines
package/mpd/Config.in +0 -1
index 1b6815e904..bbd6fc16e5 100644
@@ -119,7 +119,6 @@ config BR2_PACKAGE_MPD_LIBSNDFILE
 
 config BR2_PACKAGE_MPD_MAD
 	bool "mad"
-	default y

Why?

package/mpd/Config.in comment "Output plugins" · line 247

Quoted 8 lines
package/mpd/Config.in +0 -1
 	select BR2_PACKAGE_MPD_ID3TAG
 	select BR2_PACKAGE_LIBMAD
 	help
@@ -244,7 +243,6 @@ comment "Output plugins"
 
 config BR2_PACKAGE_MPD_ALSA
 	bool "alsa"
-	default y

Why?

These changes are not really explained in your commit message. Also this change will break existing defconfigs that assume those options "default y". Is it important to change this? (Even though I agree they should not have been "default y" in the first place).

package/mpd/mpd.mk endif · line 351

Quoted 10 lines
package/mpd/mpd.mk +0 -2
index 4db0aee7cb..5852bbe73f 100644
@@ -347,8 +347,6 @@ endif
 
 define MPD_INSTALL_EXTRA_FILES
 	$(INSTALL) -m 0644 -D package/mpd/mpd.conf $(TARGET_DIR)/etc/mpd.conf
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/music
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/playlists

Why is that no longer needed? Because of the configuration file change? Or because it was bogus/useless anyway?

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [PATCH v4 1/2] package/mpd: remove unused, add mandatory configuration items

Hi Thomas,

Quoted 20 lines · Thomas Petazzoni

Hello Andreas,

Quoted 8 lines · Andreas Ziegler

The configuration file supplied by Buildroot is only a sample; it will not start MPD on a default installation. In a production build, a custom mpd.conf has to be supplied via rootfs overlay or on the target system.

Supply the necessary configuration items to start mpd in a default build, and discard unused customizations.

Thanks for the new iteration.

Quoted 6 lines
package/mpd/Config.in +0 -0
index 1b6815e904..bbd6fc16e5 100644
@@ -119,7 +119,6 @@ config BR2_PACKAGE_MPD_LIBSNDFILE
 
Quoted 5 lines

package/mpd/Config.in config BR2_PACKAGE_MPD_LIBSNDFILE · line 122

Quoted 3 lines
package/mpd/Config.in +0 -1
 config BR2_PACKAGE_MPD_MAD
 	bool "mad"
-	default y

Why?

This is an optional component. It was never used by any Buildroot, in a user configuration it is also optional. I was always wondering why I was never able to get rid of this library ... It was also never used by the Buildroot configuration.

Quoted 11 lines

package/mpd/Config.in comment "Output plugins" · line 247

Quoted 9 lines
package/mpd/Config.in +0 -1
 	select BR2_PACKAGE_MPD_ID3TAG
 	select BR2_PACKAGE_LIBMAD
 	help
@@ -244,7 +243,6 @@ comment "Output plugins"
 
 config BR2_PACKAGE_MPD_ALSA
 	bool "alsa"
-	default y

Why?

Also optional, a MPD server or a streaming setup will never use local output. Also, other output options might be selected. The buildroot configuration never contained an output section, so this was unused.

Quoted 5 lines

These changes are not really explained in your commit message. Also this change will break existing defconfigs that assume those options "default y". Is it important to change this? (Even though I agree they should not have been "default y" in the first place).

It may break a few, but also fix other configurations; I always have to check my own configs after running make defconfig. It will remove some of the complexity from Buildroot's mpd setup (and it handles only ~50% of available options).

Quoted 6 lines
Quoted 6 lines
package/mpd/mpd.mk +0 -0
index 4db0aee7cb..5852bbe73f 100644
@@ -347,8 +347,6 @@ endif
 
Quoted 8 lines

package/mpd/mpd.mk endif · line 351

Quoted 5 lines
package/mpd/mpd.mk +0 -0
 define MPD_INSTALL_EXTRA_FILES
 	$(INSTALL) -m 0644 -D package/mpd/mpd.conf 

$(TARGET_DIR)/etc/mpd.conf

package/mpd/mpd.mk +0 -2
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/music
-	mkdir -p $(TARGET_DIR)/var/lib/mpd/playlists

Why is that no longer needed? Because of the configuration file change? Or because it was bogus/useless anyway?

/var/lib/mpd was the standard place where MPD used to place its files. But /var/lib is part of the root mount, you should not put music data there. The MPD manual itself advises to check and change this setting. Stored playlists are an optional component, and not every setup uses them. The full set of directories might have been necessary in the beginning, but became obsolete when MPD added remote database access in version 0.21.

Quoted 7 lines

Thanks!

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

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

#4 lore raw

PATCH v4 2/2 support/testing: add runtime test for mpd

In reply to Andreas Ziegler

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

---
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
DEVELOPERS +2 -0
index 53104cc60b..409e8fcaaa 100644
@@ -205,6 +205,8 @@ F:	package/qt6/qt6opcua/
 
 N:	Andreas Ziegler <[email protected]>
 F:	package/mpd/
+F:	support/testing/tests/package/test_mpd
+F:	support/testing/tests/package/test_mpd.py
 
 N:	Andrey Smirnov <[email protected]>
 F:	package/python-decorator/
support/testing/tests/package/test_mpd.py new file +49 -0

49 lines not on this page · raw message

support/testing/tests/package/test_mpd/busybox.fragment new file +4 -0
new file mode 100644
index 0000000000..0c92d86c49
@@ -0,0 +1,4 @@
+#
+# Networking Utilities
+#
+CONFIG_NC=y
support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +35 -0
new file mode 100755
index 0000000000..4cc6895602
@@ -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
Signature · 6 lines
2.53.0

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

Re: [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd

Hello Andreas,

Quoted 4 lines · Andreas Ziegler

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

Thanks for this new iteration!

Quoted 9 lines

new file mode 100755
index 0000000000..4cc6895602

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +4 -0
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+mpd_command() {
+	mpd_result=""

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh line 14

Quoted 10 lines
support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +10 -0
+	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

Why are we "hacking" a minimal mpd client here instead of adding mpd-mpc to the image and using it to test mpd?

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh line 26

Quoted 2 lines
support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +2 -0
+	export mpd_protocol
+	export mpd_state

Why does this needs to be exported?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd

Hi Thomas,

Quoted 25 lines · Thomas Petazzoni

Hello Andreas,

Quoted 4 lines · Andreas Ziegler

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

Thanks for this new iteration!

Quoted 15 lines

new file mode 100755
index 0000000000..4cc6895602
--- /dev/null
+++
b/support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +9 -0
@@ -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 ;;
Quoted 8 lines

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh line 14

Quoted 5 lines
support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +5 -0
+			OK\ MPD*)					mpd_protocol=${line##* } ;;
+			state:*)					mpd_state=${line##*: } ;;
+			ACK\ \[[0-9]*@[0-9]*\]*)	mpd_error=${line##*\} } ;;
+		esac
+	done <<- EOF

Why are we "hacking" a minimal mpd client here instead of adding mpd-mpc to the image and using it to test mpd?

Hacking? The MPD command protocol is the official way to connect to the MPD server: https://mpd.readthedocs.io/en/latest/protocol.html. Every client uses it, including mpc. I use CLI one-liners regularly for debugging issues and a more complete version in a Python script for checking libraries. Why add yet another program for checking a protocol output?

Quoted 5 lines

support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh line 26

Quoted 3 lines
support/testing/tests/package/test_mpd/rootfs-overlay/root/test_mpd.sh new file +2 -0
+	export mpd_protocol
+	export mpd_state

Why does this needs to be exported?

Variable scope is not clearly defined within shells. In POSIX, all variable declarations are global; Busybox's ash should not know about scope, but tolerates 'local' definitions; bash has a basic understanding of scope and treats function variables as local. Since I switch shells often (by running scripts on different machines) I usually export variables in functions that need visibility in the caller. It is also a good reminder that the function "returns" more than one value.

Quoted 6 lines

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

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