From 2c846b8d88fc142cbe02b769444b1d30d82865a7 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 16 May 2017 11:14:45 +0200 Subject: [PATCH] tests: only cleanup the gpio-mockup module from the main process In preparation for adding support for subprocesses: store the pid of the main process and use it such that we don't try to unload the mockup module twice leading to a splat from libkmod. Signed-off-by: Bartosz Golaszewski --- tests/gpiod-test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 11330c4..bccf02f 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -61,6 +61,7 @@ static struct { struct kmod_ctx *module_ctx; struct kmod_module *module; struct test_context test_ctx; + pid_t main_pid; } globals; enum { @@ -232,6 +233,10 @@ static bool mockup_loaded(void) static void module_cleanup(void) { + /* Don't cleanup from child processes. */ + if (globals.main_pid != getpid()) + return; + msg("cleaning up"); if (mockup_loaded()) @@ -566,6 +571,7 @@ int main(int argc TEST_UNUSED, char **argv TEST_UNUSED) { struct _test_case *test; + globals.main_pid = getpid(); atexit(module_cleanup); msg("libgpiod test suite"); -- 2.30.2