]>
git.ipfire.org Git - thirdparty/kmod.git/blob - testsuite/test-util.c
2 * Copyright (C) 2012-2013 ProFUSION embedded systems
3 * Copyright (C) 2012 Pedro Pedruzzi
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <shared/util.h>
27 #include <libkmod-util.h>
29 #include "testsuite.h"
31 static int alias_1(const struct test
*t
)
33 static const char *input
[] = {
35 "test[abcfoobar]2211",
46 for (alias
= input
; *alias
!= NULL
; alias
++) {
49 ret
= alias_normalize(*alias
, buf
, &len
);
50 printf("input %s\n", *alias
);
51 printf("return %d\n", ret
);
54 printf("len %zu\n", len
);
55 printf("output %s\n", buf
);
63 static DEFINE_TEST(alias_1
,
64 .description
= "check if alias_normalize does the right thing",
66 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-util/",
70 .out
= TESTSUITE_ROOTFS
"test-util/alias-correct.txt",
73 static int test_getline_wrapped(const struct test
*t
)
75 FILE *fp
= fopen("/getline_wrapped-input.txt", "re");
80 while (!feof(fp
) && !ferror(fp
)) {
82 char *s
= getline_wrapped(fp
, &num
);
93 static DEFINE_TEST(test_getline_wrapped
,
94 .description
= "check if getline_wrapped() does the right thing",
96 [TC_ROOTFS
] = TESTSUITE_ROOTFS
"test-util/",
100 .out
= TESTSUITE_ROOTFS
"test-util/getline_wrapped-correct.txt",
103 static const struct test
*tests
[] = {
105 &stest_getline_wrapped
,
109 TESTSUITE_MAIN(tests
);