blob: 2e84e6b325d2aef3c39636c1b390b673c5a526a3 [file] [log] [blame]
Pedro Pedruzzi760b8962012-01-28 03:22:47 -02001/*
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
Pedro Pedruzzi760b8962012-01-28 03:22:47 -020045 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}
59static const struct test salias_1 = {
60 .name = "alias_1",
61 .description = "check if alias_normalize does the right thing",
62 .func = alias_1,
63 .config = {
64 [TC_ROOTFS] = TESTSUITE_ROOTFS "test-alias/",
65 },
66 .need_spawn = true,
67 .output = {
68 .stdout = TESTSUITE_ROOTFS "test-alias/correct.txt",
69 },
70};
71
72static const struct test *tests[] = {
73 &salias_1,
74 NULL,
75};
76
Lucas De Marchie9fa9de2012-02-07 10:09:20 -020077TESTSUITE_MAIN(tests);