Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / tools / perf / tests / is_printable_array.c
blob42e13393e5028c2d1bfe515b990b0e79275e96c3
1 #include <linux/compiler.h>
2 #include "tests.h"
3 #include "debug.h"
4 #include "util.h"
6 int test__is_printable_array(int subtest __maybe_unused)
8 char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
9 char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
10 struct {
11 char *buf;
12 unsigned int len;
13 int ret;
14 } t[] = {
15 { (char *) "krava", sizeof("krava"), 1 },
16 { (char *) "krava", sizeof("krava") - 1, 0 },
17 { (char *) "", sizeof(""), 1 },
18 { (char *) "", 0, 0 },
19 { NULL, 0, 0 },
20 { buf1, sizeof(buf1), 0 },
21 { buf2, sizeof(buf2), 0 },
23 unsigned int i;
25 for (i = 0; i < ARRAY_SIZE(t); i++) {
26 int ret;
28 ret = is_printable_array((char *) t[i].buf, t[i].len);
29 if (ret != t[i].ret) {
30 pr_err("failed: test %u\n", i);
31 return TEST_FAIL;
35 return TEST_OK;