diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-02 16:25:06 +0200 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-06-02 16:25:06 +0200 |
commit | 878ec7942f02ac5169159e7748372e8c86885856 (patch) | |
tree | 56899ecefc6f002abab378e13e1a29acf45bd51a /src/basic | |
parent | test: sync with the fake binary before killing it (diff) | |
download | systemd-878ec7942f02ac5169159e7748372e8c86885856.tar.xz systemd-878ec7942f02ac5169159e7748372e8c86885856.zip |
coverage: add a wrapper for execvpe()
It's the exactly same stuff as for execveat() - gcov doesn't have a
wrapper for execvpe() so introduce our own.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/coverage.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/basic/coverage.h b/src/basic/coverage.h index 3e674a8dba..2c3ff12efe 100644 --- a/src/basic/coverage.h +++ b/src/basic/coverage.h @@ -20,17 +20,16 @@ static inline _Noreturn void _coverage__exit(int status) { } #define _exit(x) _coverage__exit(x) -/* gcov provides wrappers for the exec*() calls but there's none for execveat(), - * which means we lose all coverage prior to the call. To mitigate this, let's - * add a simple execveat() wrapper in gcov's style[0], which dumps and resets - * the coverage data when needed. - * - * This applies only when we're built with -Dfexecve=true. +/* gcov provides wrappers for the exec*() calls but there's none for execveat() + * and execvpe() which means we lose all coverage prior to such call. To mitigate + * this, let's add simple wrappers in gcov's style[0] for these exec*() calls, + * which dump and reset the coverage data as needed. * * [0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=b2ee930864183b78c8826255183ca86e15e21ded;hb=HEAD */ extern int execveat(int, const char *, char * const [], char * const [], int); +extern int execvpe(const char *, char * const [], char * const []); static inline int _coverage_execveat( int dirfd, @@ -45,3 +44,15 @@ static inline int _coverage_execveat( return r; } #define execveat(d,p,a,e,f) _coverage_execveat(d, p, a, e, f) + +static inline int _coverage_execvpe( + const char *file, + char * const argv[], + char * const envp[]) { + __gcov_dump(); + int r = execvpe(file, argv, envp); + __gcov_reset(); + + return r; +} +#define execvpe(f,a,e) _coverage_execvpe(f, a, e) |