blob: 05284b415d1a72aa1ff4fe20fda591c53cb01d60 [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
Lucas De Marchic2e42862014-10-03 01:41:42 -030019#include <errno.h>
20#include <inttypes.h>
21#include <stddef.h>
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030022#include <stdio.h>
23#include <stdlib.h>
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030024#include <string.h>
Lucas De Marchic2e42862014-10-03 01:41:42 -030025#include <unistd.h>
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030026
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}
Lucas De Marchi43289822014-10-09 14:29:04 -030043
44#ifdef ENABLE_ZLIB
Lucas De Marchif1155c12014-10-09 13:00:30 -030045DEFINE_TEST(depmod_modules_order_for_compressed,
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030046 .description = "check if depmod let aliases in right order when using compressed modules",
47 .config = {
48 [TC_UNAME_R] = MODULES_ORDER_UNAME,
49 [TC_ROOTFS] = MODULES_ORDER_ROOTFS,
50 },
51 .output = {
52 .files = (const struct keyval[]) {
53 { MODULES_ORDER_LIB_MODULES "/correct-modules.alias",
54 MODULES_ORDER_LIB_MODULES "/modules.alias" },
55 { }
56 },
57 });
Lucas De Marchi43289822014-10-09 14:29:04 -030058#endif
Lucas De Marchib0c9fc82012-10-04 01:08:13 -030059
Lucas De Marchiaa0abec2014-03-19 07:59:38 -030060#define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-simple"
61static 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 Marchif1155c12014-10-09 13:00:30 -030072DEFINE_TEST(depmod_search_order_simple,
Lucas De Marchiaa0abec2014-03-19 07:59:38 -030073 .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 Marchiad7f1752014-03-19 09:15:59 -030086#define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-order-same-prefix"
87static 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 Marchif1155c12014-10-09 13:00:30 -030098DEFINE_TEST(depmod_search_order_same_prefix,
Lucas De Marchiad7f1752014-03-19 09:15:59 -030099 .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 Marchi8183cfa2014-05-30 09:36:21 -0300112#define DETECT_LOOP_ROOTFS TESTSUITE_ROOTFS "test-depmod/detect-loop"
113static 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 Marchif1155c12014-10-09 13:00:30 -0300124DEFINE_TEST(depmod_detect_loop,
Lucas De Marchi8183cfa2014-05-30 09:36:21 -0300125 .description = "check if depmod detects module loops correctly",
126 .config = {
127 [TC_UNAME_R] = "4.4.4",
128 [TC_ROOTFS] = DETECT_LOOP_ROOTFS,
129 },
130 .expected_fail = true,
Lucas De Marchi7a2d0e62014-05-30 10:26:17 -0300131 .output = {
132 .err = DETECT_LOOP_ROOTFS "/correct.txt",
133 });
Lucas De Marchi8183cfa2014-05-30 09:36:21 -0300134
Lucas De Marchi43289822014-10-09 14:29:04 -0300135TESTSUITE_MAIN();