1*014404dbSAlan Somers# 2*014404dbSAlan Somers# Copyright 2017 Shivansh Rai 3*014404dbSAlan Somers# All rights reserved. 4*014404dbSAlan Somers# 5*014404dbSAlan Somers# Redistribution and use in source and binary forms, with or without 6*014404dbSAlan Somers# modification, are permitted provided that the following conditions 7*014404dbSAlan Somers# are met: 8*014404dbSAlan Somers# 1. Redistributions of source code must retain the above copyright 9*014404dbSAlan Somers# notice, this list of conditions and the following disclaimer. 10*014404dbSAlan Somers# 2. Redistributions in binary form must reproduce the above copyright 11*014404dbSAlan Somers# notice, this list of conditions and the following disclaimer in the 12*014404dbSAlan Somers# documentation and/or other materials provided with the distribution. 13*014404dbSAlan Somers# 14*014404dbSAlan Somers# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*014404dbSAlan Somers# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*014404dbSAlan Somers# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*014404dbSAlan Somers# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*014404dbSAlan Somers# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*014404dbSAlan Somers# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*014404dbSAlan Somers# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*014404dbSAlan Somers# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*014404dbSAlan Somers# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*014404dbSAlan Somers# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*014404dbSAlan Somers# SUCH DAMAGE. 25*014404dbSAlan Somers# 26*014404dbSAlan Somers# 27*014404dbSAlan Somers 28*014404dbSAlan Somersusage_output='usage: chflags' 29*014404dbSAlan Somers 30*014404dbSAlan Somersatf_test_case invalid_usage 31*014404dbSAlan Somersinvalid_usage_head() 32*014404dbSAlan Somers{ 33*014404dbSAlan Somers atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message" 34*014404dbSAlan Somers} 35*014404dbSAlan Somers 36*014404dbSAlan Somersinvalid_usage_body() 37*014404dbSAlan Somers{ 38*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -f 39*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -H 40*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -h 41*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -L 42*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -P 43*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -R 44*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags -v 45*014404dbSAlan Somers} 46*014404dbSAlan Somers 47*014404dbSAlan Somersatf_test_case no_arguments 48*014404dbSAlan Somersno_arguments_head() 49*014404dbSAlan Somers{ 50*014404dbSAlan Somers atf_set "descr" "Verify that chflags(1) fails and generates a valid usage message when no arguments are supplied" 51*014404dbSAlan Somers} 52*014404dbSAlan Somers 53*014404dbSAlan Somersno_arguments_body() 54*014404dbSAlan Somers{ 55*014404dbSAlan Somers atf_check -s not-exit:0 -e match:"$usage_output" chflags 56*014404dbSAlan Somers} 57*014404dbSAlan Somers 58*014404dbSAlan Somersatf_init_test_cases() 59*014404dbSAlan Somers{ 60*014404dbSAlan Somers atf_add_test_case invalid_usage 61*014404dbSAlan Somers atf_add_test_case no_arguments 62*014404dbSAlan Somers} 63