Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Ziegler <br025@umbiko.net>
To: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: buildroot@buildroot.org, Marcus Hoffmann <buildroot@bubu1.eu>
Subject: Re: [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd
Date: Sun, 06 Sep 2026 04:54:52 +0000	[thread overview]
Message-ID: <a628e7dbd84c1dd705bd6d1d9aafcc38@umbiko.net> (raw)
In-Reply-To: <apwkJkKsWDShYA-8@windsurf>

Hi Thomas,

On 2026-09-05 14:17, Thomas Petazzoni wrote:
> Hello Andreas,
> 
> On Sat, Sep 05, 2026 at 06:02:53AM +0200, Andreas Ziegler wrote:
>> 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>
> 
> Thanks for this new iteration!
> 
>> 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
> 
> 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?

> 
>> +	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.

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

Kind regards,
Andreas
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2026-09-06  4:55 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 ` [Buildroot] [PATCH v4 2/2] support/testing: add runtime test for mpd Andreas Ziegler
2026-09-05 14:17   ` Thomas Petazzoni via buildroot
2026-09-06  4:54     ` Andreas Ziegler [this message]

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=a628e7dbd84c1dd705bd6d1d9aafcc38@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