Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Sep 5, 2017
1 parent b3f3992 commit 362d290
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gcov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ gcov_init() {
/usr/lib/firejail/fseccomp --help > /dev/null
/usr/lib/firejail/ftee --help > /dev/null
/usr/lib/firejail/fcopy --help > /dev/null
/usr/lib/firejail/fldd --help > /dev/null
firecfg --help > /dev/null
sudo chown $USER:$USER `find .`
}

generate() {
lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file-new
lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg -d src/fldd --output-file gcov-file-new
lcov --add-tracefile gcov-file-old --add-tracefile gcov-file-new --output-file gcov-file
rm -fr gcov-dir
genhtml -q gcov-file --output-directory gcov-dir
Expand All @@ -24,7 +25,7 @@ generate() {


gcov_init
lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg --output-file gcov-file-old
lcov -q --capture -d src/firejail -d src/firemon -d src/fcopy -d src/fseccomp -d src/fnet -d src/ftee -d src/lib -d src/firecfg -d src/fldd --output-file gcov-file-old

#make test-environment
#generate
Expand Down
5 changes: 5 additions & 0 deletions src/fldd/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ printf("\n");
}


if (strcmp(argv[1], "--help") == 0) {
usage();
return 0;
}

// check program access
if (access(argv[1], R_OK)) {
fprintf(stderr, "Error fldd: cannot access %s\n", argv[1]);
Expand Down
3 changes: 3 additions & 0 deletions test/fs/fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ echo "TESTING: kmsg access (test/fs/kmsg.exp)"
echo "TESTING: read/write /var/tmp (test/fs/fs_var_tmp.exp)"
./fs_var_tmp.exp

echo "TESTING: private-lib (test/fs/private-lib.exp)"
./private-lib.exp

echo "TESTING: read/write /var/lock (test/fs/fs_var_lock.exp)"
./fs_var_lock.exp

Expand Down
44 changes: 44 additions & 0 deletions test/fs/private-lib.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/expect -f
# This file is part of Firejail project
# Copyright (C) 2014-2017 Firejail Authors
# License GPL v2

set timeout 10
spawn $env(SHELL)
match_max 100000

send -- "firejail --private-lib --private-bin=sh,bash,dash,ps,grep,ls,find,echo \r"
expect {
timeout {puts "TESTING ERROR 1\n";exit}
"Child process initialized"
}
after 100

send -- "find /bin; echo done\r"
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"rm" {puts "TESTING ERROR 3\n";exit}
"cp" {puts "TESTING ERROR 4\n";exit}
"done"
}
after 100

send -- "find /lib; echo done\r"
expect {
timeout {puts "TESTING ERROR 5\n";exit}
"modules" {puts "TESTING ERROR 6\n";exit}
"firmware" {puts "TESTING ERROR 7\n";exit}
"libc.so"
}
after 100

send -- "find /usr/lib; echo done\r"
expect {
timeout {puts "TESTING ERROR 8\n";exit}
"grub" {puts "TESTING ERROR 9\n";exit}
"mozilla" {puts "TESTING ERROR 10\n";exit}
"libdl.so"
}
after 100

puts "\nall done\n"
4 changes: 2 additions & 2 deletions test/utils/seccomp-print.exp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ expect {
}
expect {
timeout {puts "TESTING ERROR 2\n";exit}
"init_module"
"delete_module"
}
expect {
timeout {puts "TESTING ERROR 3\n";exit}
"delete_module"
"init_module"
}
expect {
timeout {puts "TESTING ERROR 4\n";exit}
Expand Down

0 comments on commit 362d290

Please sign in to comment.