Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 1 | /* |
Lucas De Marchi | e6b0e49 | 2013-01-16 11:27:21 -0200 | [diff] [blame] | 2 | * Copyright (C) 2012-2013 ProFUSION embedded systems |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 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 |
Lucas De Marchi | dea2dfe | 2014-12-25 23:32:03 -0200 | [diff] [blame] | 15 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 16 | */ |
| 17 | |
Lucas De Marchi | c2e4286 | 2014-10-03 01:41:42 -0300 | [diff] [blame] | 18 | #include <errno.h> |
| 19 | #include <inttypes.h> |
| 20 | #include <stddef.h> |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 23 | #include <string.h> |
Lucas De Marchi | c2e4286 | 2014-10-03 01:41:42 -0300 | [diff] [blame] | 24 | #include <unistd.h> |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 25 | |
| 26 | #include "testsuite.h" |
| 27 | |
Lucas De Marchi | 2a38870 | 2015-02-19 19:50:16 -0200 | [diff] [blame] | 28 | #define MODULES_ORDER_UNAME "4.4.4" |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 29 | #define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-compressed" |
| 30 | #define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MODULES_ORDER_UNAME |
Lucas De Marchi | d96ca9c | 2013-12-17 19:10:16 -0200 | [diff] [blame] | 31 | static noreturn int depmod_modules_order_for_compressed(const struct test *t) |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 32 | { |
Lucas De Marchi | b6adccd | 2013-07-04 16:01:55 -0300 | [diff] [blame] | 33 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 34 | const char *const args[] = { |
| 35 | progname, |
| 36 | NULL, |
| 37 | }; |
| 38 | |
| 39 | test_spawn_prog(progname, args); |
| 40 | exit(EXIT_FAILURE); |
| 41 | } |
Lucas De Marchi | 4328982 | 2014-10-09 14:29:04 -0300 | [diff] [blame] | 42 | |
Lucas De Marchi | f1155c1 | 2014-10-09 13:00:30 -0300 | [diff] [blame] | 43 | DEFINE_TEST(depmod_modules_order_for_compressed, |
Marius Bakke | 847247a | 2020-08-01 18:02:22 +0200 | [diff] [blame] | 44 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
| 45 | .skip = true, |
| 46 | #endif |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 47 | .description = "check if depmod let aliases in right order when using compressed modules", |
| 48 | .config = { |
| 49 | [TC_UNAME_R] = MODULES_ORDER_UNAME, |
| 50 | [TC_ROOTFS] = MODULES_ORDER_ROOTFS, |
| 51 | }, |
| 52 | .output = { |
| 53 | .files = (const struct keyval[]) { |
| 54 | { MODULES_ORDER_LIB_MODULES "/correct-modules.alias", |
| 55 | MODULES_ORDER_LIB_MODULES "/modules.alias" }, |
| 56 | { } |
| 57 | }, |
| 58 | }); |
| 59 | |
Lucas De Marchi | aa0abec | 2014-03-19 07:59:38 -0300 | [diff] [blame] | 60 | #define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple" |
| 61 | static noreturn int depmod_search_order_simple(const struct test *t) |
| 62 | { |
| 63 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 64 | const char *const args[] = { |
| 65 | progname, |
| 66 | NULL, |
| 67 | }; |
| 68 | |
| 69 | test_spawn_prog(progname, args); |
| 70 | exit(EXIT_FAILURE); |
| 71 | } |
Lucas De Marchi | f1155c1 | 2014-10-09 13:00:30 -0300 | [diff] [blame] | 72 | DEFINE_TEST(depmod_search_order_simple, |
Lucas De Marchi | aa0abec | 2014-03-19 07:59:38 -0300 | [diff] [blame] | 73 | .description = "check if depmod honor search order in config", |
| 74 | .config = { |
| 75 | [TC_UNAME_R] = "4.4.4", |
| 76 | [TC_ROOTFS] = SEARCH_ORDER_SIMPLE_ROOTFS, |
| 77 | }, |
| 78 | .output = { |
| 79 | .files = (const struct keyval[]) { |
| 80 | { SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", |
| 81 | SEARCH_ORDER_SIMPLE_ROOTFS "/lib/modules/4.4.4/modules.dep" }, |
| 82 | { } |
| 83 | }, |
| 84 | }); |
| 85 | |
Lucas De Marchi | ad7f175 | 2014-03-19 09:15:59 -0300 | [diff] [blame] | 86 | #define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix" |
| 87 | static noreturn int depmod_search_order_same_prefix(const struct test *t) |
| 88 | { |
| 89 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 90 | const char *const args[] = { |
| 91 | progname, |
| 92 | NULL, |
| 93 | }; |
| 94 | |
| 95 | test_spawn_prog(progname, args); |
| 96 | exit(EXIT_FAILURE); |
| 97 | } |
Lucas De Marchi | f1155c1 | 2014-10-09 13:00:30 -0300 | [diff] [blame] | 98 | DEFINE_TEST(depmod_search_order_same_prefix, |
Lucas De Marchi | ad7f175 | 2014-03-19 09:15:59 -0300 | [diff] [blame] | 99 | .description = "check if depmod honor search order in config with same prefix", |
| 100 | .config = { |
| 101 | [TC_UNAME_R] = "4.4.4", |
| 102 | [TC_ROOTFS] = SEARCH_ORDER_SAME_PREFIX_ROOTFS, |
| 103 | }, |
| 104 | .output = { |
| 105 | .files = (const struct keyval[]) { |
| 106 | { SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", |
| 107 | SEARCH_ORDER_SAME_PREFIX_ROOTFS "/lib/modules/4.4.4/modules.dep" }, |
| 108 | { } |
| 109 | }, |
| 110 | }); |
| 111 | |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 112 | #define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop" |
| 113 | static noreturn int depmod_detect_loop(const struct test *t) |
| 114 | { |
| 115 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 116 | const char *const args[] = { |
| 117 | progname, |
| 118 | NULL, |
| 119 | }; |
| 120 | |
| 121 | test_spawn_prog(progname, args); |
| 122 | exit(EXIT_FAILURE); |
| 123 | } |
Lucas De Marchi | f1155c1 | 2014-10-09 13:00:30 -0300 | [diff] [blame] | 124 | DEFINE_TEST(depmod_detect_loop, |
Marius Bakke | 847247a | 2020-08-01 18:02:22 +0200 | [diff] [blame] | 125 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
| 126 | .skip = true, |
| 127 | #endif |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 128 | .description = "check if depmod detects module loops correctly", |
| 129 | .config = { |
| 130 | [TC_UNAME_R] = "4.4.4", |
| 131 | [TC_ROOTFS] = DETECT_LOOP_ROOTFS, |
| 132 | }, |
| 133 | .expected_fail = true, |
Lucas De Marchi | 7a2d0e6 | 2014-05-30 10:26:17 -0300 | [diff] [blame] | 134 | .output = { |
| 135 | .err = DETECT_LOOP_ROOTFS "/correct.txt", |
| 136 | }); |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 137 | |
Yauheni Kaliuta | df492f5 | 2017-05-09 22:09:24 +0300 | [diff] [blame] | 138 | #define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-first" |
| 139 | static noreturn int depmod_search_order_external_first(const struct test *t) |
| 140 | { |
| 141 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 142 | const char *const args[] = { |
| 143 | progname, |
| 144 | NULL, |
| 145 | }; |
| 146 | |
| 147 | test_spawn_prog(progname, args); |
| 148 | exit(EXIT_FAILURE); |
| 149 | } |
| 150 | DEFINE_TEST(depmod_search_order_external_first, |
Marius Bakke | 847247a | 2020-08-01 18:02:22 +0200 | [diff] [blame] | 151 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
| 152 | .skip = true, |
| 153 | #endif |
Yauheni Kaliuta | df492f5 | 2017-05-09 22:09:24 +0300 | [diff] [blame] | 154 | .description = "check if depmod honor external keyword with higher priority", |
| 155 | .config = { |
| 156 | [TC_UNAME_R] = "4.4.4", |
| 157 | [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS, |
| 158 | }, |
| 159 | .output = { |
| 160 | .files = (const struct keyval[]) { |
| 161 | { SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", |
| 162 | SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS "/lib/modules/4.4.4/modules.dep" }, |
| 163 | { } |
| 164 | }, |
| 165 | }); |
| 166 | |
| 167 | #define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-external-last" |
| 168 | static noreturn int depmod_search_order_external_last(const struct test *t) |
| 169 | { |
| 170 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 171 | const char *const args[] = { |
| 172 | progname, |
| 173 | NULL, |
| 174 | }; |
| 175 | |
| 176 | test_spawn_prog(progname, args); |
| 177 | exit(EXIT_FAILURE); |
| 178 | } |
| 179 | DEFINE_TEST(depmod_search_order_external_last, |
| 180 | .description = "check if depmod honor external keyword with lower priority", |
| 181 | .config = { |
| 182 | [TC_UNAME_R] = "4.4.4", |
| 183 | [TC_ROOTFS] = SEARCH_ORDER_EXTERNAL_LAST_ROOTFS, |
| 184 | }, |
| 185 | .output = { |
| 186 | .files = (const struct keyval[]) { |
| 187 | { SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", |
| 188 | SEARCH_ORDER_EXTERNAL_LAST_ROOTFS "/lib/modules/4.4.4/modules.dep" }, |
| 189 | { } |
| 190 | }, |
| 191 | }); |
| 192 | |
Yauheni Kaliuta | 809b9fb | 2017-12-07 21:16:07 +0200 | [diff] [blame] | 193 | #define SEARCH_ORDER_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-override" |
| 194 | static noreturn int depmod_search_order_override(const struct test *t) |
| 195 | { |
| 196 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
| 197 | const char *const args[] = { |
| 198 | progname, |
| 199 | NULL, |
| 200 | }; |
| 201 | |
| 202 | test_spawn_prog(progname, args); |
| 203 | exit(EXIT_FAILURE); |
| 204 | } |
| 205 | DEFINE_TEST(depmod_search_order_override, |
Marius Bakke | 847247a | 2020-08-01 18:02:22 +0200 | [diff] [blame] | 206 | #if defined(KMOD_SYSCONFDIR_NOT_ETC) |
| 207 | .skip = true, |
| 208 | #endif |
Yauheni Kaliuta | 809b9fb | 2017-12-07 21:16:07 +0200 | [diff] [blame] | 209 | .description = "check if depmod honor override keyword", |
| 210 | .config = { |
| 211 | [TC_UNAME_R] = "4.4.4", |
| 212 | [TC_ROOTFS] = SEARCH_ORDER_OVERRIDE_ROOTFS, |
| 213 | }, |
| 214 | .output = { |
| 215 | .files = (const struct keyval[]) { |
| 216 | { SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/correct-modules.dep", |
| 217 | SEARCH_ORDER_OVERRIDE_ROOTFS "/lib/modules/4.4.4/modules.dep" }, |
| 218 | { } |
| 219 | }, |
| 220 | }); |
| 221 | |
Lucas De Marchi | 4328982 | 2014-10-09 14:29:04 -0300 | [diff] [blame] | 222 | TESTSUITE_MAIN(); |