Home | History | Annotate | Line # | Download | only in mixerctl
t_mixerctl.sh revision 1.6
      1  1.6       nat # $NetBSD: t_mixerctl.sh,v 1.6 2017/07/03 09:08:35 nat Exp $
      2  1.1  christos 
      3  1.1  christos atf_test_case noargs_usage
      4  1.1  christos noargs_usage_head() {
      5  1.1  christos 	atf_set "descr" "Ensure mixerctl(1) with no args prints a usage message"
      6  1.1  christos }
      7  1.1  christos noargs_usage_body() {
      8  1.6       nat 	cat /dev/pad0 > /dev/null 2>&1 &
      9  1.6       nat 	padpid=$!
     10  1.6       nat 
     11  1.1  christos 	atf_check -s exit:0 -o not-empty -e ignore \
     12  1.1  christos 		mixerctl
     13  1.6       nat 
     14  1.6       nat 	kill -HUP ${padpid} 2>/dev/null
     15  1.1  christos }
     16  1.1  christos 
     17  1.1  christos atf_test_case showvalue
     18  1.1  christos showvalue_head() {
     19  1.1  christos 	atf_set "descr" "Ensure mixerctl(1) can print the value for all variables"
     20  1.1  christos }
     21  1.1  christos showvalue_body() {
     22  1.5       kre 	cat /dev/pad0 > /dev/null 2>&1 &
     23  1.5       kre 	padpid=$!
     24  1.5       kre 
     25  1.4       kre 	(</dev/mixer) >/dev/null 2>&1 ||
     26  1.4       kre 	    atf_skip "no audio mixer available in kernel"
     27  1.4       kre 
     28  1.1  christos 	for var in $(mixerctl -a | awk -F= '{print $1}'); do
     29  1.1  christos 		atf_check -s exit:0 -e ignore -o match:"^${var}=" \
     30  1.1  christos 			mixerctl ${var}
     31  1.1  christos 	done
     32  1.5       kre 
     33  1.5       kre 	kill -HUP ${padpid} 2>/dev/null		# may have exited already
     34  1.1  christos }
     35  1.1  christos 
     36  1.1  christos atf_test_case nflag
     37  1.1  christos nflag_head() {
     38  1.1  christos 	atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output"
     39  1.1  christos }
     40  1.1  christos nflag_body() {
     41  1.5       kre 	cat /dev/pad0 > /dev/null 2>&1 &
     42  1.5       kre 	padpid=$!
     43  1.5       kre 
     44  1.4       kre 	(</dev/mixer) >/dev/null 2>&1 ||
     45  1.4       kre 	    atf_skip "no audio mixer available in kernel"
     46  1.4       kre 
     47  1.2       kre 	varname="$(mixerctl -a | sed -e 's/=.*//' -e q)"
     48  1.1  christos 
     49  1.1  christos 	atf_check -s exit:0 -o match:"${varname}" -e ignore \
     50  1.1  christos 		mixerctl ${varname}
     51  1.1  christos 
     52  1.1  christos 	atf_check -s exit:0 -o not-match:"${varname}" -e ignore \
     53  1.1  christos 		mixerctl -n ${varname}
     54  1.5       kre 
     55  1.5       kre 	kill -HUP ${padpid} 2>/dev/null
     56  1.1  christos }
     57  1.1  christos 
     58  1.1  christos atf_test_case nonexistant_device
     59  1.1  christos nonexistant_device_head() {
     60  1.1  christos 	atf_set "descr" "Ensure mixerctl(1) complains if provided a nonexistant mixer device"
     61  1.1  christos }
     62  1.1  christos nonexistant_device_body() {
     63  1.1  christos 	atf_check -s not-exit:0  -o ignore -e match:"No such file" \
     64  1.4       kre 		mixerctl -a -d /a/b/c/d/e
     65  1.1  christos }
     66  1.1  christos 
     67  1.1  christos atf_init_test_cases() {
     68  1.1  christos 	atf_add_test_case noargs_usage
     69  1.1  christos 	atf_add_test_case showvalue
     70  1.1  christos 	atf_add_test_case nflag
     71  1.1  christos 	atf_add_test_case nonexistant_device
     72  1.1  christos }
     73