diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-12 10:56:06 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-02-12 10:56:06 +0100 |
commit | d39c586ee03387e9d03f4dff1715fcd309738145 (patch) | |
tree | b0f42f8c11d749e82a7c2cacb3d68b1ebbf8ba15 /src/tests/qemu | |
parent | 3d13601173706f8e1b6447e66c70c146b82c310e (diff) |
qemu: more granular memleak detection
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/tests/qemu')
-rw-r--r-- | src/tests/qemu/init.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/tests/qemu/init.c b/src/tests/qemu/init.c index de0b0eb..8d783e9 100644 --- a/src/tests/qemu/init.c +++ b/src/tests/qemu/init.c @@ -98,6 +98,8 @@ static void mount_filesystems(void) panic("tmpfs mount"); if (mount("none", "/run", "tmpfs", 0, NULL)) panic("tmpfs mount"); + if (mount("none", "/sys/kernel/debug", "debugfs", 0, NULL)) + ; /* Not a problem if it fails.*/ if (symlink("/run", "/var/run")) panic("run symlink"); if (symlink("/proc/self/fd", "/dev/fd")) @@ -217,12 +219,22 @@ static void ensure_console(void) panic("Unable to open console device"); } -static void check_leaks(void) +static void clear_leaks(void) { int fd; - if (mount("none", "/sys/kernel/debug", "debugfs", 0, NULL) < 0) + fd = open("/sys/kernel/debug/kmemleak", O_WRONLY); + if (fd < 0) return; + pretty_message("[+] Starting memory leak detection..."); + write(fd, "clear\n", 5); + close(fd); +} + +static void check_leaks(void) +{ + int fd; + fd = open("/sys/kernel/debug/kmemleak", O_WRONLY); if (fd < 0) return; @@ -247,6 +259,7 @@ int main(int argc, char *argv[]) mount_filesystems(); kmod_selftests(); enable_logging(); + clear_leaks(); launch_tests(); check_leaks(); poweroff(); |