]> git.ipfire.org Git - thirdparty/kmod.git/blame - testsuite/test-alias.c
testsuite: path wrapper: Fix open() with 3 arguments
[thirdparty/kmod.git] / testsuite / test-alias.c
CommitLineData
760b8968
PP
1/*
2 * Copyright (C) 2012 ProFUSION embedded systems
3 * Copyright (C) 2012 Pedro Pedruzzi
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <libkmod.h>
23
24#include "libkmod-util.h"
25#include "testsuite.h"
26
27static int alias_1(const struct test *t)
28{
29 static const char *input[] = {
30 "test1234",
31 "test[abcfoobar]2211",
32 "bar[aaa][bbbb]sss",
33 "kmod[p.b]lib",
34 "[az]1234[AZ]",
35 NULL,
36 };
37
38 char buf[PATH_MAX];
39 size_t len;
40 const char **alias;
41
42 for (alias = input; *alias != NULL; alias++) {
43 int ret;
44
760b8968
PP
45 ret = alias_normalize(*alias, buf, &len);
46 printf("input %s\n", *alias);
47 printf("return %d\n", ret);
48
49 if (ret == 0) {
50 printf("len %zu\n", len);
51 printf("output %s\n", buf);
52 }
53
54 printf("\n");
55 }
56
57 return EXIT_SUCCESS;
58}
c5d81989 59static DEFINE_TEST(alias_1,
760b8968 60 .description = "check if alias_normalize does the right thing",
760b8968
PP
61 .config = {
62 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-alias/",
63 },
64 .need_spawn = true,
65 .output = {
66 .stdout = TESTSUITE_ROOTFS "test-alias/correct.txt",
c5d81989 67 });
760b8968
PP
68
69static const struct test *tests[] = {
70 &salias_1,
71 NULL,
72};
73
e9fa9de3 74TESTSUITE_MAIN(tests);