]>
git.ipfire.org Git - thirdparty/kmod.git/blob - testsuite/test-blacklist.c
2 * Copyright (C) 2011-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, see <http://www.gnu.org/licenses/>.
26 #include <shared/util.h>
28 #include <libkmod/libkmod.h>
30 /* good luck bulding a kmod_list outside of the library... makes this blacklist
31 * function rather pointless */
32 #include <libkmod/libkmod-internal.h>
34 /* FIXME: hack, change name so we don't clash */
36 #include "testsuite.h"
38 static int blacklist_1(const struct test
*t
)
41 struct kmod_list
*list
= NULL
, *l
, *filtered
;
42 struct kmod_module
*mod
;
46 const char *names
[] = { "pcspkr", "pcspkr2", "floppy", "ext4", NULL
};
49 ctx
= kmod_new(NULL
, NULL
);
53 for(name
= names
; *name
; name
++) {
54 err
= kmod_module_new_from_name(ctx
, *name
, &mod
);
57 list
= kmod_list_append(list
, mod
);
60 err
= kmod_module_apply_filter(ctx
, KMOD_FILTER_BLACKLIST
, list
,
63 ERR("Could not filter: %s\n", strerror(-err
));
66 if (filtered
== NULL
) {
67 ERR("All modules were filtered out!\n");
71 kmod_list_foreach(l
, filtered
) {
73 mod
= kmod_module_get_module(l
);
74 modname
= kmod_module_get_name(mod
);
75 if (streq("pcspkr", modname
) || streq("floppy", modname
))
78 kmod_module_unref(mod
);
84 kmod_module_unref_list(filtered
);
85 kmod_module_unref_list(list
);
91 kmod_module_unref_list(list
);
97 DEFINE_TEST(blacklist_1
,
98 .description
= "check if modules are correctly blacklisted",
100 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-blacklist/",