5
/usr/sbin/ovinstanceadd $newinstance >$stdoutf 2>$stderrf
8
assertTrue "[ -d /opt/openvista/$newinstance ]"
10
assertNull "`cat ${stdoutf}`"
11
assertNull "`cat ${stderrf}`"
14
testOvinstanceaddRequiresRoot()
16
su -c "/usr/sbin/ovinstanceadd $newinstance" openvista >$stdoutf 2>$stderrf
19
assertFalse "[ -d /opt/openvista/$newinstance ]"
20
assertEquals 1 $retval
21
assertNull "`cat ${stdoutf}`"
22
assertEquals 'ovinstanceadd: Only root may add an OpenVista instance to the system' "`cat ${stderrf}`"
27
/usr/sbin/ovinstancedel -y $instance >$stdoutf 2>$stderrf
30
assertFalse "[ -d /opt/openvista/$instance ]"
31
assertEquals 0 $retval
32
assertNull "`cat ${stdoutf}`"
33
assertNull "`cat ${stderrf}`"
36
testOvinstancedelRequiresRoot()
38
su -c "/usr/sbin/ovinstancedel $instance" openvista >$stdoutf 2>$stderrf
41
assertTrue "[ -d /opt/openvista/$instance ]"
42
assertEquals 1 $retval
43
assertNull "`cat ${stdoutf}`"
44
assertEquals 'ovinstancedel: Only root may delete an OpenVista instance from the system' "`cat ${stderrf}`"
49
# create a backup to restore
50
ovbackup -q "$instance"
51
backup=`find /opt/openvista/$instance/backups -name '*.tar.bz2' | head -n1`
53
# FIXME: create routines and globals and check that they are actually restored
54
md5sum=`md5sum /opt/openvista/$instance/globals/default.dat`
56
/usr/sbin/ovrestore -y $backup $instance >$stdoutf 2>$stderrf
59
assertNotEquals "$md5sum" "`md5sum /opt/openvista/$instance/globals/default.dat`"
60
assertEquals 0 $retval
61
assertNull "`cat ${stdoutf}`"
62
assertNotNull "`cat ${stderrf}`"
67
# create a backup to restore
68
ovbackup -q "$instance"
69
backup=`find /opt/openvista/$instance/backups -name '*.tar.bz2' | head -n1`
71
# FIXME: create routines and globals and check that they are actually restored
72
md5sum=`md5sum /opt/openvista/$instance/globals/default.dat`
74
/usr/sbin/ovrestore -y -q $backup $instance >$stdoutf 2>$stderrf
77
assertNotEquals "$md5sum" "`md5sum /opt/openvista/$instance/globals/default.dat`"
78
assertEquals 0 $retval
79
assertNull "`cat ${stdoutf}`"
80
assertNull "`cat ${stderrf}`"
83
testOvrestoreRequiresRoot()
85
# create a backup to restore
86
ovbackup -q "$instance"
87
backup=`find /opt/openvista/$instance/backups -name '*.tar.bz2' | head -n1`
89
md5sum=`md5sum /opt/openvista/$instance/globals/default.dat`
91
su -c "/usr/sbin/ovrestore -y $backup $instance" openvista >$stdoutf 2>$stderrf
94
assertEquals "$md5sum" "`md5sum /opt/openvista/$instance/globals/default.dat`"
95
assertEquals 1 $retval
96
assertNull "`cat ${stdoutf}`"
97
assertEquals 'ovrestore: root privileges are required to restore backups' "`cat ${stderrf}`"
102
tempdir=`mktemp -d -t .shunit.XXXXXXXXXX`
103
stdoutf="$tempdir/stdout"
104
stderrf="$tempdir/stderr"
107
newinstance="shunitnew"
109
/usr/sbin/ovinstanceadd "$instance"
116
# may have already been deleted by the test, so check before deleting
117
[ -d "/opt/openvista/$instance" ] && /usr/sbin/ovinstancedel -y "$instance"
119
# may have been created by the test, delete if it exists
120
[ -d "/opt/openvista/$newinstance" ] && /usr/sbin/ovinstancedel -y "$newinstance"
123
[ `id -u` -eq 0 ] || {
124
echo "runtests.sh: tests must be run as root" >&2
128
# load and run shUnit2
129
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
130
. ./shunit2-2.1.5/src/shell/shunit2