blob: ae53753e75846b1428266759a14d564adb4e85c7 [file] [log] [blame]
Lucas De Marchib0c9fc82012-10-04 01:08:13 -03001/*
Lucas De Marchie6b0e492013-01-16 11:27:21 -02002 * Copyright (C) 2012-2013 ProFUSION embedded systems
Lucas De Marchib0c9fc82012-10-04 01:08:13 -03003 *
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 Marchid96ca9c2013-12-17 19:10:16 -020032static noreturn int depmod_modules_order_for_compressed(const struct test *t)
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030033{
Lucas De Marchib6adccd2013-07-04 16:01:55 -030034 const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030035 const char *const args[] = {
36 progname,
37 NULL,
38 };
39
40 test_spawn_prog(progname, args);
41 exit(EXIT_FAILURE);
42}
43static 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 Marchiaa0abec2014-03-19 07:59:38 -030057#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
58static 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}
69static 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 Marchiad7f1752014-03-19 09:15:59 -030083#define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
84static 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}
95static 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 Marchi8183cfa2014-05-30 09:36:21 -0300109#define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop"
110static 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}
121static 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 Marchi7a2d0e62014-05-30 10:26:17 -0300128 .output = {
129 .err = DETECT_LOOP_ROOTFS "/correct.txt",
130 });
Lucas De Marchi8183cfa2014-05-30 09:36:21 -0300131
Lucas De Marchib0c9fc82012-10-04 01:08:13 -0300132
133static const struct test *tests[] = {
Michal Marek81bf88d2014-04-04 13:05:49 +0200134#ifdef ENABLE_ZLIB
Lucas De Marchib0c9fc82012-10-04 01:08:13 -0300135 &sdepmod_modules_order_for_compressed,
Michal Marek81bf88d2014-04-04 13:05:49 +0200136#endif
Lucas De Marchiaa0abec2014-03-19 07:59:38 -0300137 &sdepmod_search_order_simple,
Lucas De Marchiad7f1752014-03-19 09:15:59 -0300138 &sdepmod_search_order_same_prefix,
Lucas De Marchi8183cfa2014-05-30 09:36:21 -0300139 &sdepmod_detect_loop,
Lucas De Marchib0c9fc82012-10-04 01:08:13 -0300140 NULL,
141};
142
143TESTSUITE_MAIN(tests);