Add runtime test for mpd
v3 cover Add runtime test for mpd
Buildroot mpd.conf now contains exactly the minimum changes, that need to be merged with the upstream configuration file to make a default build of mpd runnable.
The runtime test has been stripped down to be able to dispense with using test data. It uses the standard Buildroot configuration for mpd without customization.
Changes v1 -> v2:
split test data in chunks to overcome mailing list restrictions
Changes v2 -> v3:
leave Config.in unchanged
reintroduce Buildroot mpd.conf as fragment file simplify test to be used without test data
remove test data
remove mpd.conf rootfs overlay
Andreas Ziegler (2):
package/mpd: use upstream mpd.conf w/ buildroot modifications support/testing: add runtime test for mpd
DEVELOPERS | 2 + package/mpd/mpd.conf | 31 +++-------- package/mpd/mpd.mk | 22 +++++++- support/testing/tests/package/test_mpd.py | 51 +++++++++++++++++++ .../tests/package/test_mpd/busybox.fragment | 4 ++ .../test_mpd/rootfs-overlay/root/test_mpd.sh | 35 +++++++++++++ 6 files changed, 121 insertions(+), 24 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
PATCH v3 1/2 package/mpd: use upstream mpd.conf w/ buildroot modifications
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.
Treat Buildroot mpd.conf as a fragment file, containing the minimum modifications necessary to run mpd in a default build. Install the upstream sample and inject the values from the Buildroot fragment.
* log_file, pid_file: Buildroot specific; referenced in mpd.mk and S95mpd
* audio_output: At least one output has to be defined to run mpd
---
Changes v2 -> v3:
reintroduce Buildroot mpd.conf as fragment file
package/mpd/mpd.conf | 31 ++++++++----------------------- package/mpd/mpd.mk | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 24 deletions(-)
package/mpd/mpd.conf +8 -23
@@ -1,32 +1,17 @@ # -# Sample configuration file for mpd -# This is a minimal configuration, see the manpage for more options +# The configuration file is provided by the mpd package. This file +# contains values that will override settings from the main config +# file to make mpd startable in a default configuration. # -# 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 +21 -1
@@ -345,8 +345,28 @@ else MPD_CONF_OPTS += -Dzzip=disabled endif +# sed snippet from https://stackoverflow.com/a/37911473 +# single-line configurations will be inserted behind the last matching line +# in the target file, multi-line blocks are just appended at the bottom. define MPD_INSTALL_EXTRA_FILES - $(INSTALL) -m 0644 -D package/mpd/mpd.conf $(TARGET_DIR)/etc/mpd.conf + $(INSTALL) -m 0644 -D $(@D)/doc/mpdconf.example $(TARGET_DIR)/etc/mpd.conf + export multiline=0 + while read -r line; do \ + if [[ $$line =~ ^[a-zA-Z] ]]; then \ + if [ "$${line##*[[:space:]]}" == "{" ]; then \ + export multiline=1; \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + else \ + [ $$multiline ] && \ + printf "\t%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + [ ! $$multiline ] && \ + sed '/#'$${line%%[[:space:]]*}'[^\n]*/,$$!b;//{x;//p;g};//!H;$$!d;x;s||&\n'"$$line"'|' -i "$(TARGET_DIR)"/etc/mpd.conf; \ + fi \ + elif [ "$$line" == "}" ]; then \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + export multiline=0; \ + fi \ + done < package/mpd/mpd.conf mkdir -p $(TARGET_DIR)/var/lib/mpd/music mkdir -p $(TARGET_DIR)/var/lib/mpd/playlists endef
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Re: [Buildroot] [PATCH v3 1/2] package/mpd: use upstream mpd.conf w/ buildroot modifications
Hello Andreas,
Quoted 13 lines · Andreas Ziegler
package/mpd/mpd.mk +11
-1+# sed snippet from https://stackoverflow.com/a/37911473 +# single-line configurations will be inserted behind the last matching line +# in the target file, multi-line blocks are just appended at the bottom. define MPD_INSTALL_EXTRA_FILES - $(INSTALL) -m 0644 -D package/mpd/mpd.conf $(TARGET_DIR)/etc/mpd.conf + $(INSTALL) -m 0644 -D $(@D)/doc/mpdconf.example $(TARGET_DIR)/etc/mpd.conf + export multiline=0 + while read -r line; do \ + if [[ $$line =~ ^[a-zA-Z] ]]; then \ + if [ "$${line##*[[:space:]]}" == "{" ]; then \ + export multiline=1; \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + else \
package/mpd/mpd.mk else · line 369
Quoted 10 lines
package/mpd/mpd.mk +10
-0+ [ $$multiline ] && \ + printf "\t%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + [ ! $$multiline ] && \ + sed '/#'$${line%%[[:space:]]*}'[^\n]*/,$$!b;//{x;//p;g};//!H;$$!d;x;s||&\n'"$$line"'|' -i "$(TARGET_DIR)"/etc/mpd.conf; \ + fi \ + elif [ "$$line" == "}" ]; then \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + export multiline=0; \ + fi \ + done < package/mpd/mpd.conf
I am sorry, but this is way too complicated for Buildroot's KISS principle. Some much simpler approach needs to be found.
Best regards,
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
Re: [Buildroot] [PATCH v3 1/2] package/mpd: use upstream mpd.conf w/ buildroot modifications
Ji Thomas,
Quoted 27 lines · Thomas Petazzoni
Hello Andreas,
Quoted 24 lines · Andreas Ziegler
(quoted diff) +2
-0+# sed snippet from https://stackoverflow.com/a/37911473 +# single-line configurations will be inserted behind the lastmatching line
+# in the target file, multi-line blocks are just appended at the bottom.
defineMPD_INSTALL_EXTRA_FILES(quoted diff) +0
-1- $(INSTALL) -m 0644 -D package/mpd/mpd.conf$(TARGET_DIR)/etc/mpd.conf
(quoted diff) +1
-0+ $(INSTALL) -m 0644 -D $(@D)/doc/mpdconf.example$(TARGET_DIR)/etc/mpd.conf
package/mpd/mpd.mk +11
-0+ export multiline=0 + while read -r line; do \ + if [[ $$line =~ ^[a-zA-Z] ]]; then \ + if [ "$${line##*[[:space:]]}" == "{" ]; then \ + export multiline=1; \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + else \ + [ $$multiline ] && \ + printf "\t%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + [ ! $$multiline ] && \ + sed'/#'$${line%%[[:space:]]*}'[^\n]*/,$$!b;//{x;//p;g};//!H;$$!d;x;s||&\n'"$$line"'|'
(quoted diff) +1
-1-i "$(TARGET_DIR)"/etc/mpd.conf; \ + fi \
Quoted 8 lines
package/mpd/mpd.mk else · line 369
Quoted 5 lines
package/mpd/mpd.mk +5
-0+ elif [ "$$line" == "}" ]; then \ + printf "%s\n" "$$line" >> "$(TARGET_DIR)"/etc/mpd.conf; \ + export multiline=0; \ + fi \ + done < package/mpd/mpd.confI am sorry, but this is way too complicated for Buildroot's KISS principle. Some much simpler approach needs to be found.
You might have a point: too much effort for a file that is probably never used :-D
Quoted 7 lines
Best regards,
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
PATCH v3 2/2 support/testing: add runtime test for mpd
In reply to Andreas Ziegler---
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 | 51 +++++++++++++++++++ .../tests/package/test_mpd/busybox.fragment | 4 ++ .../test_mpd/rootfs-overlay/root/test_mpd.sh | 35 +++++++++++++ 4 files changed, 92 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
@@ -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 +51 -0
51 lines not on this page · raw message
support/testing/tests/package/test_mpd/busybox.fragment new file +4 -0
@@ -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
@@ -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