Skip most of the mixerctl tests when running under QEMU (assumed to be for ATF)

as the kernel that runs them has no audio (and no mixers) configured.

The usage message test might be returned some day if /usr/bin/mixerctl
gets modified so it doesn't attempt to open the device (and error out)
in cases where the device isn't actually going to be used (and -d wasn't
given to set the device name explicitly).
This commit is contained in:
kre 2017-02-23 02:09:24 +00:00
parent e3edf3b621
commit e4eeed67d9
1 changed files with 16 additions and 2 deletions

View File

@ -1,10 +1,16 @@
# $NetBSD: t_mixerctl.sh,v 1.1 2017/01/02 15:40:09 christos Exp $
# $NetBSD: t_mixerctl.sh,v 1.2 2017/02/23 02:09:24 kre Exp $
atf_test_case noargs_usage
noargs_usage_head() {
atf_set "descr" "Ensure mixerctl(1) with no args prints a usage message"
}
noargs_usage_body() {
if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
then
# better would be for mixerctl to not open the device...
# but for now, it does.
atf_skip "ATF qemu kernel has no audio"
fi
atf_check -s exit:0 -o not-empty -e ignore \
mixerctl
}
@ -14,6 +20,10 @@ showvalue_head() {
atf_set "descr" "Ensure mixerctl(1) can print the value for all variables"
}
showvalue_body() {
if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
then
atf_skip "ATF qemu kernel has no audio"
fi
for var in $(mixerctl -a | awk -F= '{print $1}'); do
atf_check -s exit:0 -e ignore -o match:"^${var}=" \
mixerctl ${var}
@ -25,7 +35,11 @@ nflag_head() {
atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output"
}
nflag_body() {
varname="$(mixerctl -a | head -1 | awk -F= '{print $1}')"
if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1
then
atf_skip "ATF qemu kernel has no audio"
fi
varname="$(mixerctl -a | sed -e 's/=.*//' -e q)"
atf_check -s exit:0 -o match:"${varname}" -e ignore \
mixerctl ${varname}