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