1*63d1fd59SEnji Cooper# $NetBSD: t_mixerctl.sh,v 1.1 2017/01/02 15:40:09 christos Exp $ 2*63d1fd59SEnji Cooper 3*63d1fd59SEnji Cooperatf_test_case noargs_usage 4*63d1fd59SEnji Coopernoargs_usage_head() { 5*63d1fd59SEnji Cooper atf_set "descr" "Ensure mixerctl(1) with no args prints a usage message" 6*63d1fd59SEnji Cooper} 7*63d1fd59SEnji Coopernoargs_usage_body() { 8*63d1fd59SEnji Cooper atf_check -s exit:0 -o not-empty -e ignore \ 9*63d1fd59SEnji Cooper mixerctl 10*63d1fd59SEnji Cooper} 11*63d1fd59SEnji Cooper 12*63d1fd59SEnji Cooperatf_test_case showvalue 13*63d1fd59SEnji Coopershowvalue_head() { 14*63d1fd59SEnji Cooper atf_set "descr" "Ensure mixerctl(1) can print the value for all variables" 15*63d1fd59SEnji Cooper} 16*63d1fd59SEnji Coopershowvalue_body() { 17*63d1fd59SEnji Cooper for var in $(mixerctl -a | awk -F= '{print $1}'); do 18*63d1fd59SEnji Cooper atf_check -s exit:0 -e ignore -o match:"^${var}=" \ 19*63d1fd59SEnji Cooper mixerctl ${var} 20*63d1fd59SEnji Cooper done 21*63d1fd59SEnji Cooper} 22*63d1fd59SEnji Cooper 23*63d1fd59SEnji Cooperatf_test_case nflag 24*63d1fd59SEnji Coopernflag_head() { 25*63d1fd59SEnji Cooper atf_set "descr" "Ensure 'mixerctl -n' actually suppresses some output" 26*63d1fd59SEnji Cooper} 27*63d1fd59SEnji Coopernflag_body() { 28*63d1fd59SEnji Cooper varname="$(mixerctl -a | head -1 | awk -F= '{print $1}')" 29*63d1fd59SEnji Cooper 30*63d1fd59SEnji Cooper atf_check -s exit:0 -o match:"${varname}" -e ignore \ 31*63d1fd59SEnji Cooper mixerctl ${varname} 32*63d1fd59SEnji Cooper 33*63d1fd59SEnji Cooper atf_check -s exit:0 -o not-match:"${varname}" -e ignore \ 34*63d1fd59SEnji Cooper mixerctl -n ${varname} 35*63d1fd59SEnji Cooper} 36*63d1fd59SEnji Cooper 37*63d1fd59SEnji Cooperatf_test_case nonexistant_device 38*63d1fd59SEnji Coopernonexistant_device_head() { 39*63d1fd59SEnji Cooper atf_set "descr" "Ensure mixerctl(1) complains if provided a nonexistant mixer device" 40*63d1fd59SEnji Cooper} 41*63d1fd59SEnji Coopernonexistant_device_body() { 42*63d1fd59SEnji Cooper atf_check -s not-exit:0 -o ignore -e match:"No such file" \ 43*63d1fd59SEnji Cooper mixerctl -d /a/b/c/d/e 44*63d1fd59SEnji Cooper} 45*63d1fd59SEnji Cooper 46*63d1fd59SEnji Cooperatf_init_test_cases() { 47*63d1fd59SEnji Cooper atf_add_test_case noargs_usage 48*63d1fd59SEnji Cooper atf_add_test_case showvalue 49*63d1fd59SEnji Cooper atf_add_test_case nflag 50*63d1fd59SEnji Cooper atf_add_test_case nonexistant_device 51*63d1fd59SEnji Cooper} 52