]>
Commit | Line | Data |
---|---|---|
b0c9fc85 | 1 | /* |
e6b0e49b | 2 | * Copyright (C) 2012-2013 ProFUSION embedded systems |
b0c9fc85 LDM |
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, write to the Free Software | |
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
b0c9fc85 | 19 | #include <errno.h> |
b0c9fc85 | 20 | #include <inttypes.h> |
c2e4286b LDM |
21 | #include <stddef.h> |
22 | #include <stdio.h> | |
23 | #include <stdlib.h> | |
b0c9fc85 | 24 | #include <string.h> |
c2e4286b | 25 | #include <unistd.h> |
b0c9fc85 LDM |
26 | |
27 | #include "testsuite.h" | |
28 | ||
29 | #define MODULES_ORDER_UNAME "3.5.4-1-ARCH" | |
30 | #define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed" | |
31 | #define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME | |
d96ca9c4 | 32 | static noreturn int depmod_modules_order_for_compressed(const struct test *t) |
b0c9fc85 | 33 | { |
b6adccd6 | 34 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
b0c9fc85 LDM |
35 | const char *const args[] = { |
36 | progname, | |
37 | NULL, | |
38 | }; | |
39 | ||
40 | test_spawn_prog(progname, args); | |
41 | exit(EXIT_FAILURE); | |
42 | } | |
f1155c15 | 43 | DEFINE_TEST(depmod_modules_order_for_compressed, |
b0c9fc85 LDM |
44 | .description = "check if depmod let aliases in right order when using compressed modules", |
45 | .config = { | |
46 | [TC_UNAME_R] = MODULES_ORDER_UNAME, | |
47 | [TC_ROOTFS] = MODULES_ORDER_ROOTFS, | |
48 | }, | |
49 | .output = { | |
50 | .files = (const struct keyval[]) { | |
51 | { MODULES_ORDER_LIB_MODULES "/correct-modules.alias", | |
52 | MODULES_ORDER_LIB_MODULES "/modules.alias" }, | |
53 | { } | |
54 | }, | |
55 | }); | |
56 | ||
aa0abec7 LDM |
57 | #define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple" |
58 | static noreturn int depmod_search_order_simple(const struct test *t) | |
59 | { | |
60 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; | |
61 | const char *const args[] = { | |
62 | progname, | |
63 | NULL, | |
64 | }; | |
65 | ||
66 | test_spawn_prog(progname, args); | |
67 | exit(EXIT_FAILURE); | |
68 | } | |
f1155c15 | 69 | DEFINE_TEST(depmod_search_order_simple, |
aa0abec7 LDM |
70 | .description = "check if depmod honor search order in config", |
71 | .config = { | |
72 | [TC_UNAME_R] = "4.4.4", | |
73 | [TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS, | |
74 | }, | |
75 | .output = { | |
76 | .files = (const struct keyval[]) { | |
77 | { SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", | |
78 | SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/modules.dep" }, | |
79 | { } | |
80 | }, | |
81 | }); | |
82 | ||
ad7f1757 LDM |
83 | #define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix" |
84 | static noreturn int depmod_search_order_same_prefix(const struct test *t) | |
85 | { | |
86 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; | |
87 | const char *const args[] = { | |
88 | progname, | |
89 | NULL, | |
90 | }; | |
91 | ||
92 | test_spawn_prog(progname, args); | |
93 | exit(EXIT_FAILURE); | |
94 | } | |
f1155c15 | 95 | DEFINE_TEST(depmod_search_order_same_prefix, |
ad7f1757 LDM |
96 | .description = "check if depmod honor search order in config with same prefix", |
97 | .config = { | |
98 | [TC_UNAME_R] = "4.4.4", | |
99 | [TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS, | |
100 | }, | |
101 | .output = { | |
102 | .files = (const struct keyval[]) { | |
103 | { SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", | |
104 | SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/modules.dep" }, | |
105 | { } | |
106 | }, | |
107 | }); | |
108 | ||
8183cfa9 LDM |
109 | #define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop" |
110 | static noreturn int depmod_detect_loop(const struct test *t) | |
111 | { | |
112 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; | |
113 | const char *const args[] = { | |
114 | progname, | |
115 | NULL, | |
116 | }; | |
117 | ||
118 | test_spawn_prog(progname, args); | |
119 | exit(EXIT_FAILURE); | |
120 | } | |
f1155c15 | 121 | DEFINE_TEST(depmod_detect_loop, |
8183cfa9 LDM |
122 | .description = "check if depmod detects module loops correctly", |
123 | .config = { | |
124 | [TC_UNAME_R] = "4.4.4", | |
125 | [TC_ROOTFS] = DETECT_LOOP_ROOTFS, | |
126 | }, | |
127 | .expected_fail = true, | |
7a2d0e61 LDM |
128 | .output = { |
129 | .err = DETECT_LOOP_ROOTFS "/correct.txt", | |
130 | }); | |
8183cfa9 | 131 | |
b0c9fc85 LDM |
132 | |
133 | static const struct test *tests[] = { | |
81bf88d6 | 134 | #ifdef ENABLE_ZLIB |
b0c9fc85 | 135 | &sdepmod_modules_order_for_compressed, |
81bf88d6 | 136 | #endif |
aa0abec7 | 137 | &sdepmod_search_order_simple, |
ad7f1757 | 138 | &sdepmod_search_order_same_prefix, |
8183cfa9 | 139 | &sdepmod_detect_loop, |
b0c9fc85 LDM |
140 | NULL, |
141 | }; | |
142 | ||
143 | TESTSUITE_MAIN(tests); |