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 |
| 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 | |
| 19 | #include <stdio.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <stddef.h> |
| 22 | #include <errno.h> |
| 23 | #include <unistd.h> |
| 24 | #include <inttypes.h> |
| 25 | #include <string.h> |
| 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 |
Lucas De Marchi | d96ca9c | 2013-12-17 19:10:16 -0200 | [diff] [blame] | 32 | 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] | 33 | { |
Lucas De Marchi | b6adccd | 2013-07-04 16:01:55 -0300 | [diff] [blame] | 34 | const char *progname = ABS_TOP_BUILDDIR "/tools/depmod"; |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 35 | const char *const args[] = { |
| 36 | progname, |
| 37 | NULL, |
| 38 | }; |
| 39 | |
| 40 | test_spawn_prog(progname, args); |
| 41 | exit(EXIT_FAILURE); |
| 42 | } |
| 43 | static DEFINE_TEST(depmod_modules_order_for_compressed, |
| 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 | |
Lucas De Marchi | aa0abec | 2014-03-19 07:59:38 -0300 | [diff] [blame] | 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 | } |
| 69 | static DEFINE_TEST(depmod_search_order_simple, |
| 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 | |
Lucas De Marchi | ad7f175 | 2014-03-19 09:15:59 -0300 | [diff] [blame] | 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 | } |
| 95 | static DEFINE_TEST(depmod_search_order_same_prefix, |
| 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 | |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 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 | } |
| 121 | static DEFINE_TEST(depmod_detect_loop, |
| 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, |
Lucas De Marchi | 7a2d0e6 | 2014-05-30 10:26:17 -0300 | [diff] [blame^] | 128 | .output = { |
| 129 | .err = DETECT_LOOP_ROOTFS "/correct.txt", |
| 130 | }); |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 131 | |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 132 | |
| 133 | static const struct test *tests[] = { |
Michal Marek | 81bf88d | 2014-04-04 13:05:49 +0200 | [diff] [blame] | 134 | #ifdef ENABLE_ZLIB |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 135 | &sdepmod_modules_order_for_compressed, |
Michal Marek | 81bf88d | 2014-04-04 13:05:49 +0200 | [diff] [blame] | 136 | #endif |
Lucas De Marchi | aa0abec | 2014-03-19 07:59:38 -0300 | [diff] [blame] | 137 | &sdepmod_search_order_simple, |
Lucas De Marchi | ad7f175 | 2014-03-19 09:15:59 -0300 | [diff] [blame] | 138 | &sdepmod_search_order_same_prefix, |
Lucas De Marchi | 8183cfa | 2014-05-30 09:36:21 -0300 | [diff] [blame] | 139 | &sdepmod_detect_loop, |
Lucas De Marchi | b0c9fc8 | 2012-10-04 01:08:13 -0300 | [diff] [blame] | 140 | NULL, |
| 141 | }; |
| 142 | |
| 143 | TESTSUITE_MAIN(tests); |