aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2011-12-04 21:18:21 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2011-12-05 01:45:21 -0200
commit8226058343ac9634b9af0999c9fce84dc71e1bb9 (patch)
tree8aeb7b7393f42ea913d6b136514055c02851fa46 /test
parent69f9dd4369ec9945b3ca3f4aea800fdb027f47da (diff)
downloadkmod-8226058343ac9634b9af0999c9fce84dc71e1bb9.tar.gz
tests: release memory before error exits.
this makes it easier to valgrind the error cases as well.
Diffstat (limited to 'test')
-rw-r--r--test/test-insmod.c4
-rw-r--r--test/test-lookup.c1
-rw-r--r--test/test-rmmod.c1
-rw-r--r--test/test-rmmod2.c4
4 files changed, 8 insertions, 2 deletions
diff --git a/test/test-insmod.c b/test/test-insmod.c
index bbff878..fb58561 100644
--- a/test/test-insmod.c
+++ b/test/test-insmod.c
@@ -29,8 +29,10 @@ int main(int argc, char *argv[])
printf("libkmod version %s\n", VERSION);
err = kmod_module_new_from_path(ctx, path, &mod);
- if (err < 0)
+ if (err < 0) {
+ kmod_unref(ctx);
exit(EXIT_FAILURE);
+ }
printf("Trying insmod '%s'\n", path);
err = kmod_module_insert_module(mod, 0);
diff --git a/test/test-lookup.c b/test/test-lookup.c
index 29a7d3c..5b27628 100644
--- a/test/test-lookup.c
+++ b/test/test-lookup.c
@@ -40,6 +40,7 @@ int main(int argc, char *argv[])
kmod_list_foreach(l, list) {
struct kmod_module *mod = kmod_module_get_module(l);
printf("\t%s\n", kmod_module_get_name(mod));
+ kmod_module_unref(mod);
}
kmod_module_unref_list(list);
diff --git a/test/test-rmmod.c b/test/test-rmmod.c
index 7a7bc5b..e1b9fb4 100644
--- a/test/test-rmmod.c
+++ b/test/test-rmmod.c
@@ -27,6 +27,7 @@ int main(int argc, char *argv[])
err = kmod_loaded_get_list(ctx, &list);
if (err < 0) {
fprintf(stderr, "%s\n", strerror(-err));
+ kmod_unref(ctx);
exit(EXIT_FAILURE);
}
diff --git a/test/test-rmmod2.c b/test/test-rmmod2.c
index c3585be..5e3fa49 100644
--- a/test/test-rmmod2.c
+++ b/test/test-rmmod2.c
@@ -29,8 +29,10 @@ int main(int argc, char *argv[])
printf("libkmod version %s\n", VERSION);
err = kmod_module_new_from_name(ctx, modname, &mod);
- if (err < 0)
+ if (err < 0) {
+ kmod_unref(ctx);
exit(EXIT_FAILURE);
+ }
printf("Trying to remove '%s'\n", modname);
kmod_module_remove_module(mod, 0);