mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-17 15:47:39 +07:00
58db1d6e7d
Out of util.h, to disentangle it a bit more. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/n/tip-vpksyj3w5fk9t8s6mxmkajyr@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
39 lines
674 B
C
39 lines
674 B
C
#include <inttypes.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/types.h>
|
|
#include "tests.h"
|
|
#include "units.h"
|
|
#include "debug.h"
|
|
|
|
int test__unit_number__scnprint(int subtest __maybe_unused)
|
|
{
|
|
struct {
|
|
u64 n;
|
|
const char *str;
|
|
} test[] = {
|
|
{ 1, "1B" },
|
|
{ 10*1024, "10K" },
|
|
{ 20*1024*1024, "20M" },
|
|
{ 30*1024*1024*1024ULL, "30G" },
|
|
{ 0, "0B" },
|
|
{ 0, NULL },
|
|
};
|
|
unsigned i = 0;
|
|
|
|
while (test[i].str) {
|
|
char buf[100];
|
|
|
|
unit_number__scnprintf(buf, sizeof(buf), test[i].n);
|
|
|
|
pr_debug("n %" PRIu64 ", str '%s', buf '%s'\n",
|
|
test[i].n, test[i].str, buf);
|
|
|
|
if (strcmp(test[i].str, buf))
|
|
return TEST_FAIL;
|
|
|
|
i++;
|
|
}
|
|
|
|
return TEST_OK;
|
|
}
|