Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
netblue30 committed Dec 6, 2016
1 parent 667de2f commit 4d0797b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
21 changes: 14 additions & 7 deletions gcov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

gcov_init() {
USER=`whoami`
firejail --help
firemon --help
/usr/lib/firejail/fnet --help
/usr/lib/firejail/fseccomp --help
/usr/lib/firejail/ftee --help
/usr/lib/firejail/fcopy --help
firecfg --help
firejail --help > /dev/null
firemon --help > /dev/null
/usr/lib/firejail/fnet --help > /dev/null
/usr/lib/firejail/fseccomp --help > /dev/null
/usr/lib/firejail/ftee --help > /dev/null
/usr/lib/firejail/fcopy --help > /dev/null
firecfg --help > /dev/null
sudo chown $USER:$USER `find .`
}

Expand All @@ -24,6 +24,13 @@ 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

#make test-environment
#generate
#sleep 2
#exit


# running tests
make test-root
Expand Down
3 changes: 3 additions & 0 deletions src/firejail/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,9 @@ void profile_read(const char *fname) {
// else {
// free(ptr);
// }
#ifdef HAVE_GCOV
__gcov_flush();
#endif
}
fclose(fp);
}
12 changes: 12 additions & 0 deletions src/firejail/rlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ void set_rlimits(void) {
if (arg_rlimit_nofile) {
rl.rlim_cur = (rlim_t) cfg.rlimit_nofile;
rl.rlim_max = (rlim_t) cfg.rlimit_nofile;
#ifdef HAVE_GCOV // gcov-instrumented programs might crash at this point
__gcov_dump();
#endif
if (setrlimit(RLIMIT_NOFILE, &rl) == -1)
errExit("setrlimit");
if (arg_debug)
Expand All @@ -36,6 +39,9 @@ void set_rlimits(void) {
if (arg_rlimit_nproc) {
rl.rlim_cur = (rlim_t) cfg.rlimit_nproc;
rl.rlim_max = (rlim_t) cfg.rlimit_nproc;
#ifdef HAVE_GCOV
__gcov_dump();
#endif
if (setrlimit(RLIMIT_NPROC, &rl) == -1)
errExit("setrlimit");
if (arg_debug)
Expand All @@ -45,6 +51,9 @@ void set_rlimits(void) {
if (arg_rlimit_fsize) {
rl.rlim_cur = (rlim_t) cfg.rlimit_fsize;
rl.rlim_max = (rlim_t) cfg.rlimit_fsize;
#ifdef HAVE_GCOV
__gcov_dump();
#endif
if (setrlimit(RLIMIT_FSIZE, &rl) == -1)
errExit("setrlimit");
if (arg_debug)
Expand All @@ -54,6 +63,9 @@ void set_rlimits(void) {
if (arg_rlimit_sigpending) {
rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending;
rl.rlim_max = (rlim_t) cfg.rlimit_sigpending;
#ifdef HAVE_GCOV
__gcov_dump();
#endif
if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1)
errExit("setrlimit");
if (arg_debug)
Expand Down
9 changes: 9 additions & 0 deletions src/firejail/sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ void start_application(void) {
//****************************************
if (arg_audit) {
assert(arg_audit_prog);
#ifdef HAVE_GCOV
__gcov_dump();
#endif
execl(arg_audit_prog, arg_audit_prog, NULL);
}
//****************************************
Expand All @@ -309,6 +312,9 @@ void start_application(void) {
if (!arg_command && !arg_quiet)
printf("Child process initialized\n");

#ifdef HAVE_GCOV
__gcov_dump();
#endif
execvp(cfg.original_argv[cfg.original_program_index], &cfg.original_argv[cfg.original_program_index]);
exit(1);
}
Expand Down Expand Up @@ -356,6 +362,9 @@ void start_application(void) {

if (!arg_command && !arg_quiet)
printf("Child process initialized\n");
#ifdef HAVE_GCOV
__gcov_dump();
#endif
execvp(arg[0], arg);
}

Expand Down

0 comments on commit 4d0797b

Please sign in to comment.