Squashed backup commit (no shallow-clone history issues) of xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream commit 9eece662e) plus all fixes applied to get everpal_defconfig building clean against a modern (GCC 15.2.0) toolchain -- see the previous commit message on the lineage-23.2 branch (also in this repo history is not available here since this is a squashed snapshot; full incremental history lives in the local DL380 checkout and the upstream GitHub remote). Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
40 lines
741 B
C
40 lines
741 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#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;
|
|
}
|