x86/mm: Remove preempt_disable/enable() from __native_flush_tlb()
[linux/fpc-iii.git] / tools / perf / tests / unit_number__scnprintf.c
blob2bb8cb0039c18468036aba68081097c4578db957
1 // SPDX-License-Identifier: GPL-2.0
2 #include <inttypes.h>
3 #include <linux/compiler.h>
4 #include <linux/types.h>
5 #include "tests.h"
6 #include "units.h"
7 #include "debug.h"
9 int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
11 struct {
12 u64 n;
13 const char *str;
14 } test[] = {
15 { 1, "1B" },
16 { 10*1024, "10K" },
17 { 20*1024*1024, "20M" },
18 { 30*1024*1024*1024ULL, "30G" },
19 { 0, "0B" },
20 { 0, NULL },
22 unsigned i = 0;
24 while (test[i].str) {
25 char buf[100];
27 unit_number__scnprintf(buf, sizeof(buf), test[i].n);
29 pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n",
30 test[i].n, test[i].str, buf);
32 if (strcmp(test[i].str, buf))
33 return TEST_FAIL;
35 i++;
38 return TEST_OK;