vcpupin 3.2 KB
Newer Older
1 2 3
#!/bin/sh
# ensure that an invalid CPU spec elicits a diagnostic

4
# Copyright (C) 2008 Red Hat, Inc.
5 6 7

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
J
Jim Meyering 已提交
8
# the Free Software Foundation, either version 2 of the License, or
9 10 11 12 13 14 15 16
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
17 18
# along with this program.  If not, see
# <http://www.gnu.org/licenses/>.
19

C
Chris Lalancette 已提交
20 21 22 23
test -z "$srcdir" && srcdir=$(pwd)
test -z "$abs_top_srcdir" && abs_top_srcdir=$(pwd)/..
test -z "$abs_top_builddir" && abs_top_builddir=$(pwd)/..

24 25
if test "$VERBOSE" = yes; then
  set -x
C
Chris Lalancette 已提交
26
  $abs_top_builddir/tools/virsh --version
27 28
fi

C
Chris Lalancette 已提交
29
. "$srcdir/test-lib.sh"
30 31

fail=0
32 33

# Invalid syntax.
C
Chris Lalancette 已提交
34
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test a 0,1 > out 2>&1
35 36
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
37
error: Numeric value 'a' for <vcpu> option is malformed or out of range
38 39

EOF
40
compare exp out || fail=1
41

42
# An out-of-range vCPU number deserves a diagnostic, too.
C
Chris Lalancette 已提交
43
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
44 45
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
46
error: invalid argument: requested vcpu '100' is not present in the domain
47 48 49 50 51 52 53 54

EOF
compare exp out || fail=1

# Negative number
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test -100 0,1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
55
error: Numeric value '-100' for <vcpu> option is malformed or out of range
56 57

EOF
58
compare exp out || fail=1
59

60 61 62 63 64 65 66 67 68
# missing argument
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test --cpulist 0,1 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpupin: Missing vCPU number in pin mode.

EOF
compare exp out || fail=1

69 70
# An out-of-range vCPU number when get information with live flag
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --live > out 2>&1
71 72
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
error: vcpu 100 is out of range of live cpu count 2

EOF
compare exp out || fail=1

# An out-of-range vCPU number when get information without flag
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpu 100 is out of range of live cpu count 2

EOF
compare exp out || fail=1

# An out-of-range vCPU number when get information with config flag
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --config > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpu 100 is out of range of persistent cpu count 2

EOF
compare exp out || fail=1

# An out-of-range vCPU number when get information with current flag
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --current > out 2>&1
test $? = 1 || fail=1
cat <<\EOF > exp || fail=1
error: vcpu 100 is out of range of live cpu count 2
101 102 103

EOF
compare exp out || fail=1
104
(exit $fail); exit $fail