ctx = kmod_new(NULL, NULL);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
for (size_t i = 0; i < ARRAY_SIZE(names); i++) {
err = kmod_module_new_from_name(ctx, names[i], &mod);
#define TEST_UNAME "4.0.20-kmod"
-static noreturn int test_dependencies(void)
+static int test_dependencies(void)
{
struct kmod_ctx *ctx;
struct kmod_module *mod = NULL;
ctx = kmod_new(NULL, NULL);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_name(ctx, "mod-foo", &mod);
if (err < 0 || mod == NULL) {
kmod_unref(ctx);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
list = kmod_module_get_dependencies(mod);
/* fooa, foob, fooc */
if (len != 3 || !fooa || !foob || !fooc)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
kmod_module_unref_list(list);
kmod_module_unref(mod);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(test_dependencies,
.description = "test if kmod_module_get_dependencies works",
#include "testsuite.h"
-static noreturn int test_load_resources(void)
+static int test_load_resources(void)
{
struct kmod_ctx *ctx;
const char *null_config = NULL;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
kmod_set_log_priority(ctx, 7);
err = kmod_load_resources(ctx);
if (err != 0) {
ERR("could not load libkmod resources: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST_WITH_FUNC(
test_load_resource1, test_load_resources,
[TC_UNAME_R] = "5.6.0",
});
-static noreturn int test_initlib(void)
+static int test_initlib(void)
{
struct kmod_ctx *ctx;
const char *null_config = NULL;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(test_initlib, .description = "test if libkmod's init function work");
-static noreturn int test_insert(void)
+static int test_insert(void)
{
struct kmod_ctx *ctx;
struct kmod_module *mod;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_path(ctx, "/mod-simple.ko", &mod);
if (err != 0) {
ERR("could not create module from path: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_insert_module(mod, 0, NULL);
if (err != 0) {
ERR("could not insert module: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_module_unref(mod);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(test_insert,
.description = "test if libkmod's insert_module returns ok",
},
.modules_loaded = "mod_simple");
-static noreturn int test_remove(void)
+static int test_remove(void)
{
struct kmod_ctx *ctx;
struct kmod_module *mod_simple, *mod_bla;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_name(ctx, "mod-simple", &mod_simple);
if (err != 0) {
ERR("could not create module from name: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_new_from_name(ctx, "bla", &mod_bla);
if (err != 0) {
ERR("could not create module from name: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_remove_module(mod_simple, 0);
if (err != 0) {
ERR("could not remove module: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_remove_module(mod_bla, 0);
if (err != -ENOENT) {
ERR("wrong return code for failure test: %d\n", err);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_module_unref(mod_bla);
kmod_module_unref(mod_simple);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(
test_remove, .description = "test if libkmod's remove_module returns ok",
#include "testsuite.h"
-static noreturn int test_initstate_from_lookup(void)
+static int test_initstate_from_lookup(void)
{
struct kmod_ctx *ctx;
struct kmod_list *list = NULL;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_lookup(ctx, "fake-builtin", &list);
if (err < 0) {
ERR("could not create module from lookup: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (!list) {
ERR("could not create module from lookup: module not found: fake-builtin\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
mod = kmod_module_get_module(list);
if (r != KMOD_MODULE_BUILTIN) {
ERR("module should have builtin state but is: %s\n",
kmod_module_initstate_str(r));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_module_unref(mod);
kmod_module_unref_list(list);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(
test_initstate_from_lookup,
[TC_UNAME_R] = "4.4.4",
});
-static noreturn int test_initstate_from_name(void)
+static int test_initstate_from_name(void)
{
struct kmod_ctx *ctx;
struct kmod_module *mod = NULL;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_name(ctx, "fake-builtin", &mod);
if (err != 0) {
ERR("could not create module from lookup: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (!mod) {
ERR("could not create module from lookup: module not found: fake-builtin\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
r = kmod_module_get_initstate(mod);
if (r != KMOD_MODULE_BUILTIN) {
ERR("module should have builtin state but is: %s\n",
kmod_module_initstate_str(r));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_module_unref(mod);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(test_initstate_from_name,
.description =
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_loaded(ctx, &list);
if (err < 0) {
fprintf(stderr, "%s\n", strerror(-err));
kmod_unref(ctx);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
printf("Module Size Used by\n");
ctx = kmod_new(NULL, NULL);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
for (mod_index = 0; mod_index < ARRAY_SIZE(test_modules); mod_index++) {
modname = test_modules[mod_index].modname;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
for (size_t i = 0; i < ARRAY_SIZE(modnames); i++) {
err = kmod_module_new_from_name(ctx, modnames[i], &mod);
if (err < 0)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
printf("modname: %s\n", kmod_module_get_name(mod));
kmod_module_unref(mod);
ctx = kmod_new(NULL, NULL);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
for (size_t i = 0; i < ARRAY_SIZE(modnames); i++) {
struct kmod_list *l, *list = NULL;
err = kmod_module_new_from_lookup(ctx, modnames[i], &list);
if (err < 0)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
kmod_list_foreach(l, list) {
struct kmod_module *m;
#include "testsuite.h"
-static noreturn int test_remove(void)
+static int test_remove(void)
{
struct kmod_ctx *ctx;
struct kmod_module *mod;
ctx = kmod_new(NULL, &null_config);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
err = kmod_module_new_from_path(ctx, "/mod-simple.ko", &mod);
if (err != 0) {
ERR("could not create module from path: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_insert_module(mod, 0, NULL);
if (err != 0) {
ERR("could not insert module: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
err = kmod_module_remove_module(mod, 0);
if (err != 0) {
ERR("could not remove module: %s\n", strerror(-err));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
if (stat("/sys/module/mod_simple", &st) == 0 && S_ISDIR(st.st_mode)) {
ERR("could not remove module directory.\n");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_module_unref(mod);
kmod_unref(ctx);
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(test_remove,
.description = "test if libkmod's delete_module removes module directory",
#include "testsuite.h"
#define TEST_UNAME "4.0.20-kmod"
-static noreturn int testsuite_uname(void)
+static int testsuite_uname(void)
{
struct utsname u;
int err = uname(&u);
if (err < 0)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
if (!streq(u.release, TEST_UNAME)) {
const char *ldpreload = getenv("LD_PRELOAD");
ERR("u.release=%s should be %s\n", u.release, TEST_UNAME);
ERR("LD_PRELOAD=%s\n", ldpreload);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
- exit(EXIT_SUCCESS);
+ return EXIT_SUCCESS;
}
DEFINE_TEST(testsuite_uname, .description = "test if trap to uname() works",
.config = {
ctx = kmod_new(NULL, NULL);
if (ctx == NULL)
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
for (size_t i = 0; i < ARRAY_SIZE(mod_name); i++) {
struct kmod_list *list = NULL;
if (list == NULL || err < 0) {
fprintf(stderr, "module %s not found in directory %s\n",
mod_name[i], ctx ? kmod_get_dirname(ctx) : "(missing)");
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
mod = kmod_module_get_module(list);
if (err) {
fprintf(stderr, "weak dependencies can not be read for %s (%d)\n",
mod_name[i], err);
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
kmod_list_foreach(itr, mod_list) {