]> git.ipfire.org Git - thirdparty/kmod.git/blame - testsuite/test-init.c
elf: privately export kmod_elf_get_section()
[thirdparty/kmod.git] / testsuite / test-init.c
CommitLineData
eebca81e
LDM
1#include <stdio.h>
2#include <stdlib.h>
3#include <stddef.h>
4#include <string.h>
5#include <errno.h>
6#include <unistd.h>
7#include <libkmod.h>
8
9#include "testsuite.h"
10
11static int testsuite_init(const struct test *t)
12{
13 struct kmod_ctx *ctx;
14 const char *null_config = NULL;
15
16 ctx = kmod_new(NULL, &null_config);
17 if (ctx == NULL)
18 exit(EXIT_FAILURE);
19
20 kmod_unref(ctx);
21
22 exit(EXIT_SUCCESS);
23}
24static const struct test stestsuite_init = {
25 .name = "testsuite_init",
26 .description = "test if libkmod's init function work",
27 .func = testsuite_init,
28};
29
30static const struct test *tests[] = {
31 &stestsuite_init,
32 NULL,
33};
34
35int main(int argc, char *argv[])
36{
37 const struct test *t;
38 int arg;
39 size_t i;
40
41 arg = test_init(argc, argv, tests);
42 if (arg == 0)
43 return 0;
44
45 if (arg < argc) {
46 t = test_find(tests, argv[arg]);
47 if (t == NULL) {
48 fprintf(stderr, "could not find test %s\n", argv[arg]);
49 exit(EXIT_FAILURE);
50 }
51
52 return test_run(t);
53 }
54
55 for (i = 0; tests[i] != NULL; i++) {
56 if (test_run(tests[i]) != 0)
57 exit(EXIT_FAILURE);
58 }
59
60 exit(EXIT_SUCCESS);
61}