2 * Copyright (C) 2015 Intel Corporation. All rights reserved.
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, see <http://www.gnu.org/licenses/>.
28 #include <libkmod/libkmod.h>
30 #include <shared/macro.h>
32 #include "testsuite.h"
35 static noreturn
int test_initstate_from_lookup(const struct test
*t
)
38 struct kmod_list
*list
= NULL
;
39 struct kmod_module
*mod
;
40 const char *null_config
= NULL
;
43 ctx
= kmod_new(NULL
, &null_config
);
47 err
= kmod_module_new_from_lookup(ctx
, "fake-builtin", &list
);
49 ERR("could not create module from lookup: %s\n", strerror(-err
));
54 ERR("could not create module from lookup: module not found: fake-builtin\n");
58 mod
= kmod_module_get_module(list
);
60 r
= kmod_module_get_initstate(mod
);
61 if (r
!= KMOD_MODULE_BUILTIN
) {
62 ERR("module should have builtin state but is: %s\n",
63 kmod_module_initstate_str(r
));
67 kmod_module_unref(mod
);
68 kmod_module_unref_list(list
);
73 DEFINE_TEST(test_initstate_from_lookup
,
74 .description
= "test if libkmod return correct initstate for builtin module from lookup",
76 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-initstate",
77 [TC_UNAME_R
] = "4.4.4",
81 static noreturn
int test_initstate_from_name(const struct test
*t
)
84 struct kmod_module
*mod
= NULL
;
85 const char *null_config
= NULL
;
88 ctx
= kmod_new(NULL
, &null_config
);
92 err
= kmod_module_new_from_name(ctx
, "fake-builtin", &mod
);
94 ERR("could not create module from lookup: %s\n", strerror(-err
));
99 ERR("could not create module from lookup: module not found: fake-builtin\n");
103 r
= kmod_module_get_initstate(mod
);
104 if (r
!= KMOD_MODULE_BUILTIN
) {
105 ERR("module should have builtin state but is: %s\n",
106 kmod_module_initstate_str(r
));
110 kmod_module_unref(mod
);
115 DEFINE_TEST(test_initstate_from_name
,
116 .description
= "test if libkmod return correct initstate for builtin module from name",
118 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-initstate",
119 [TC_UNAME_R
] = "4.4.4",