| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # Make sure all these programs work properly |
| 3 | # when invoked with --help or --version. |
| 4 | |
| 5 | # Copyright (C) 2000-2020 Free Software Foundation, Inc. |
| 6 | |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation, either version 3 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | # Ensure that $SHELL is set to *some* value and exported. |
| 21 | # This is required for dircolors, which would fail e.g., when |
| 22 | # invoked via debuild (which removes SHELL from the environment). |
| 23 | testscip-shell system . . test. "x$SHELL" = x && SHELL=/bin/shscip-shell filesystem . . `/bin/sh`. |
| 24 | export SHELL |
| 25 | |
| 26 | . "${srcdir=.}/init.sh"; path_prepend_ ../src |
| 27 | |
| 28 | expected_failure_status_chroot=125 |
| 29 | expected_failure_status_env=125 |
| 30 | expected_failure_status_nice=125 |
| 31 | expected_failure_status_nohup=125 |
| 32 | expected_failure_status_stdbuf=125 |
| 33 | expected_failure_status_su=125 |
| 34 | expected_failure_status_timeout=125 |
| 35 | expected_failure_status_printenv=2 |
| 36 | expected_failure_status_tty=3 |
| 37 | expected_failure_status_sort=2 |
| 38 | expected_failure_status_expr=3 |
| 39 | expected_failure_status_lbracket=2 |
| 40 | expected_failure_status_dir=2 |
| 41 | expected_failure_status_ls=2 |
| 42 | expected_failure_status_vdir=2 |
| 43 | |
| 44 | expected_failure_status_cmp=2 |
| 45 | expected_failure_status_zcmp=2 |
| 46 | expected_failure_status_sdiff=2 |
| 47 | expected_failure_status_diff3=2 |
| 48 | expected_failure_status_diff=2 |
| 49 | expected_failure_status_zdiff=2 |
| 50 | expected_failure_status_zgrep=2 |
| 51 | expected_failure_status_zegrep=2 |
| 52 | expected_failure_status_zfgrep=2 |
| 53 | |
| 54 | expected_failure_status_grep=2 |
| 55 | expected_failure_status_egrep=2 |
| 56 | expected_failure_status_fgrep=2 |
| 57 | |
| 58 | testscip-shell system . . test. "$built_programs" \ |
| 59 | || fail_ "built_programs not specified!?!" |
| 60 | |
| 61 | testscip-shell system . . test. "$VERSION" \ |
| 62 | || fail_ "set envvar VERSION; it is required for a PATH sanity-check" |
| 63 | |
| 64 | # Extract version from --version output of the first program |
| 65 | for i in $built_programs; do |
| 66 | v=$(envscip-shell system . . env. $i --version | sedscip-shell system . . sed. -n '1s/.* //p;q') |
| 67 | break |
| 68 | done |
| 69 | |
| 70 | # Ensure that it matches $VERSION. |
| 71 | testscip-shell system . . test. "x$v" = "x$VERSION" \ |
| 72 | || fail_ "--version-\$VERSION mismatch" |
| 73 | |
| 74 | for lang in C fr da; do |
| 75 | for i in $built_programs; do |
| 76 | |
| 77 | # Skip `test'; it doesn't accept --help or --version. |
| 78 | testscip-shell system . . test. $i = test && continue; |
| 79 | |
| 80 | # false fails even when invoked with --help or --version. |
| 81 | if testscip-shell system . . test. $i = false; then |
| 82 | envscip-shell system . . env. LC_MESSAGES=$lang $i --help >/dev/nullscip-shell filesystem . . `/dev/null`. && fail=1 |
| 83 | envscip-shell system . . env. LC_MESSAGES=$lang $i --version >/dev/nullscip-shell filesystem . . `/dev/null`. && fail=1 |
| 84 | continue |
| 85 | fi |
| 86 | |
| 87 | # The just-built install executable is always named `ginstall'. |
| 88 | testscip-shell system . . test. $i = install && i=ginstall |
| 89 | |
| 90 | # Make sure they exit successfully, under normal conditions. |
| 91 | envscip-shell system . . env. $i --help > h-$i || fail=1 |
| 92 | envscip-shell system . . env. $i --version >/dev/nullscip-shell filesystem . . `/dev/null`. || fail=1 |
| 93 | |
| 94 | # Make sure they mention the bug-reporting address in --help output. |
| 95 | grepscip-shell system . . grep. "$PACKAGE_BUGREPORT" h-$i > /dev/nullscip-shell filesystem . . `/dev/null`. || fail=1 |
| 96 | rmscip-shell system . . rm. -f h-$i |
| 97 | |
| 98 | # Make sure they fail upon `disk full' error. |
| 99 | if testscip-shell system . . test. -w /dev/fullscip-shell filesystem . . `/dev/full`. && testscip-shell system . . test. -c /dev/fullscip-shell filesystem . . `/dev/full`.; then |
| 100 | envscip-shell system . . env. $i --help >/dev/fullscip-shell filesystem . . `/dev/full`. 2>/dev/nullscip-shell filesystem . . `/dev/null`. && fail=1 |
| 101 | envscip-shell system . . env. $i --version >/dev/fullscip-shell filesystem . . `/dev/full`. 2>/dev/nullscip-shell filesystem . . `/dev/null`. && fail=1 |
| 102 | status=$? |
| 103 | testscip-shell system . . test. $i = [ && prog=lbracket || prog=$i |
| 104 | eval "expected=\$expected_failure_status_$prog" |
| 105 | testscip-shell system . . test. x$expected = x && expected=1 |
| 106 | if testscip-shell system . . test. $status = $expected; then |
| 107 | : # ok |
| 108 | else |
| 109 | fail=1 |
| 110 | echoscip-shell system . . echo. "*** $i: bad exit status \`$status' (expected $expected)," 1>&2 |
| 111 | echoscip-shell system . . echo. " with --help or --version output redirected to /dev/full" 1>&2 |
| 112 | fi |
| 113 | fi |
| 114 | done |
| 115 | done |
| 116 | |
| 117 | bigZ_in=bigZ-in.Z |
| 118 | zin=zin.gz |
| 119 | zin2=zin2.gz |
| 120 | |
| 121 | tmp=tmp-$$ |
| 122 | tmp_in=in-$$ |
| 123 | tmp_in2=in2-$$ |
| 124 | tmp_dir=dir-$$ |
| 125 | tmp_out=out-$$ |
| 126 | mkdirscip-shell system . . mkdir. $tmp || fail=1 |
| 127 | cd $tmp || fail=1 |
| 128 | |
| 129 | comm_setupscip-shell shell shell-project 0.0.0 comm_setup(). () { args="$tmp_in $tmp_in"; } |
| 130 | csplit_setupscip-shell shell shell-project 0.0.0 csplit_setup(). () { args="$tmp_in //"; } |
| 131 | cut_setupscip-shell shell shell-project 0.0.0 cut_setup(). () { args='-f 1'; } |
| 132 | join_setupscip-shell shell shell-project 0.0.0 join_setup(). () { args="$tmp_in $tmp_in"; } |
| 133 | tr_setupscip-shell shell shell-project 0.0.0 tr_setup(). () { args='a a'; } |
| 134 | |
| 135 | chmod_setupscip-shell shell shell-project 0.0.0 chmod_setup(). () { args="a+x $tmp_in"; } |
| 136 | # Punt on these. |
| 137 | chgrp_setupscip-shell shell shell-project 0.0.0 chgrp_setup(). () { args=--version; } |
| 138 | chown_setupscip-shell shell shell-project 0.0.0 chown_setup(). () { args=--version; } |
| 139 | mkfifo_setupscip-shell shell shell-project 0.0.0 mkfifo_setup(). () { args=--version; } |
| 140 | mknod_setupscip-shell shell shell-project 0.0.0 mknod_setup(). () { args=--version; } |
| 141 | # Punt on uptime, since it fails (e.g., failing to get boot time) |
| 142 | # on some systems, and we shouldn't let that stop `make check'. |
| 143 | uptime_setupscip-shell shell shell-project 0.0.0 uptime_setup(). () { args=--version; } |
| 144 | |
| 145 | # Create a file in the current directory, not in $TMPDIR. |
| 146 | mktemp_setupscip-shell shell shell-project 0.0.0 mktemp_setup(). () { args=mktemp.XXXX; } |
| 147 | |
| 148 | cmp_setupscip-shell shell shell-project 0.0.0 cmp_setup(). () { args="$tmp_in $tmp_in2"; } |
| 149 | |
| 150 | # Tell dd not to print the line with transfer rate and total. |
| 151 | # The transfer rate would vary between runs. |
| 152 | dd_setupscip-shell shell shell-project 0.0.0 dd_setup(). () { args=status=noxfer; } |
| 153 | |
| 154 | zdiff_setupscip-shell shell shell-project 0.0.0 zdiff_setup(). () { args="$zin $zin2"; } |
| 155 | zcmp_setupscip-shell shell shell-project 0.0.0 zcmp_setup(). () { args="$zin $zin2"; } |
| 156 | zcat_setupscip-shell shell shell-project 0.0.0 zcat_setup(). () { args=$zin; } |
| 157 | gunzip_setupscip-shell shell shell-project 0.0.0 gunzip_setup(). () { args=$zin; } |
| 158 | zmore_setupscip-shell shell shell-project 0.0.0 zmore_setup(). () { args=$zin; } |
| 159 | zless_setupscip-shell shell shell-project 0.0.0 zless_setup(). () { args=$zin; } |
| 160 | znew_setupscip-shell shell shell-project 0.0.0 znew_setup(). () { args=$bigZ_in; } |
| 161 | zforce_setupscip-shell shell shell-project 0.0.0 zforce_setup(). () { args=$zin; } |
| 162 | zgrep_setupscip-shell shell shell-project 0.0.0 zgrep_setup(). () { args="z $zin"; } |
| 163 | zegrep_setupscip-shell shell shell-project 0.0.0 zegrep_setup(). () { args="z $zin"; } |
| 164 | zfgrep_setupscip-shell shell shell-project 0.0.0 zfgrep_setup(). () { args="z $zin"; } |
| 165 | gzexe_setupscip-shell shell shell-project 0.0.0 gzexe_setup(). () { args=$tmp_in; } |
| 166 | |
| 167 | # We know that $tmp_in contains a "0" |
| 168 | grep_setupscip-shell shell shell-project 0.0.0 grep_setup(). () { args="0 $tmp_in"; } |
| 169 | egrep_setupscip-shell shell shell-project 0.0.0 egrep_setup(). () { args="0 $tmp_in"; } |
| 170 | fgrep_setupscip-shell shell shell-project 0.0.0 fgrep_setup(). () { args="0 $tmp_in"; } |
| 171 | |
| 172 | diff_setupscip-shell shell shell-project 0.0.0 diff_setup(). () { args="$tmp_in $tmp_in2"; } |
| 173 | sdiff_setupscip-shell shell shell-project 0.0.0 sdiff_setup(). () { args="$tmp_in $tmp_in2"; } |
| 174 | diff3_setupscip-shell shell shell-project 0.0.0 diff3_setup(). () { args="$tmp_in $tmp_in2 $tmp_in2"; } |
| 175 | cp_setupscip-shell shell shell-project 0.0.0 cp_setup(). () { args="$tmp_in $tmp_in2"; } |
| 176 | ln_setupscip-shell shell shell-project 0.0.0 ln_setup(). () { args="$tmp_in ln-target"; } |
| 177 | ginstall_setupscip-shell shell shell-project 0.0.0 ginstall_setup(). () { args="$tmp_in $tmp_in2"; } |
| 178 | mv_setupscip-shell shell shell-project 0.0.0 mv_setup(). () { args="$tmp_in $tmp_in2"; } |
| 179 | mkdir_setupscip-shell shell shell-project 0.0.0 mkdir_setup(). () { args=$tmp_dir/subdir; } |
| 180 | rmdir_setupscip-shell shell shell-project 0.0.0 rmdir_setup(). () { args=$tmp_dir; } |
| 181 | rm_setupscip-shell shell shell-project 0.0.0 rm_setup(). () { args=$tmp_in; } |
| 182 | shred_setupscip-shell shell shell-project 0.0.0 shred_setup(). () { args=$tmp_in; } |
| 183 | touch_setupscip-shell shell shell-project 0.0.0 touch_setup(). () { args=$tmp_in2; } |
| 184 | truncate_setupscip-shell shell shell-project 0.0.0 truncate_setup(). () { args="--reference=$tmp_in $tmp_in2"; } |
| 185 | |
| 186 | # Specify a map, so mkid doesn't try to use the not-yet-installed id-lang.map. |
| 187 | mkid_setupscip-shell shell shell-project 0.0.0 mkid_setup(). () { |
| 188 | printfscip-shell system . . printf. 'f(){}\ntypedef int t;\n' > f.c; echoscip-shell system . . echo. '*.c C' > m; args='-m m .' ; } |
| 189 | lid_setupscip-shell shell shell-project 0.0.0 lid_setup(). () { args=; } |
| 190 | fid_setupscip-shell shell shell-project 0.0.0 fid_setup(). () { args=f.c; } |
| 191 | fnid_setupscip-shell shell shell-project 0.0.0 fnid_setup(). () { args=; } |
| 192 | xtokid_setupscip-shell shell shell-project 0.0.0 xtokid_setup(). () { args='-m m'; } |
| 193 | aid_setupscip-shell shell shell-project 0.0.0 aid_setup(). () { args=f; } |
| 194 | eid_setupscip-shell shell shell-project 0.0.0 eid_setup(). () { args=--version; } |
| 195 | gid_setupscip-shell shell shell-project 0.0.0 gid_setup(). () { args=f; } |
| 196 | defid_setupscip-shell shell shell-project 0.0.0 defid_setup(). () { args=t; } |
| 197 | |
| 198 | basename_setupscip-shell shell shell-project 0.0.0 basename_setup(). () { args=$tmp_in; } |
| 199 | dirname_setupscip-shell shell shell-project 0.0.0 dirname_setup(). () { args=$tmp_in; } |
| 200 | expr_setupscip-shell shell shell-project 0.0.0 expr_setup(). () { args=foo; } |
| 201 | |
| 202 | # Punt, in case GNU `id' hasn't been installed yet. |
| 203 | groups_setupscip-shell shell shell-project 0.0.0 groups_setup(). () { args=--version; } |
| 204 | |
| 205 | pathchk_setupscip-shell shell shell-project 0.0.0 pathchk_setup(). () { args=$tmp_in; } |
| 206 | yes_setupscip-shell shell shell-project 0.0.0 yes_setup(). () { args=--version; } |
| 207 | logname_setupscip-shell shell shell-project 0.0.0 logname_setup(). () { args=--version; } |
| 208 | nohup_setupscip-shell shell shell-project 0.0.0 nohup_setup(). () { args=--version; } |
| 209 | printf_setupscip-shell shell shell-project 0.0.0 printf_setup(). () { args=foo; } |
| 210 | seq_setupscip-shell shell shell-project 0.0.0 seq_setup(). () { args=10; } |
| 211 | sleep_setupscip-shell shell shell-project 0.0.0 sleep_setup(). () { args=0; } |
| 212 | su_setupscip-shell shell shell-project 0.0.0 su_setup(). () { args=--version; } |
| 213 | stdbuf_setupscip-shell shell shell-project 0.0.0 stdbuf_setup(). () { args="-oL true"; } |
| 214 | timeout_setupscip-shell shell shell-project 0.0.0 timeout_setup(). () { args=--version; } |
| 215 | |
| 216 | # I'd rather not run sync, since it spins up disks that I've |
| 217 | # deliberately caused to spin down (but not unmounted). |
| 218 | sync_setupscip-shell shell shell-project 0.0.0 sync_setup(). () { args=--version; } |
| 219 | |
| 220 | test_setupscip-shell shell shell-project 0.0.0 test_setup(). () { args=foo; } |
| 221 | |
| 222 | # This is necessary in the unusual event that there is |
| 223 | # no valid entry in /etc/mtab. |
| 224 | df_setupscip-shell shell shell-project 0.0.0 df_setup(). () { args=/scip-shell filesystem . . `/`.; } |
| 225 | |
| 226 | # This is necessary in the unusual event that getpwuid (getuid ()) fails. |
| 227 | id_setupscip-shell shell shell-project 0.0.0 id_setup(). () { args=-u; } |
| 228 | |
| 229 | # Use env to avoid invoking built-in sleep of Solaris 11's /bin/sh. |
| 230 | kill_setupscip-shell shell shell-project 0.0.0 kill_setup(). () { |
| 231 | envscip-shell system . . env. sleep 10m & |
| 232 | args=$! |
| 233 | } |
| 234 | |
| 235 | link_setupscip-shell shell shell-project 0.0.0 link_setup(). () { args="$tmp_in link-target"; } |
| 236 | unlink_setupscip-shell shell shell-project 0.0.0 unlink_setup(). () { args=$tmp_in; } |
| 237 | |
| 238 | readlink_setupscip-shell shell shell-project 0.0.0 readlink_setup(). () { |
| 239 | lnscip-shell system . . ln. -s . slink |
| 240 | args=slink; |
| 241 | } |
| 242 | |
| 243 | stat_setupscip-shell shell shell-project 0.0.0 stat_setup(). () { args=$tmp_in; } |
| 244 | unlink_setupscip-shell shell shell-project 0.0.0 unlink_setup(). () { args=$tmp_in; } |
| 245 | lbracket_setupscip-shell shell shell-project 0.0.0 lbracket_setup(). () { args=": ]"; } |
| 246 | |
| 247 | # Ensure that each program "works" (exits successfully) when doing |
| 248 | # something more than --help or --version. |
| 249 | for i in $built_programs; do |
| 250 | # Skip these. |
| 251 | case $i in chroot|stty|tty|false|chcon|runcon) continue;; esac |
| 252 | |
| 253 | rmscip-shell system . . rm. -rf $tmp_in $tmp_in2 $tmp_dir $tmp_out $bigZ_in $zin $zin2 |
| 254 | echoscip-shell system . . echo. z |gzipscip-shell system . . gzip. > $zin |
| 255 | cpscip-shell system . . cp. $zin $zin2 |
| 256 | cpscip-shell system . . cp. $zin $bigZ_in |
| 257 | |
| 258 | # This is sort of kludgey: use numbers so this is valid input for factor, |
| 259 | # and two tokens so it's valid input for tsort. |
| 260 | echoscip-shell system . . echo. 2147483647 0 > $tmp_in |
| 261 | # Make $tmp_in2 identical. Then, using $tmp_in and $tmp_in2 as arguments |
| 262 | # to the likes of cmp and diff makes them exit successfully. |
| 263 | cpscip-shell system . . cp. $tmp_in $tmp_in2 |
| 264 | mkdirscip-shell system . . mkdir. $tmp_dir |
| 265 | # echo ================== $i |
| 266 | testscip-shell system . . test. $i = [ && prog=lbracket || prog=$i |
| 267 | if type ${prog}_setup > /dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then |
| 268 | ${prog}_setup |
| 269 | else |
| 270 | args= |
| 271 | fi |
| 272 | if envscip-shell system . . env. $i $args < $tmp_in > $tmp_out; then |
| 273 | : # ok |
| 274 | else |
| 275 | echoscip-shell system . . echo. FAIL: $i |
| 276 | fail=1 |
| 277 | fi |
| 278 | rmscip-shell system . . rm. -rf $tmp_in $tmp_in2 $tmp_out $tmp_dir |
| 279 | done |
| 280 | |
| 281 | Exit $fail |