blob: 4645166b855f7d581cbb218cf454ffe46b0cd3cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
OK=" OK"
FAIL=" FAIL"
TESTDIR=`mktemp -d`
IMGFILE=$TESTDIR/tbdiff.img
ORIGIN=$TESTDIR/orig
TARGET=$TESTDIR/target
# check_same_mtime FILE_A FILE_B
check_same_mtime () {
test $(stat -c %Y $1) = $(stat -c %Y $2)
}
# check_same_uidgid FILE_A FILE_B
check_same_uidgid () {
test $(stat -c "%u.%g" $1) = $(stat -c "%u.%g" $2)
}
# check_same_mode FILE_A FILE_B
check_same_mode () {
test $(stat -c "%f" $1) = $(stat -c "%f" $2)
}
# check_content FILE EXPECTED_OCTAL_PERMISSIONS
check_perm () {
test $(stat -c %a $1) = $2
}
# check_content FILE EXPECTED_OCTAL_PERMISSIONS
check_symlink () {
test $(readlink $1) = $2
}
# check_content FILE EXPECTED_CONTENT
check_content () {
test $(cat $1) = $2
}
# check_group FILE EXPECTED_GROUP_NAME
check_group () {
test $(stat -c %G $1) = $2
}
start () {
if [ $# -ne 2 ]
then
echo "ERROR: Not enough arguments."
cleanup_and_exit
fi
if [ ! -f $1 ]
then
echo "ERROR: $1 is an invalid tbdiff-create path" 1>&2
cleanup_and_exit
fi
if [ ! -f $2 ]
then
echo "ERROR: $1 is an invalid tbdiff-deploy path" 1>&2
cleanup_and_exit
fi
}
cleanup_and_exit () {
rm -rf $TESTDIR
exit 1
}
main () {
start $@
echo -n "$TEST_ID Setting up $TEST_NAME test: "
if [ ! -d $TESTDIR ]
then
echo $FAIL
echo "Couldn't create temporary directory for test. " \
"Please check mktemp accepts -d and permissions." >&2
cleanup_and_exit
fi
mkdir -p $ORIGIN && \
mkdir -p $TARGET && \
setup
if [ $? -ne 0 ]
then
echo $FAIL
echo "Couldn't setup the test directory structure. Check your privileges" 1>&2
cleanup_and_exit
fi
echo $OK
echo "$TEST_ID Performing $TEST_NAME image creation and deployment: "
CWD=$(pwd)
$CREATE $IMGFILE $ORIGIN $TARGET && \
cd $ORIGIN && \
$DEPLOY $IMGFILE && \
RETVAL=$?
cd $CWD
if test "x$RETVAL" != "x0"
then
echo $FAIL
echo "Could not create and deploy image." 1>&2
cleanup_and_exit
fi
echo $OK
echo -n "$TEST_ID Checking $TEST_NAME results: "
check_results
if test "x$?" != "x0"
then
echo $FAIL
echo "Applying image did not produce the expected results" 1>&2
cleanup_and_exit
fi
echo $OK
}
|