perf stat: Update walltime_nsecs_stats in interval mode
[linux/fpc-iii.git] / tools / perf / tests / unit_number__scnprintf.c
blob15cd1cf8c129d74d0499a06a874d82f4085b64af
1 #include <inttypes.h>
2 #include <linux/compiler.h>
3 #include <linux/types.h>
4 #include "tests.h"
5 #include "units.h"
6 #include "debug.h"
8 int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
10 struct {
11 u64 n;
12 const char *str;
13 } test[] = {
14 { 1, "1B" },
15 { 10*1024, "10K" },
16 { 20*1024*1024, "20M" },
17 { 30*1024*1024*1024ULL, "30G" },
18 { 0, "0B" },
19 { 0, NULL },
21 unsigned i = 0;
23 while (test[i].str) {
24 char buf[100];
26 unit_number__scnprintf(buf, sizeof(buf), test[i].n);
28 pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n",
29 test[i].n, test[i].str, buf);
31 if (strcmp(test[i].str, buf))
32 return TEST_FAIL;
34 i++;
37 return TEST_OK;