2 * Copyright (C) 2012-2013 ProFUSION embedded systems
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include "testsuite.h"
29 static noreturn
int test_initlib(const struct test
*t
)
32 const char *null_config
= NULL
;
34 ctx
= kmod_new(NULL
, &null_config
);
42 static DEFINE_TEST(test_initlib
,
43 .description
= "test if libkmod's init function work");
45 static noreturn
int test_insert(const struct test
*t
)
48 struct kmod_module
*mod
;
49 const char *null_config
= NULL
;
52 ctx
= kmod_new(NULL
, &null_config
);
56 err
= kmod_module_new_from_path(ctx
, "/ext4-x86_64.ko", &mod
);
58 ERR("could not create module from path: %m\n");
62 err
= kmod_module_insert_module(mod
, 0, NULL
);
64 ERR("could not insert module: %m\n");
71 static DEFINE_TEST(test_insert
,
72 .description
= "test if libkmod's insert_module returns ok",
74 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-init/",
75 [TC_INIT_MODULE_RETCODES
] = "bla:1:20",
77 .modules_loaded
= "ext4",
80 static noreturn
int test_remove(const struct test
*t
)
83 struct kmod_module
*mod
;
84 const char *null_config
= NULL
;
87 ctx
= kmod_new(NULL
, &null_config
);
91 err
= kmod_module_new_from_name(ctx
, "ext4", &mod
);
93 ERR("could not create module from name: %m\n");
97 err
= kmod_module_remove_module(mod
, 0);
99 ERR("could not remove module: %m\n");
106 static DEFINE_TEST(test_remove
,
107 .description
= "test if libkmod's remove_module returns ok",
109 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-remove/",
110 [TC_DELETE_MODULE_RETCODES
] = "bla:1:20",
114 static const struct test
*tests
[] = {
121 TESTSUITE_MAIN(tests
);