libkmod: fix return error when opening index
[platform/upstream/kmod.git] / testsuite / test-tools.c
1 /*
2  * Copyright (C) 2015 Intel Corporation. All rights reserved.
3  *
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.
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 GNU
12  * Lesser General Public License for more details.
13  *
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/>.
16  */
17
18 #include <errno.h>
19 #include <inttypes.h>
20 #include <stddef.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25
26 #include "testsuite.h"
27
28 static noreturn int kmod_tool_insert(const struct test *t)
29 {
30         const char *progname = ABS_TOP_BUILDDIR "/tools/kmod";
31         const char *const args[] = {
32                 progname,
33                 "insert", "mod-simple",
34                 NULL,
35         };
36
37         test_spawn_prog(progname, args);
38         exit(EXIT_FAILURE);
39 }
40 DEFINE_TEST(kmod_tool_insert,
41         .description = "check kmod insert",
42         .config = {
43                 [TC_UNAME_R] = "4.4.4",
44                 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-tools/insert",
45                 [TC_INIT_MODULE_RETCODES] = "",
46         },
47         .modules_loaded = "mod-simple",
48         );
49
50 static noreturn int kmod_tool_remove(const struct test *t)
51 {
52         const char *progname = ABS_TOP_BUILDDIR "/tools/kmod";
53         const char *const args[] = {
54                 progname,
55                 "remove", "mod-simple",
56                 NULL,
57         };
58
59         test_spawn_prog(progname, args);
60         exit(EXIT_FAILURE);
61 }
62 DEFINE_TEST(kmod_tool_remove,
63         .description = "check kmod remove",
64         .config = {
65                 [TC_UNAME_R] = "4.4.4",
66                 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-tools/remove",
67                 [TC_DELETE_MODULE_RETCODES] = "",
68         },
69         );
70
71 TESTSUITE_MAIN();