-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_isolate.sh
executable file
·55 lines (40 loc) · 1.28 KB
/
test_isolate.sh
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
set -e
export NI_QUIET=1
#export VERBOSE=1
trap 'set +x ; echo; echo; echo FAILURE' EXIT
set -x
# Basic test 1: /bin and /usr should exist
./isolate.sh 'test -e /bin -a -e /usr'
# Basic test 2: /etc should not exist
./isolate.sh 'test ! -e /etc'
# test pwd
test "$(./isolate.sh 'pwd')" = "$PWD"
# Test mounting of directory locally
tmpdir=`mktemp -d --tmpdir isolate-test.XXXXXXX`
./isolate.sh -m ". $tmpdir" "touch $tmpdir/file1"
test -e $tmpdir/file1
rm -r $tmpdir
# Test read-only mounting of directory locally
tmpdir=`mktemp -d --tmpdir isolate-test.XXXXXXX`
./isolate.sh -m ". ro:$tmpdir" "! touch $tmpdir/file1"
test ! -e $tmpdir/file1
rm -r "$tmpdir"
# Test mounting of a file
tmpdir=`mktemp --tmpdir isolate-test.XXXXXXX`
./isolate.sh -m ". $tmpdir" "echo -n 123 > $tmpdir"
test 123 = "$(cat $tmpdir)"
rm -r "$tmpdir"
# Test mounting of a dir at a different path
tmpdir=`mktemp -d --tmpdir isolate-test.XXXXXXX`
./isolate.sh -m ". /tmp/x1=$tmpdir" "touch /tmp/x1/file1"
test -e "$tmpdir"/file1
rm -r "$tmpdir"
# Test replacing a file with null file
./isolate.sh -m ". /bin/tar=none" 'test $(stat --format=%s /bin/tar) = 0'
# Test replacing a directory with an empty directory
./isolate.sh -m ". /usr/sbin=none" 'test ! -e /usr/sbin/chroot'
set +x
echo
echo
echo SUCCESS
trap - EXIT