]> git.ipfire.org Git - thirdparty/kmod.git/blame - testsuite/test-modprobe.c
testsuite: check if module is in kernel for return code
[thirdparty/kmod.git] / testsuite / test-modprobe.c
CommitLineData
976ea8c3
LDM
1/*
2 * Copyright (C) 2012 ProFUSION embedded systems
3 *
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.
8 *
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.
13 *
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/>.
16 */
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <stddef.h>
21#include <errno.h>
22#include <unistd.h>
23#include <inttypes.h>
24#include <string.h>
25
26#include "testsuite.h"
27
32d29b35 28static __noreturn int modprobe_show_depends(const struct test *t)
976ea8c3
LDM
29{
30 const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
31 const char *const args[] = {
32 progname,
33 "--show-depends", "btusb",
34 NULL,
35 };
36
37 test_spawn_prog(progname, args);
38 exit(EXIT_FAILURE);
39}
40static DEFINE_TEST(modprobe_show_depends,
41 .description = "check if output for modprobe --show-depends is correct for loaded modules",
42 .config = {
43 [TC_UNAME_R] = "4.4.4",
44 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/show-depends",
45 },
46 .output = {
47 .stdout = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct.txt",
48 });
49
32d29b35 50static __noreturn int modprobe_show_depends2(const struct test *t)
976ea8c3
LDM
51{
52 const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
53 const char *const args[] = {
54 progname,
55 "--show-depends", "psmouse",
56 NULL,
57 };
58
59 test_spawn_prog(progname, args);
60 exit(EXIT_FAILURE);
61}
62static DEFINE_TEST(modprobe_show_depends2,
63 .description = "check if output for modprobe --show-depends is correct",
64 .config = {
65 [TC_UNAME_R] = "4.4.4",
66 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/show-depends",
67 },
68 .output = {
69 .stdout = TESTSUITE_ROOTFS "test-modprobe/show-depends/correct-psmouse.txt",
70 });
a7f5300d
LDM
71
72static __noreturn int modprobe_builtin(const struct test *t)
73{
74 const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
75 const char *const args[] = {
76 progname,
77 "unix",
78 NULL,
79 };
80
81 test_spawn_prog(progname, args);
82 exit(EXIT_FAILURE);
83}
84static DEFINE_TEST(modprobe_builtin,
85 .description = "check if modprobe return 0 for builtin",
a7f5300d
LDM
86 .config = {
87 [TC_UNAME_R] = "4.4.4",
88 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/builtin",
89 });
90
976ea8c3
LDM
91static const struct test *tests[] = {
92 &smodprobe_show_depends,
93 &smodprobe_show_depends2,
a7f5300d 94 &smodprobe_builtin,
976ea8c3
LDM
95 NULL,
96};
97
98TESTSUITE_MAIN(tests);