]>
git.ipfire.org Git - thirdparty/kmod.git/blob - testsuite/test-loaded.c
2 * Copyright (C) 2012-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 <libkmod/libkmod.h>
28 #include "testsuite.h"
30 static int loaded_1(const struct test
*t
)
33 const char *null_config
= NULL
;
34 struct kmod_list
*list
, *itr
;
37 ctx
= kmod_new(NULL
, &null_config
);
41 err
= kmod_module_new_from_loaded(ctx
, &list
);
43 fprintf(stderr
, "%s\n", strerror(-err
));
48 printf("Module Size Used by\n");
50 kmod_list_foreach(itr
, list
) {
51 struct kmod_module
*mod
= kmod_module_get_module(itr
);
52 const char *name
= kmod_module_get_name(mod
);
53 int use_count
= kmod_module_get_refcnt(mod
);
54 long size
= kmod_module_get_size(mod
);
55 struct kmod_list
*holders
, *hitr
;
58 printf("%-19s %8ld %d ", name
, size
, use_count
);
59 holders
= kmod_module_get_holders(mod
);
60 kmod_list_foreach(hitr
, holders
) {
61 struct kmod_module
*hm
= kmod_module_get_module(hitr
);
68 fputs(kmod_module_get_name(hm
), stdout
);
69 kmod_module_unref(hm
);
72 kmod_module_unref_list(holders
);
73 kmod_module_unref(mod
);
75 kmod_module_unref_list(list
);
82 .description
= "check if list of module is created",
84 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-loaded/",
88 .out
= TESTSUITE_ROOTFS
"test-loaded/correct.txt",