]>
git.ipfire.org Git - thirdparty/kmod.git/blob - testsuite/test-dependencies.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 #include "testsuite.h"
32 #define TEST_UNAME "4.0.20-kmod"
34 static noreturn
int test_dependencies(const struct test
*t
)
37 struct kmod_module
*mod
= NULL
;
38 struct kmod_list
*list
, *l
;
41 int fooa
= 0, foob
= 0, fooc
= 0;
43 ctx
= kmod_new(NULL
, NULL
);
47 err
= kmod_module_new_from_name(ctx
, "mod-foo", &mod
);
48 if (err
< 0 || mod
== NULL
) {
53 list
= kmod_module_get_dependencies(mod
);
55 kmod_list_foreach(l
, list
) {
56 struct kmod_module
*m
= kmod_module_get_module(l
);
57 const char *name
= kmod_module_get_name(m
);
59 if (streq(name
, "mod_foo_a"))
61 if (streq(name
, "mod_foo_b"))
63 else if (streq(name
, "mod_foo_c"))
66 fprintf(stderr
, "name=%s", name
);
71 /* fooa, foob, fooc */
72 if (len
!= 3 || !fooa
|| !foob
|| !fooc
)
75 kmod_module_unref_list(list
);
76 kmod_module_unref(mod
);
81 DEFINE_TEST(test_dependencies
,
82 .description
= "test if kmod_module_get_dependencies works",
84 [TC_UNAME_R
] = TEST_UNAME
,
85 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-dependencies/",