2 * Copyright (C) 2012 ProFUSION embedded systems
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "testsuite.h"
28 static int test_initlib(const struct test
*t
)
31 const char *null_config
= NULL
;
33 ctx
= kmod_new(NULL
, &null_config
);
41 static DEFINE_TEST(test_initlib
,
42 .description
= "test if libkmod's init function work");
44 static int test_insert(const struct test
*t
)
47 struct kmod_module
*mod
;
48 const char *null_config
= NULL
;
51 ctx
= kmod_new(NULL
, &null_config
);
55 err
= kmod_module_new_from_path(ctx
, "/ext4-x86_64.ko", &mod
);
57 ERR("could not create module from path: %m\n");
61 err
= kmod_module_insert_module(mod
, 0, NULL
);
63 ERR("could not insert module: %m\n");
70 static DEFINE_TEST(test_insert
,
71 .description
= "test if libkmod's insert_module returns ok",
73 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modinfo/",
74 [TC_INIT_MODULE_RETCODES
] = "bla:1:20",
78 static int test_remove(const struct test
*t
)
81 struct kmod_module
*mod
;
82 const char *null_config
= NULL
;
85 ctx
= kmod_new(NULL
, &null_config
);
89 err
= kmod_module_new_from_name(ctx
, "ext4", &mod
);
91 ERR("could not create module from name: %m\n");
95 err
= kmod_module_remove_module(mod
, 0);
97 ERR("could not remove module: %m\n");
104 static DEFINE_TEST(test_remove
,
105 .description
= "test if libkmod's remove_module returns ok",
107 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-modinfo/",
108 [TC_DELETE_MODULE_RETCODES
] = "bla:1:20",
112 static const struct test
*tests
[] = {
119 TESTSUITE_MAIN(tests
);