2 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 # Copyright (c) 2019 Mateusz Piotrowski <0mp@FreeBSD.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 ! { mixer && mixer vol; } >/dev/null 2>&1
36 atf_check -o match:'^[0-9]{1,3}:[0-9]{1,3}$' -o save:saved_vol \
37 -x "mixer vol | awk '{print \$7}'"
43 -o match:'^Setting the mixer vol from [0-9]{1,3}:[0-9]{1,3} to 0:0\.$' \
49 if [ -r "saved_vol" ]; then
50 mixer vol "$(cat saved_vol)"
54 atf_test_case s_flag cleanup
57 atf_set "descr" "Verify that the output of the -s flag could be " \
58 "reused as command-line arguments to the mixer command"
62 if mixer_unavailable; then
63 atf_skip "This test requires mixer support"
67 atf_check -o inline:"vol 0:0" -o save:values mixer -s vol
68 atf_check -o inline:"Setting the mixer vol from 0:0 to 0:0.\n" \
76 atf_test_case S_flag cleanup
79 atf_set "descr" "Verify that the output of the -S flag is " \
80 "matching the documented behavior"
84 if mixer_unavailable; then
85 atf_skip "This test requires mixer support"
89 atf_check -o inline:"vol:0:0" mixer -S vol
96 atf_test_case set_empty_value cleanup
97 set_empty_value_head()
99 atf_set "descr" "Verify that mixer returns when the provided " \
100 "value to set is an empty string instead of a number"
101 atf_set "timeout" "1"
103 set_empty_value_body()
105 if mixer_unavailable; then
106 atf_skip "This test requires mixer support"
109 atf_check -s exit:1 -e inline:"mixer: invalid value: \n" \
110 -o match:"^usage:" mixer vol ""
112 set_empty_value_cleanup()
118 atf_init_test_cases()
120 atf_add_test_case s_flag
121 atf_add_test_case S_flag
122 atf_add_test_case set_empty_value