| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # This file is part of util-linux. |
| 4 | # |
| 5 | # This file is free software; you can redistribute it and/or modify |
| 6 | # it under the terms of the GNU General Public License as published by |
| 7 | # the Free Software Foundation; either version 2 of the License, or |
| 8 | # (at your option) any later version. |
| 9 | # |
| 10 | # This file is distributed in the hope that it will be useful, |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | # GNU General Public License for more details. |
| 14 | |
| 15 | TS_TOPDIR="${0%/*}/../.." |
| 16 | TS_DESC="setarch" |
| 17 | |
| 18 | . "$TS_TOPDIR"/functions.sh |
| 19 | ts_init "$*" |
| 20 | |
| 21 | ts_check_test_command "$TS_CMD_SETARCH" |
| 22 | ts_skip_docker |
| 23 | |
| 24 | ARCH=$(unamescip-shell system . . uname. -m) |
| 25 | |
| 26 | ts_init_subtest options |
| 27 | ts_log_both "###### unknown arch" |
| 28 | $TS_CMD_SETARCH qubit --verbose echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 29 | echoscip-shell system . . echo. "exit: $?" >>$TS_OUTPUT |
| 30 | |
| 31 | ts_log_both "###### unknown command" |
| 32 | $TS_CMD_SETARCH $ARCH --verbose /das/gibs/nichtscip-shell filesystem . . `/das/gibs/nicht`. >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 33 | echoscip-shell system . . echo. "exit: $?" >>$TS_OUTPUT |
| 34 | |
| 35 | echoscip-shell system . . echo. "###### noop uname -a" >>$TS_OUTPUT |
| 36 | uname_a=$(unamescip-shell system . . uname. -srm) |
| 37 | $TS_CMD_SETARCH $ARCH --verbose uname -srm >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 38 | sedscip-shell system . . sed. -i "$ s@${uname_a}@uname -a unchanged@" $TS_OUTPUT |
| 39 | |
| 40 | echoscip-shell system . . echo. "###### almost all options" >>$TS_OUTPUT |
| 41 | $TS_CMD_SETARCH $ARCH -vRFZLXBIST3 echo "success" >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 42 | ts_finalize_subtest |
| 43 | |
| 44 | |
| 45 | ts_init_subtest uname26 |
| 46 | finmsg="" # for debugging 2.6 issues |
| 47 | |
| 48 | echoscip-shell system . . echo. "###### --uname-2.6 echo" >>$TS_OUTPUT |
| 49 | $TS_CMD_SETARCH $ARCH --verbose --uname-2.6 echo "2.6 worked" >> $TS_OUTPUT 2>&1 |
| 50 | if [scip-shell system . . `[`. $? -eq 0 ]; then |
| 51 | expected='^2.6 worked$' |
| 52 | else |
| 53 | # this may happen after execvp - gets written to stderr |
| 54 | expected="^FATAL: kernel too old$" |
| 55 | finmsg+=" echo" |
| 56 | fi |
| 57 | sedscip-shell system . . sed. -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT |
| 58 | |
| 59 | echoscip-shell system . . echo. "###### --uname-2.6 true, non-verbose" >>$TS_OUTPUT |
| 60 | $TS_CMD_SETARCH $ARCH --uname-2.6 true >> $TS_OUTPUT 2>&1 |
| 61 | if [scip-shell system . . `[`. $? -eq 0 ]; then |
| 62 | echoscip-shell system . . echo. "2.6 works or kernel too old" >> $TS_OUTPUT |
| 63 | else |
| 64 | # this may happen after execvp - gets written to stderr |
| 65 | expected="^FATAL: kernel too old$" |
| 66 | sedscip-shell system . . sed. -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT |
| 67 | finmsg+=" true" |
| 68 | fi |
| 69 | |
| 70 | if [scip-shell system . . `[`. -n "$finmsg" ]; then |
| 71 | finmsg=$(echoscip-shell system . . echo. unsupported --uname-2.6: $finmsg) |
| 72 | else |
| 73 | uname26_seems_supported=yes |
| 74 | fi |
| 75 | ts_finalize_subtest "$finmsg" |
| 76 | |
| 77 | |
| 78 | # conditional subtest |
| 79 | if [scip-shell system . . `[`. "$uname26_seems_supported" = "yes" ]; then |
| 80 | ts_init_subtest uname26-version |
| 81 | tmp=$($TS_CMD_SETARCH $ARCH --uname-2.6 uname -r) |
| 82 | if echoscip-shell system . . echo. "$tmp" | grepscip-shell system . . grep. -q "^2\.6\."; then |
| 83 | echoscip-shell system . . echo. "kernel version changed to 2.6" >> $TS_OUTPUT |
| 84 | else |
| 85 | echoscip-shell system . . echo. "uname26 failed" >> $TS_OUTPUT |
| 86 | echoscip-shell system . . echo. "original kernel: $(unamescip-shell system . . uname. -r)" >> $TS_OUTPUT |
| 87 | echoscip-shell system . . echo. "uname26 kernel: $tmp" >> $TS_OUTPUT |
| 88 | fi |
| 89 | ts_finalize_subtest |
| 90 | fi # conditional subtest |
| 91 | |
| 92 | ts_init_subtest show |
| 93 | echoscip-shell system . . echo. "###### --show" >>$TS_OUTPUT |
| 94 | |
| 95 | showscip-shell shell util-linux 2.42.2-1 show().() { |
| 96 | echoscip-shell system . . echo. -n "$1: " >> $TS_OUTPUT |
| 97 | $TS_CMD_SETARCH --show=$1 >> $TS_OUTPUT 2> $TS_ERRLOG |
| 98 | } |
| 99 | |
| 100 | showscip-shell shell util-linux 2.42.2-1 show(). 0x00000000 |
| 101 | showscip-shell shell util-linux 2.42.2-1 show(). 0x00800000 |
| 102 | showscip-shell shell util-linux 2.42.2-1 show(). 0x00880000 |
| 103 | showscip-shell shell util-linux 2.42.2-1 show(). 0x00000008 |
| 104 | showscip-shell shell util-linux 2.42.2-1 show(). 0x08000008 |
| 105 | showscip-shell shell util-linux 2.42.2-1 show(). 0x000040ff |
| 106 | |
| 107 | ts_finalize_subtest |
| 108 | |
| 109 | ts_finalize |