1# Copyright (c) 2022 Yoshihiro Ota <ota@j.email.ne.jp> 2# 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions 5# are met: 6# 1. Redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer. 8# 2. Redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution. 11# 12# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 13# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 15# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 16# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 18# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 19# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 20# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22# SUCH DAMAGE. 23 24sysctl_name="kern.ostype" 25sysctl_value="FreeBSD" 26sysctl_type="string" 27sysctl_description="Operating system type" 28 29atf_test_case sysctl_by_name 30sysctl_by_name_head() 31{ 32 atf_set "descr" "Verify name without any arguments" 33} 34sysctl_by_name_body() 35{ 36 atf_check -o "inline:${sysctl_name}: ${sysctl_value}\n" sysctl ${sysctl_name} 37} 38 39 40atf_test_case sysctl_nflag 41sysctl_nflag_head() 42{ 43 atf_set "descr" "Verify -n argument" 44} 45sysctl_nflag_body() 46{ 47 atf_check -o "inline:${sysctl_value}\n" sysctl -n ${sysctl_name} 48} 49 50 51atf_test_case sysctl_eflag 52sysctl_eflag_head() 53{ 54 atf_set "descr" "Verify -e argument" 55} 56sysctl_eflag_body() 57{ 58 atf_check -o "inline:${sysctl_name}=${sysctl_value}\n" sysctl -e ${sysctl_name} 59} 60 61 62atf_test_case sysctl_tflag 63sysctl_tflag_head() 64{ 65 atf_set "descr" "Verify -t argument" 66} 67sysctl_tflag_body() 68{ 69 atf_check -o "inline:${sysctl_name}: ${sysctl_type}\n" sysctl -t ${sysctl_name} 70} 71 72 73atf_test_case sysctl_dflag 74sysctl_dflag_head() 75{ 76 atf_set "descr" "Verify -d argument" 77} 78sysctl_dflag_body() 79{ 80 atf_check -o "inline:${sysctl_name}: ${sysctl_description}\n" sysctl -d ${sysctl_name} 81} 82 83 84atf_test_case sysctl_tflag_dflag 85sysctl_tflag_dflag_head() 86{ 87 atf_set "descr" "Verify -t -d arguments" 88} 89sysctl_tflag_dflag_body() 90{ 91 atf_check -o "inline:${sysctl_name}: ${sysctl_type}: ${sysctl_description}\n" sysctl -t -d ${sysctl_name} 92 atf_check -o "inline:${sysctl_name}: ${sysctl_type}: ${sysctl_description}\n" sysctl -d -t ${sysctl_name} 93} 94 95 96atf_test_case sysctl_nflag_tflag_dflag 97sysctl_nflag_tflag_dflag_head() 98{ 99 atf_set "descr" "Verify -n -t -d arguments" 100} 101sysctl_nflag_tflag_dflag_body() 102{ 103 atf_check -o "inline:${sysctl_type}: ${sysctl_description}\n" sysctl -n -t -d ${sysctl_name} 104} 105 106 107atf_init_test_cases() 108{ 109 atf_add_test_case sysctl_by_name 110 atf_add_test_case sysctl_nflag 111 atf_add_test_case sysctl_eflag 112 atf_add_test_case sysctl_tflag 113 atf_add_test_case sysctl_dflag 114 atf_add_test_case sysctl_tflag_dflag 115 atf_add_test_case sysctl_nflag_tflag_dflag 116} 117