1# 2# Copyright (c) 2017 Dell EMC 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions 7# are met: 8# 1. Redistributions of source code must retain the above copyright 9# notice, this list of conditions and the following disclaimer. 10# 2. Redistributions in binary form must reproduce the above copyright 11# notice, this list of conditions and the following disclaimer in the 12# documentation and/or other materials provided with the distribution. 13# 14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24# SUCH DAMAGE. 25# 26# $FreeBSD$ 27 28POSITIVE_EXP_EXPR_RE='match:[1-9][0-9]*' 29 30POSIX_CONSTANTS="ARG_MAX PAGESIZE" 31POSIX_PATH_CONSTANTS="NAME_MAX PATH_MAX" 32SUPPORTED_32BIT_PROGRAM_ENVS="POSIX_V6_ILP32_OFFBIG" 33SUPPORTED_64BIT_PROGRAM_ENVS="POSIX_V6_LP64_OFF64" 34UNAVAILABLE_PROGRAM_ENVS="I_AM_BOGUS" 35UNSUPPORTED_32BIT_PROGRAM_ENVS="POSIX_V6_LP64_OFF64" 36UNSUPPORTED_64BIT_PROGRAM_ENVS="POSIX_V6_ILP32_OFFBIG" 37 38XOPEN_CONSTANTS= 39 40# XXX: hardcoded sysexits 41EX_USAGE=64 42EX_UNAVAILABLE=69 43 44set_program_environments() 45{ 46 atf_check -o save:arch_type.out $(atf_get_srcdir)/arch_type 47 arch_type=$(cat arch_type.out) 48 case "$arch_type" in 49 ILP32|LP32) 50 SUPPORTED_PROGRAM_ENVS="$SUPPORTED_PROGRAM_ENVS $SUPPORTED_32BIT_PROGRAM_ENVS" 51 UNSUPPORTED_PROGRAM_ENVS="$UNSUPPORTED_PROGRAM_ENVS $UNSUPPORTED_32BIT_PROGRAM_ENVS" 52 ;; 53 LP64) 54 SUPPORTED_PROGRAM_ENVS="$SUPPORTED_PROGRAM_ENVS $SUPPORTED_64BIT_PROGRAM_ENVS" 55 UNSUPPORTED_PROGRAM_ENVS="$UNSUPPORTED_PROGRAM_ENVS $UNSUPPORTED_64BIT_PROGRAM_ENVS" 56 ;; 57 *) 58 atf_fail "arch_type output unexpected: $arch_type" 59 ;; 60 esac 61} 62 63atf_test_case no_programming_environment 64no_programming_environment_head() 65{ 66 atf_set "descr" "Test some POSIX constants as a positive functional test" 67} 68 69no_programming_environment_body() 70{ 71 for var in $POSIX_CONSTANTS; do 72 atf_check -o "$POSITIVE_EXP_EXPR_RE" getconf $var 73 done 74 for var in $POSIX_PATH_CONSTANTS; do 75 atf_check -o "$POSITIVE_EXP_EXPR_RE" getconf $var . 76 done 77} 78 79atf_test_case programming_environment 80programming_environment_head() 81{ 82 atf_set "descr" "Test some constants with specific programming environments" 83} 84 85programming_environment_body() 86{ 87 set_program_environments 88 89 for prog_env in ${SUPPORTED_PROGRAM_ENVS}; do 90 for var in $POSIX_CONSTANTS; do 91 atf_check -o "$POSITIVE_EXP_EXPR_RE" \ 92 getconf -v $prog_env $var 93 done 94 done 95} 96 97atf_test_case programming_environment_unsupported 98programming_environment_unsupported_head() 99{ 100 atf_set "descr" "Test for unsupported environments" 101} 102 103programming_environment_unsupported_body() 104{ 105 set_program_environments 106 107 for prog_env in ${UNSUPPORTED_PROGRAM_ENVS}; do 108 for var in $POSIX_CONSTANTS; do 109 atf_check -e not-empty -s exit:$EX_UNAVAILABLE \ 110 getconf -v $prog_env $var 111 done 112 done 113} 114 115atf_init_test_cases() 116{ 117 atf_add_test_case no_programming_environment 118 atf_add_test_case programming_environment 119 atf_add_test_case programming_environment_unsupported 120} 121