fs_var_lock.exp 1.52 KB
Newer Older
netblue30's avatar
netblue30 committed
1
#!/usr/bin/expect -f
netblue30's avatar
netblue30 committed
2 3 4
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
netblue30's avatar
netblue30 committed
5 6 7 8 9 10 11 12 13 14 15 16 17

set timeout 10
spawn $env(SHELL)
match_max 100000

# testing read-write /var/lock
send -- "firejail\r"
expect {
	timeout {puts "TESTING ERROR 0\n";exit}
	"Child process initialized"
}
sleep 1

netblue30's avatar
netblue30 committed
18
send -- "echo mytest > /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
19 20
expect {
	timeout {puts "TESTING ERROR 1\n";exit}
netblue30's avatar
netblue30 committed
21
	"done"
netblue30's avatar
netblue30 committed
22 23
}

netblue30's avatar
netblue30 committed
24
send -- "cat /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
25
expect {
netblue30's avatar
netblue30 committed
26
	timeout {puts "TESTING ERROR 2\n";exit}
netblue30's avatar
netblue30 committed
27 28 29
	"mytest"
}
expect {
netblue30's avatar
netblue30 committed
30 31
	timeout {puts "TESTING ERROR 3\n";exit}
	"done"
netblue30's avatar
netblue30 committed
32 33
}

netblue30's avatar
netblue30 committed
34
send -- "rm /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
35
expect {
netblue30's avatar
netblue30 committed
36 37
	timeout {puts "TESTING ERROR 4\n";exit}
	"done"
netblue30's avatar
netblue30 committed
38 39
}

netblue30's avatar
netblue30 committed
40
send -- "cat /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
41
expect {
netblue30's avatar
netblue30 committed
42 43 44
	timeout {puts "TESTING ERROR 5\n";exit}
	"mytest" {puts "TESTING ERROR 6\n";exit}
	"done"
netblue30's avatar
netblue30 committed
45 46 47 48 49 50 51 52 53
}

sleep 1
send -- "exit\r"
sleep 1

# redo the test with --private
send -- "firejail\r"
expect {
netblue30's avatar
netblue30 committed
54
	timeout {puts "TESTING ERROR 7\n";exit}
netblue30's avatar
netblue30 committed
55 56 57 58
	"Child process initialized"
}
sleep 1

netblue30's avatar
netblue30 committed
59
send -- "echo mytest > /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
60
expect {
netblue30's avatar
netblue30 committed
61 62
	timeout {puts "TESTING ERROR 8\n";exit}
	"done"
netblue30's avatar
netblue30 committed
63 64
}

netblue30's avatar
netblue30 committed
65
send -- "cat /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
66
expect {
netblue30's avatar
netblue30 committed
67
	timeout {puts "TESTING ERROR 9\n";exit}
netblue30's avatar
netblue30 committed
68 69 70
	"mytest"
}
expect {
netblue30's avatar
netblue30 committed
71 72
	timeout {puts "TESTING ERROR 10\n";exit}
	"done"
netblue30's avatar
netblue30 committed
73 74
}

netblue30's avatar
netblue30 committed
75
send -- "rm /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
76
expect {
netblue30's avatar
netblue30 committed
77 78
	timeout {puts "TESTING ERROR 11\n";exit}
	"done"
netblue30's avatar
netblue30 committed
79 80
}

netblue30's avatar
netblue30 committed
81
send -- "cat /var/lock/ttt;echo done\r"
netblue30's avatar
netblue30 committed
82
expect {
netblue30's avatar
netblue30 committed
83 84 85
	timeout {puts "TESTING ERROR 12\n";exit}
	"mytest" {puts "TESTING ERROR 13\n";exit}
	"done"
netblue30's avatar
netblue30 committed
86 87 88 89
}

sleep 1

netblue30's avatar
netblue30 committed
90
puts "\nall done\n"