t_mixerctl.sh revision 1.3
1# $NetBSD: t_mixerctl.sh,v 1.3 2017/02/23 02:28:10 kre Exp $
2
3atf_test_case noargs_usage
4noargs_usage_head() {
5	atf_set "descr" "Ensure mixerctl(1) with no args prints a usage message"
6}
7noargs_usage_body() {
8        if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1 &&
9	    test $(uname -m) = i386
10	then
11	    # better would be for mixerctl to not open the device...
12	    # but for now, it does.
13	    atf_skip "i386 ATF qemu kernel has no audio"
14	fi
15	atf_check -s exit:0 -o not-empty -e ignore \
16		mixerctl
17}
18
19atf_test_case showvalue
20showvalue_head() {
21	atf_set "descr" "Ensure mixerctl(1) can print the value for all variables"
22}
23showvalue_body() {
24        if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1 &&
25	    test $(uname -m) = i386
26	then
27	    atf_skip "i386 ATF qemu kernel has no audio"
28	fi
29	for var in $(mixerctl -a | awk -F= '{print $1}'); do
30		atf_check -s exit:0 -e ignore -o match:"^${var}=" \
31			mixerctl ${var}
32	done
33}
34
35atf_test_case nflag
36nflag_head() {
37	atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output"
38}
39nflag_body() {
40        if sysctl machdep.cpu_brand 2>/dev/null | grep QEMU >/dev/null 2>&1 &&
41	    test $(uname -m) = i386
42	then
43	    atf_skip "i386 ATF qemu kernel has no audio"
44	fi
45	varname="$(mixerctl -a | sed -e 's/=.*//' -e q)"
46
47	atf_check -s exit:0 -o match:"${varname}" -e ignore \
48		mixerctl ${varname}
49
50	atf_check -s exit:0 -o not-match:"${varname}" -e ignore \
51		mixerctl -n ${varname}
52}
53
54atf_test_case nonexistant_device
55nonexistant_device_head() {
56	atf_set "descr" "Ensure mixerctl(1) complains if provided a nonexistant mixer device"
57}
58nonexistant_device_body() {
59	atf_check -s not-exit:0  -o ignore -e match:"No such file" \
60		mixerctl -d /a/b/c/d/e
61}
62
63atf_init_test_cases() {
64	atf_add_test_case noargs_usage
65	atf_add_test_case showvalue
66	atf_add_test_case nflag
67	atf_add_test_case nonexistant_device
68}
69