Print this page
4620 Add OmniOS as a runnable usr/src/test distro
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/cmd/scripts/zfstest.ksh
+++ new/usr/src/test/zfs-tests/cmd/scripts/zfstest.ksh
1 1 #!/usr/bin/ksh
2 2
3 3 #
4 4 # This file and its contents are supplied under the terms of the
5 5 # Common Development and Distribution License ("CDDL"), version 1.0.
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
6 6 # You may only use this file in accordance with the terms of version
7 7 # 1.0 of the CDDL.
8 8 #
9 9 # A full copy of the text of the CDDL should have accompanied this
10 10 # source. A copy of the CDDL is also available via the Internet at
11 11 # http://www.illumos.org/license/CDDL.
12 12 #
13 13
14 14 #
15 15 # Copyright (c) 2012 by Delphix. All rights reserved.
16 +# Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
16 17 #
17 18
18 19 export STF_SUITE="/opt/zfs-tests"
19 20 export STF_TOOLS="/opt/test-runner/stf"
20 21 runner="/opt/test-runner/bin/run"
21 22 auto_detect=false
22 23
23 24 function fail
24 25 {
25 26 echo $1
26 27 exit ${2:-1}
27 28 }
28 29
29 30 function find_disks
30 31 {
31 32 typeset all_disks=$(echo '' | sudo /usr/sbin/format | awk \
32 33 '/c[0-9]/ {print $2}')
33 34 typeset used_disks=$(/sbin/zpool status | awk \
34 35 '/c[0-9]*t[0-9a-f]*d[0-9]/ {print $1}' | sed 's/s[0-9]//g')
35 36
36 37 typeset disk used avail_disks
37 38 for disk in $all_disks; do
38 39 for used in $used_disks; do
39 40 [[ "$disk" = "$used" ]] && continue 2
40 41 done
41 42 [[ -n $avail_disks ]] && avail_disks="$avail_disks $disk"
42 43 [[ -z $avail_disks ]] && avail_disks="$disk"
43 44 done
44 45
45 46 echo $avail_disks
46 47 }
47 48
48 49 function find_rpool
49 50 {
50 51 typeset ds=$(/usr/sbin/mount | awk '/^\/ / {print $3}')
|
↓ open down ↓ |
25 lines elided |
↑ open up ↑ |
51 52 echo ${ds%%/*}
52 53 }
53 54
54 55 function find_runfile
55 56 {
56 57 typeset distro=
57 58 if [[ -d /opt/delphix && -h /etc/delphix/version ]]; then
58 59 distro=delphix
59 60 elif [[ 0 -ne $(grep -c OpenIndiana /etc/release 2>/dev/null) ]]; then
60 61 distro=openindiana
62 + elif [[ 0 -ne $(grep -c OmniOS /etc/release 2>/dev/null) ]]; then
63 + distro=omnios
61 64 fi
62 65
63 66 [[ -n $distro ]] && echo $STF_SUITE/runfiles/$distro.run
64 67 }
65 68
66 69 function verify_id
67 70 {
68 71 [[ $(id -u) = "0" ]] && fail "This script must not be run as root."
69 72
70 73 sudo -n id >/dev/null 2>&1
71 74 [[ $? -eq 0 ]] || fail "User must be able to sudo without a password."
72 75
73 76 typeset -i priv_cnt=$(ppriv $$ | egrep -v \
74 77 ": basic$| L:| <none>|$$:" | wc -l)
75 78 [[ $priv_cnt -ne 0 ]] && fail "User must only have basic privileges."
76 79 }
77 80
78 81 function verify_disks
79 82 {
80 83 typeset disk
81 84 for disk in $DISKS; do
82 85 sudo /usr/sbin/prtvtoc /dev/rdsk/${disk}s0 >/dev/null 2>&1
83 86 [[ $? -eq 0 ]] || return 1
84 87 done
85 88 return 0
86 89 }
87 90
88 91 verify_id
89 92
90 93 while getopts ac:q c; do
91 94 case $c in
92 95 'a')
93 96 auto_detect=true
94 97 ;;
95 98 'c')
96 99 runfile=$OPTARG
97 100 [[ -f $runfile ]] || fail "Cannot read file: $runfile"
98 101 ;;
99 102 'q')
100 103 quiet='-q'
101 104 ;;
102 105 esac
103 106 done
104 107 shift $((OPTIND - 1))
105 108
106 109 # If the user specified -a, then use free disks, otherwise use those in $DISKS.
107 110 if $auto_detect; then
108 111 export DISKS=$(find_disks)
109 112 elif [[ -z $DISKS ]]; then
110 113 fail "\$DISKS not set in env, and -a not specified."
111 114 else
112 115 verify_disks || fail "Couldn't verify all the disks in \$DISKS"
113 116 fi
114 117
115 118 # Add the rpool to $KEEP according to its contents. It's ok to list it twice.
116 119 if [[ -z $KEEP ]]; then
117 120 export KEEP="^$(find_rpool)\$"
118 121 else
119 122 export KEEP="^$(echo $KEEP | sed 's/ /|$/')\$"
120 123 KEEP+="|^$(find_rpool)\$"
121 124 fi
122 125
123 126 [[ -z $runfile ]] && runfile=$(find_runfile)
124 127 [[ -z $runfile ]] && fail "Couldn't determine distro"
125 128
126 129 . $STF_SUITE/include/default.cfg
127 130
128 131 num_disks=$(echo $DISKS | awk '{print NF}')
129 132 [[ $num_disks -lt 3 ]] && fail "Not enough disks to run ZFS Test Suite"
130 133
131 134 $runner $quiet -c $runfile
132 135
133 136 exit $?
|
↓ open down ↓ |
63 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX