blob: 2c182a73f380225d314462cfd1e091e25a99f424 (
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
|
OK=" OK"
FAIL=" FAIL"
TESTDIR=/tmp/tbdiff-test-`uuid`
IMGFILE=$TESTDIR/tbdiff.img
ORIGIN=$TESTDIR/orig
TARGET=$TESTDIR/target
# check_same_mtime FILE_A FILE_B
function check_same_mtime {
test $(stat -c %Y $1) = $(stat -c %Y $2)
}
# check_content FILE EXPECTED_OCTAL_PERMISSIONS
function check_perm {
test $(stat -c %a $1) = $2
}
# check_content FILE EXPECTED_OCTAL_PERMISSIONS
function check_symlink {
test $(readlink $1) = $2
}
# check_content FILE EXPECTED_CONTENT
function check_content {
test $(cat $1) = $2
}
# check_group FILE EXPECTED_GROUP_NAME
function check_group {
test $(stat -c %G $1) = $2
}
function 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
}
function cleanup_and_exit {
rm -rf $TESTDIR
exit 1
}
function main {
start $@
echo -n "$TEST_ID Setting up $TEST_NAME test: "
rm -rf $TESTDIR && \
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$RETVAL" != "x0"
then
echo $FAIL
echo "Applying image did not produce the expected results" 1>&2
cleanup_and_exit
fi
echo $OK
}
|