xref: /freebsd/contrib/netbsd-tests/usr.bin/mixerctl/t_mixerctl.sh (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1# $NetBSD: t_mixerctl.sh,v 1.1 2017/01/02 15:40:09 christos 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	atf_check -s exit:0 -o not-empty -e ignore \
9		mixerctl
10}
11
12atf_test_case showvalue
13showvalue_head() {
14	atf_set "descr" "Ensure mixerctl(1) can print the value for all variables"
15}
16showvalue_body() {
17	for var in $(mixerctl -a | awk -F= '{print $1}'); do
18		atf_check -s exit:0 -e ignore -o match:"^${var}=" \
19			mixerctl ${var}
20	done
21}
22
23atf_test_case nflag
24nflag_head() {
25	atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output"
26}
27nflag_body() {
28	varname="$(mixerctl -a | head -1 | awk -F= '{print $1}')"
29
30	atf_check -s exit:0 -o match:"${varname}" -e ignore \
31		mixerctl ${varname}
32
33	atf_check -s exit:0 -o not-match:"${varname}" -e ignore \
34		mixerctl -n ${varname}
35}
36
37atf_test_case nonexistant_device
38nonexistant_device_head() {
39	atf_set "descr" "Ensure mixerctl(1) complains if provided a nonexistant mixer device"
40}
41nonexistant_device_body() {
42	atf_check -s not-exit:0  -o ignore -e match:"No such file" \
43		mixerctl -d /a/b/c/d/e
44}
45
46atf_init_test_cases() {
47	atf_add_test_case noargs_usage
48	atf_add_test_case showvalue
49	atf_add_test_case nflag
50	atf_add_test_case nonexistant_device
51}
52