Debian Codegraph @

tests/ts/setarch/setarch

raw symbols SCIP
1 #!/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=$(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 echo "exit: $?" >>$TS_OUTPUT
30
31 ts_log_both "###### unknown command"
32 $TS_CMD_SETARCH $ARCH --verbose /das/gibs/nicht >> $TS_OUTPUT 2>> $TS_ERRLOG
33 echo "exit: $?" >>$TS_OUTPUT
34
35 echo "###### noop uname -a" >>$TS_OUTPUT
36 uname_a=$(uname -srm)
37 $TS_CMD_SETARCH $ARCH --verbose uname -srm >> $TS_OUTPUT 2>> $TS_ERRLOG
38 sed -i "$ s@${uname_a}@uname -a unchanged@" $TS_OUTPUT
39
40 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 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 [ $? -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 sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT
58
59 echo "###### --uname-2.6 true, non-verbose" >>$TS_OUTPUT
60 $TS_CMD_SETARCH $ARCH --uname-2.6 true >> $TS_OUTPUT 2>&1
61 if [ $? -eq 0 ]; then
62 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 sed -i "$ s/$expected/2.6 works or kernel too old/" $TS_OUTPUT
67 finmsg+=" true"
68 fi
69
70 if [ -n "$finmsg" ]; then
71 finmsg=$(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 [ "$uname26_seems_supported" = "yes" ]; then
80 ts_init_subtest uname26-version
81 tmp=$($TS_CMD_SETARCH $ARCH --uname-2.6 uname -r)
82 if echo "$tmp" | grep -q "^2\.6\."; then
83 echo "kernel version changed to 2.6" >> $TS_OUTPUT
84 else
85 echo "uname26 failed" >> $TS_OUTPUT
86 echo "original kernel: $(uname -r)" >> $TS_OUTPUT
87 echo "uname26 kernel: $tmp" >> $TS_OUTPUT
88 fi
89 ts_finalize_subtest
90 fi # conditional subtest
91
92 ts_init_subtest show
93 echo "###### --show" >>$TS_OUTPUT
94
95 show() {
96 echo -n "$1: " >> $TS_OUTPUT
97 $TS_CMD_SETARCH --show=$1 >> $TS_OUTPUT 2> $TS_ERRLOG
98 }
99
100 show 0x00000000
101 show 0x00800000
102 show 0x00880000
103 show 0x00000008
104 show 0x08000008
105 show 0x000040ff
106
107 ts_finalize_subtest
108
109 ts_finalize