mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 16:33:17 +00:00
This way we'll be able to pass more test specific parameters without having to change this function signature. Will be used by the upcoming 'shell tests', shell scripts that will call perf tools and check if they work as expected, comparing its effects on the system (think 'perf probe foo') the output produced, etc. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Thomas Richter <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
39 lines
705 B
C
39 lines
705 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(struct test *t __maybe_unused, 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;
|
|
}
|