Pedro Pedruzzi | 760b896 | 2012-01-28 03:22:47 -0200 | [diff] [blame] | 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 | |
| 27 | static 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 Pedruzzi | 760b896 | 2012-01-28 03:22:47 -0200 | [diff] [blame] | 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 | } |
| 59 | static 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 | |
| 72 | static const struct test *tests[] = { |
| 73 | &salias_1, |
| 74 | NULL, |
| 75 | }; |
| 76 | |
Lucas De Marchi | e9fa9de | 2012-02-07 10:09:20 -0200 | [diff] [blame^] | 77 | TESTSUITE_MAIN(tests); |