Commit fffce11c authored by netblue30's avatar netblue30

testing

parent d8984ed1
......@@ -174,7 +174,7 @@ test-compile: dist
cd test/compile; ./compile.sh $(NAME)-$(VERSION)
test-root:
cd test/root; su -c ./start.sh
cd test/root; su -c ./root.sh | grep TESTING
.PHONY: rpms
rpms:
......
......@@ -247,6 +247,9 @@ void fs_private_bin_list(void) {
duplicate(ptr);
free(dlist);
fs_logger_print();
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
// wait for the child to finish
......
......@@ -171,6 +171,9 @@ void fs_private_etc_list(void) {
duplicate(ptr);
free(dlist);
fs_logger_print();
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
// wait for the child to finish
......
......@@ -81,6 +81,9 @@ void fs_mkdir(const char *name) {
// create directory
mkdir_recursive(expanded);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
// wait for the child to finish
......@@ -126,6 +129,9 @@ void fs_mkfile(const char *name) {
(void) rv;
fclose(fp);
}
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
// wait for the child to finish
......
......@@ -358,6 +358,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) {
// copy the file
if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600))
_exit(1);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......@@ -381,6 +384,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) {
// copy the file
if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600))
_exit(1);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......@@ -423,6 +429,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) {
// copy the file
if (copy_file(src_fname, tmp_fname, getuid(), getgid(), 0600))
_exit(1);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......@@ -452,6 +461,9 @@ void sandboxfs(int op, pid_t pid, const char *path1, const char *path2) {
// copy the file
if (copy_file(tmp_fname, dest_fname, getuid(), getgid(), 0600))
_exit(1);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......
......@@ -2461,6 +2461,9 @@ int main(int argc, char **argv) {
network_main(child);
if (arg_debug)
printf("Host network configured\n");
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......
......@@ -692,6 +692,9 @@ void x11_xorg(void) {
execlp("/usr/bin/xauth", "/usr/bin/xauth", "-f", tmpfname,
"generate", display, "MIT-MAGIC-COOKIE-1", "untrusted", NULL);
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......
......@@ -146,6 +146,9 @@ static void print_sandbox(pid_t pid) {
return;
net_ifprint();
printf("\n");
#ifdef HAVE_GCOV
__gcov_flush();
#endif
_exit(0);
}
......
......@@ -192,6 +192,10 @@ static int procevent_monitor(const int sock, pid_t mypid) {
tv.tv_usec = 0;
while (1) {
#ifdef HAVE_GCOV
__gcov_flush();
#endif
#define BUFFSIZE 4096
char __attribute__ ((aligned(NLMSG_ALIGNTO)))buf[BUFFSIZE];
......
......@@ -8,6 +8,15 @@ export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))
rm -fr ~/_firejail_test_*
echo "TESTING: mkdir/mkfile (test/fs/mkdir_mkfile.exp)"
./mkdir_mkfile.exp
rm -fr ~/_firejail_test_*
mkdir ~/_firejail_test_dir
touch ~/_firejail_test_dir/a
mkdir ~/_firejail_test_dir/test1
touch ~/_firejail_test_dir/test1/b
echo "TESTING: read/write (test/fs/read-write.exp)"
./read-write.exp
rm -fr ~/_firejail_test_*
echo "TESTING: /sys/fs access (test/fs/sys_fs.exp)"
......
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "firejail --read-only=~/_firejail_test_dir --read-write=~/_firejail_test_dir/test1\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
}
sleep 1
send -- "echo mytest >~/_firejail_test_dir/a;echo done\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"done"
}
send -- "echo mytest >~/_firejail_test_dir/test1/b;echo done\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"done"
}
send -- "cat ~/_firejail_test_dir/a;echo done\r"
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"mytest" {puts "TESTING ERROR 4\n";exit}
"done"
}
send -- "cat ~/_firejail_test_dir/test1/b;echo done\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"mytest"
}
expect {
timeout {puts "TESTING ERROR 6\n";exit}
"done"
}
after 100
puts "\nall done\n"
#!/bin/bash
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
brctl addbr br0
ifconfig br0 10.10.20.1/29 up
# NAT masquerade
iptables -t nat -A POSTROUTING -o eth0 -s 10.10.20.0/29 -j MASQUERADE
# port forwarding
# iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.10.20.2:80
brctl addbr br1
ifconfig br1 10.10.30.1/24 up
brctl addbr br2
ifconfig br2 10.10.40.1/24 up
brctl addbr br3
ifconfig br3 10.10.50.1/24 up
brctl addbr br4
ifconfig br4 10.10.60.1/24 up
ip link add link eth0 name eth0.5 type vlan id 5
/sbin/ifconfig eth0.5 10.10.205.10/24 up
ip link add link eth0 name eth0.6 type vlan id 6
/sbin/ifconfig eth0.6 10.10.206.10/24 up
ip link add link eth0 name eth0.7 type vlan id 7
/sbin/ifconfig eth0.7 10.10.207.10/24 up
#!/usr/bin/expect -f
set timeout 10
spawn $env(SHELL)
match_max 100000
# start firemon
set firemon_id $spawn_id
send -- "firemon\r"
sleep 1
# start firejail
spawn $env(SHELL)
set firejail_id $spawn_id
send -- "firejail\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
}
# get messages on firemon
set spawn_id $firemon_id
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"exec"
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"/bin/bash -c /bin/bash"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"exec"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"/bin/bash"
}
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"fork"
}
expect {
timeout {puts "TESTING ERROR 6\n";exit}
"child"
}
expect {
timeout {puts "TESTING ERROR 7\n";exit}
"/bin/bash"
}
after 100
# exit firejail
set spawn_id $firejail_id
send -- "exit\r"
sleep 1
# get messages on firemon
set spawn_id $firemon_id
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"exit"
}
expect {
timeout {puts "TESTING ERROR 9\n";exit}
"EXIT SANDBOX"
}
puts "\nall done\n"
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "ip link add link eth0 name eth0.100 type vlan id 100\r"
sleep 1
send -- "ip link add link eth0 name eth0.101 type vlan id 101\r"
sleep 1
send -- "ip link add link eth0 name eth0.102 type vlan id 102\r"
sleep 1
send -- "ip link add link eth0 name eth0.103 type vlan id 103\r"
sleep 1
send -- "ip link add link eth0 name eth0.104 type vlan id 104\r"
sleep 1
puts "\n"
send -- "/sbin/ifconfig eth0.100 10.200.0.1/24\r"
sleep 1
send -- "/sbin/ifconfig eth0.101 10.200.1.1/24\r"
sleep 1
send -- "/sbin/ifconfig eth0.102 10.200.2.1/24\r"
sleep 1
send -- "/sbin/ifconfig eth0.103 10.200.3.1/24\r"
sleep 1
send -- "/sbin/ifconfig eth0.104 10.200.4.1/24\r"
sleep 1
puts "\n"
send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103 --interface=eth0.104\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"maximum 4 interfaces are allowed"
}
sleep 1
send -- "firejail --noprofile --interface=eth0.100 --interface=eth0.101 --interface=eth0.102 --interface=eth0.103\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"eth0.100"
}
expect {
timeout {puts "TESTING ERROR 1.1\n";exit}
"UP"
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"eth0.101"
}
expect {
timeout {puts "TESTING ERROR 2.2\n";exit}
"UP"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"eth0.102"
}
expect {
timeout {puts "TESTING ERROR 3.1\n";exit}
"UP"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
"eth0.103"
}
expect {
timeout {puts "TESTING ERROR 4.1\n";exit}
"UP"
}
sleep 1
send -- "exit\r"
sleep 1
send -- "firejail --noprofile --interface=eth0.104\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"eth0.104"
}
expect {
timeout {puts "TESTING ERROR 5.1\n";exit}
"UP"
}
send -- "exit\r"
after 100
puts "all done\n"
......@@ -16,13 +16,9 @@ expect {
timeout {puts "TESTING ERROR 1\n";exit}
"total 0"
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"/root"
}
sleep 1
after 100
send -- "exit\r"
sleep 2
sleep 1
send -- "firejail --debug-check-filename --tmpfs=\"bla&&bla\"\r"
expect {
......
......@@ -4,34 +4,37 @@ set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "mkdir /tmp/firejailtestdir\r"
sleep 1
send -- "ls > /tmp/firejailtestdir/tmpfile\r"
sleep 1
send -- "firejail --profile=tmpfs.profile\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
}
# testing private only
send -- "bash\r"
sleep 1
send -- "ls -l /tmp/firejailtestdir;pwd\r"
send -- "ls -l /var;pwd\r"
expect {
timeout {puts "TESTING ERROR 1.1\n";exit}
"tmpfile" {puts "TESTING ERROR 1\n";exit}
"home"
timeout {puts "TESTING ERROR 1\n";exit}
"total 0"
}
sleep 1
send -- "exit\r"
sleep 1
after 100
send -- "exit\r"
sleep 1
send -- "rm -fr /tmp/firejailtestdir\r"
sleep 1
send -- "firejail --debug-check-filename --profile=tmpfs-bad.profile\r"
expect {
timeout {puts "TESTING ERROR 13.1\n";exit}
"Checking filename bla&&bla"
}
expect {
timeout {puts "TESTING ERROR 13.2\n";exit}
"Error:"
}
expect {
timeout {puts "TESTING ERROR 13.3\n";exit}
"is an invalid filename"
}
after 100
puts "\nall done\n"
#!/bin/bash
./configure 2 > /dev/null
#********************************
# servers
#********************************
......@@ -76,30 +74,7 @@ echo hello > tmpfile
rm -f tmpfile
#********************************
# networking
# firemon
#********************************
echo "TESTING: network interfaces (test/root/net_interface.exp)"
./net_interface.exp
echo "TESTING: firemon --interface (test/root/firemon-interface.exp)"
./firemon-interface.exp
#if [ -f /sys/fs/cgroup/g1/tasks ]
#then
# echo "TESTING: firemon --cgroup (firemon-cgroup.exp)"
# ./firemon-cgroup.exp
#fi
#
#echo "TESTING: chroot resolv.conf (chroot-resolvconf.exp)"
#rm -f tmpfile
#touch tmpfile
#rm -f /tmp/chroot/etc/resolv.conf
#ln -s tmp /tmp/chroot/etc/resolv.conf
#./chroot-resolvconf.exp
#rm -f tmpfile
#rm /tmp/chroot/etc/resolv.conf
#echo "TESTING: chroot (fs_chroot_asroot.exp)"
#./fs_chroot_asroot.exp
echo "TESTING: firemon events (test/root/firemon-events.exp)"
./firemon-events.exp
#/bin/bash
./configure
./root.sh | grep TESTING
\ No newline at end of file
tmpfs /tmp/firejailtestdir
\ No newline at end of file
tmpfs /var
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2016 Firejail Authors
# License GPL v2
set timeout 10
spawn $env(SHELL)
match_max 100000
send -- "firejail\r"
send -- "firejail --name=test1\r"
expect {
timeout {puts "TESTING ERROR 0\n";exit}
"Child process initialized"
......@@ -12,23 +15,26 @@ expect {
sleep 1
spawn $env(SHELL)
send -- "firemon --interface\r"
send -- "firejail --name=test2\r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"lo UP"
"Child process initialized"
}
sleep 1
spawn $env(SHELL)
send -- "firemon --cgroup\r"
sleep 4
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"10.10.20.1/29"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"10.10.50.1/24"
"name=test1"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"br3"
"name=test2"
}
sleep 1
puts "\n"
after 100
puts "\nall done\n"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment