diff options
-rwxr-xr-x | gcov.sh | 21 | ||||
-rw-r--r-- | src/firejail/profile.c | 3 | ||||
-rw-r--r-- | src/firejail/rlimit.c | 12 | ||||
-rw-r--r-- | src/firejail/sandbox.c | 9 |
4 files changed, 38 insertions, 7 deletions
@@ -2,13 +2,13 @@ | |||
2 | 2 | ||
3 | gcov_init() { | 3 | gcov_init() { |
4 | USER=`whoami` | 4 | USER=`whoami` |
5 | firejail --help | 5 | firejail --help > /dev/null |
6 | firemon --help | 6 | firemon --help > /dev/null |
7 | /usr/lib/firejail/fnet --help | 7 | /usr/lib/firejail/fnet --help > /dev/null |
8 | /usr/lib/firejail/fseccomp --help | 8 | /usr/lib/firejail/fseccomp --help > /dev/null |
9 | /usr/lib/firejail/ftee --help | 9 | /usr/lib/firejail/ftee --help > /dev/null |
10 | /usr/lib/firejail/fcopy --help | 10 | /usr/lib/firejail/fcopy --help > /dev/null |
11 | firecfg --help | 11 | firecfg --help > /dev/null |
12 | sudo chown $USER:$USER `find .` | 12 | sudo chown $USER:$USER `find .` |
13 | } | 13 | } |
14 | 14 | ||
@@ -24,6 +24,13 @@ generate() { | |||
24 | 24 | ||
25 | 25 | ||
26 | gcov_init | 26 | gcov_init |
27 | 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 | ||
28 | |||
29 | #make test-environment | ||
30 | #generate | ||
31 | #sleep 2 | ||
32 | #exit | ||
33 | |||
27 | 34 | ||
28 | # running tests | 35 | # running tests |
29 | make test-root | 36 | make test-root |
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index 63678514f..da3daf95a 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -1053,6 +1053,9 @@ void profile_read(const char *fname) { | |||
1053 | // else { | 1053 | // else { |
1054 | // free(ptr); | 1054 | // free(ptr); |
1055 | // } | 1055 | // } |
1056 | #ifdef HAVE_GCOV | ||
1057 | __gcov_flush(); | ||
1058 | #endif | ||
1056 | } | 1059 | } |
1057 | fclose(fp); | 1060 | fclose(fp); |
1058 | } | 1061 | } |
diff --git a/src/firejail/rlimit.c b/src/firejail/rlimit.c index a774fd6f5..47dd846d2 100644 --- a/src/firejail/rlimit.c +++ b/src/firejail/rlimit.c | |||
@@ -27,6 +27,9 @@ void set_rlimits(void) { | |||
27 | if (arg_rlimit_nofile) { | 27 | if (arg_rlimit_nofile) { |
28 | rl.rlim_cur = (rlim_t) cfg.rlimit_nofile; | 28 | rl.rlim_cur = (rlim_t) cfg.rlimit_nofile; |
29 | rl.rlim_max = (rlim_t) cfg.rlimit_nofile; | 29 | rl.rlim_max = (rlim_t) cfg.rlimit_nofile; |
30 | #ifdef HAVE_GCOV // gcov-instrumented programs might crash at this point | ||
31 | __gcov_dump(); | ||
32 | #endif | ||
30 | if (setrlimit(RLIMIT_NOFILE, &rl) == -1) | 33 | if (setrlimit(RLIMIT_NOFILE, &rl) == -1) |
31 | errExit("setrlimit"); | 34 | errExit("setrlimit"); |
32 | if (arg_debug) | 35 | if (arg_debug) |
@@ -36,6 +39,9 @@ void set_rlimits(void) { | |||
36 | if (arg_rlimit_nproc) { | 39 | if (arg_rlimit_nproc) { |
37 | rl.rlim_cur = (rlim_t) cfg.rlimit_nproc; | 40 | rl.rlim_cur = (rlim_t) cfg.rlimit_nproc; |
38 | rl.rlim_max = (rlim_t) cfg.rlimit_nproc; | 41 | rl.rlim_max = (rlim_t) cfg.rlimit_nproc; |
42 | #ifdef HAVE_GCOV | ||
43 | __gcov_dump(); | ||
44 | #endif | ||
39 | if (setrlimit(RLIMIT_NPROC, &rl) == -1) | 45 | if (setrlimit(RLIMIT_NPROC, &rl) == -1) |
40 | errExit("setrlimit"); | 46 | errExit("setrlimit"); |
41 | if (arg_debug) | 47 | if (arg_debug) |
@@ -45,6 +51,9 @@ void set_rlimits(void) { | |||
45 | if (arg_rlimit_fsize) { | 51 | if (arg_rlimit_fsize) { |
46 | rl.rlim_cur = (rlim_t) cfg.rlimit_fsize; | 52 | rl.rlim_cur = (rlim_t) cfg.rlimit_fsize; |
47 | rl.rlim_max = (rlim_t) cfg.rlimit_fsize; | 53 | rl.rlim_max = (rlim_t) cfg.rlimit_fsize; |
54 | #ifdef HAVE_GCOV | ||
55 | __gcov_dump(); | ||
56 | #endif | ||
48 | if (setrlimit(RLIMIT_FSIZE, &rl) == -1) | 57 | if (setrlimit(RLIMIT_FSIZE, &rl) == -1) |
49 | errExit("setrlimit"); | 58 | errExit("setrlimit"); |
50 | if (arg_debug) | 59 | if (arg_debug) |
@@ -54,6 +63,9 @@ void set_rlimits(void) { | |||
54 | if (arg_rlimit_sigpending) { | 63 | if (arg_rlimit_sigpending) { |
55 | rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending; | 64 | rl.rlim_cur = (rlim_t) cfg.rlimit_sigpending; |
56 | rl.rlim_max = (rlim_t) cfg.rlimit_sigpending; | 65 | rl.rlim_max = (rlim_t) cfg.rlimit_sigpending; |
66 | #ifdef HAVE_GCOV | ||
67 | __gcov_dump(); | ||
68 | #endif | ||
57 | if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1) | 69 | if (setrlimit(RLIMIT_SIGPENDING, &rl) == -1) |
58 | errExit("setrlimit"); | 70 | errExit("setrlimit"); |
59 | if (arg_debug) | 71 | if (arg_debug) |
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c index 68b8f554d..50fcd6ed0 100644 --- a/src/firejail/sandbox.c +++ b/src/firejail/sandbox.c | |||
@@ -286,6 +286,9 @@ void start_application(void) { | |||
286 | //**************************************** | 286 | //**************************************** |
287 | if (arg_audit) { | 287 | if (arg_audit) { |
288 | assert(arg_audit_prog); | 288 | assert(arg_audit_prog); |
289 | #ifdef HAVE_GCOV | ||
290 | __gcov_dump(); | ||
291 | #endif | ||
289 | execl(arg_audit_prog, arg_audit_prog, NULL); | 292 | execl(arg_audit_prog, arg_audit_prog, NULL); |
290 | } | 293 | } |
291 | //**************************************** | 294 | //**************************************** |
@@ -309,6 +312,9 @@ void start_application(void) { | |||
309 | if (!arg_command && !arg_quiet) | 312 | if (!arg_command && !arg_quiet) |
310 | printf("Child process initialized\n"); | 313 | printf("Child process initialized\n"); |
311 | 314 | ||
315 | #ifdef HAVE_GCOV | ||
316 | __gcov_dump(); | ||
317 | #endif | ||
312 | execvp(cfg.original_argv[cfg.original_program_index], &cfg.original_argv[cfg.original_program_index]); | 318 | execvp(cfg.original_argv[cfg.original_program_index], &cfg.original_argv[cfg.original_program_index]); |
313 | exit(1); | 319 | exit(1); |
314 | } | 320 | } |
@@ -356,6 +362,9 @@ void start_application(void) { | |||
356 | 362 | ||
357 | if (!arg_command && !arg_quiet) | 363 | if (!arg_command && !arg_quiet) |
358 | printf("Child process initialized\n"); | 364 | printf("Child process initialized\n"); |
365 | #ifdef HAVE_GCOV | ||
366 | __gcov_dump(); | ||
367 | #endif | ||
359 | execvp(arg[0], arg); | 368 | execvp(arg[0], arg); |
360 | } | 369 | } |
361 | 370 | ||