1# 2# SPDX-License-Identifier: BSD-2-Clause 3# 4# Copyright 2019 Yuri Pankov 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 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. 14# 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 25# SUCH DAMAGE. 26# 27# $FreeBSD$ 28 29atf_test_case k_flag_posix 30k_flag_posix_head() 31{ 32 atf_set "descr" \ 33 "Verify output of 'locale -k' for all POSIX specified keywords" 34} 35k_flag_posix_body() 36{ 37 export LC_ALL="C" 38 39 # LC_MONETARY 40 atf_check -o file:"$(atf_get_srcdir)/k_flag_posix_monetary.out" \ 41 locale -k \ 42 int_curr_symbol \ 43 currency_symbol \ 44 mon_decimal_point \ 45 mon_thousands_sep \ 46 mon_grouping \ 47 positive_sign \ 48 negative_sign \ 49 int_frac_digits \ 50 frac_digits \ 51 p_cs_precedes \ 52 p_sep_by_space \ 53 n_cs_precedes \ 54 n_sep_by_space \ 55 p_sign_posn \ 56 n_sign_posn \ 57 int_p_cs_precedes \ 58 int_n_cs_precedes \ 59 int_p_sep_by_space \ 60 int_n_sep_by_space \ 61 int_p_sign_posn \ 62 int_n_sign_posn 63 64 # LC_NUMERIC 65 atf_check -o file:"$(atf_get_srcdir)/k_flag_posix_numeric.out" \ 66 locale -k \ 67 decimal_point \ 68 thousands_sep \ 69 grouping 70 71 # LC_TIME 72 atf_check -o file:"$(atf_get_srcdir)/k_flag_posix_time.out" \ 73 locale -k \ 74 abday \ 75 day \ 76 abmon \ 77 mon \ 78 d_t_fmt \ 79 d_fmt \ 80 t_fmt \ 81 am_pm \ 82 t_fmt_ampm \ 83 era \ 84 era_d_fmt \ 85 era_t_fmt \ 86 era_d_t_fmt \ 87 alt_digits 88 89 # LC_MESSAGES 90 atf_check -o file:"$(atf_get_srcdir)/k_flag_posix_messages.out" \ 91 locale -k \ 92 yesexpr \ 93 noexpr 94} 95 96atf_test_case no_flags_posix 97no_flags_posix_head() 98{ 99 atf_set "descr" \ 100 "Verify output of 'locale' for all POSIX specified keywords" 101} 102no_flags_posix_body() 103{ 104 export LC_ALL="C" 105 106 # LC_MONETARY 107 atf_check -o file:"$(atf_get_srcdir)/no_flags_posix_monetary.out" \ 108 locale \ 109 int_curr_symbol \ 110 currency_symbol \ 111 mon_decimal_point \ 112 mon_thousands_sep \ 113 mon_grouping \ 114 positive_sign \ 115 negative_sign \ 116 int_frac_digits \ 117 frac_digits \ 118 p_cs_precedes \ 119 p_sep_by_space \ 120 n_cs_precedes \ 121 n_sep_by_space \ 122 p_sign_posn \ 123 n_sign_posn \ 124 int_p_cs_precedes \ 125 int_n_cs_precedes \ 126 int_p_sep_by_space \ 127 int_n_sep_by_space \ 128 int_p_sign_posn \ 129 int_n_sign_posn 130 131 # LC_NUMERIC 132 atf_check -o file:"$(atf_get_srcdir)/no_flags_posix_numeric.out" \ 133 locale \ 134 decimal_point \ 135 thousands_sep \ 136 grouping 137 138 # LC_TIME 139 atf_check -o file:"$(atf_get_srcdir)/no_flags_posix_time.out" \ 140 locale \ 141 abday \ 142 day \ 143 abmon \ 144 mon \ 145 d_t_fmt \ 146 d_fmt \ 147 t_fmt \ 148 am_pm \ 149 t_fmt_ampm \ 150 era \ 151 era_d_fmt \ 152 era_t_fmt \ 153 era_d_t_fmt \ 154 alt_digits 155 156 # LC_MESSAGES 157 atf_check -o file:"$(atf_get_srcdir)/no_flags_posix_messages.out" \ 158 locale \ 159 yesexpr \ 160 noexpr 161} 162 163atf_test_case k_flag_unknown_kw 164k_flag_unknown_kw_head() 165{ 166 atf_set "descr" \ 167 "Verify 'locale -k' exit status is '1' for unknown keywords" 168} 169k_flag_unknown_kw_body() 170{ 171 export LC_ALL="C" 172 173 # Hopefully the keyword will stay nonexistent 174 atf_check -s exit:1 -o empty -e ignore locale -k nonexistent 175} 176 177 178atf_init_test_cases() 179{ 180 atf_add_test_case k_flag_posix 181 atf_add_test_case no_flags_posix 182 atf_add_test_case k_flag_unknown_kw 183} 184