Files
android/drivers/misc/mediatek/geniezone/include/unittest.h
T
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
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)
2026-09-12 13:36:46 +00:00

127 lines
6.2 KiB
C

/*
* Copyright (C) 2015 MediaTek Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#define UT_LOG(fmt...) pr_info("[GZTEST]" fmt)
#define INIT_UNITTESTS \
static uint _uts_total; \
static uint _uts_failed
#define RESET_UNITTESTS \
do { \
_uts_total = 0; \
_uts_failed = 0; \
} while (0)
#define REPORT_UNITTESTS \
{ \
UT_LOG("======== UT report =======\n"); \
UT_LOG("total test cases: %u\n", _uts_total); \
UT_LOG("FAILED test cases: %u\n", _uts_failed); \
if (_uts_failed > 0) { \
UT_LOG("===========> UT FAILED\n"); \
} else { \
UT_LOG("===========> UT SUCCEEDED\n"); \
} \
}
/*
* Begin and end test macro
*/
#define TEST_BEGIN(name) \
bool _success = true; \
char *_test = name
#define TEST_END \
{ \
if (_success) \
UT_LOG("%s: PASSED\n", _test); \
else \
UT_LOG("%s: FAILED\n", _test); \
}
/*
* CHECK_* macros to check test results.
*/
#define CHECK_EQ(expected, actual, msg) \
{ \
typeof(actual) _e = expected; \
typeof(actual) _a = actual; \
_uts_total++; \
if (_e != _a) { \
UT_LOG("%s: expected " #expected \
" (%d), " \
"actual " #actual " (%d)\n", \
msg, (int)_e, (int)_a); \
_uts_failed++; \
_success = false; \
} \
}
#define CHECK_NEQ(expected, actual, msg) \
{ \
typeof(actual) _e = expected; \
typeof(actual) _a = actual; \
_uts_total++; \
if (_e == _a) { \
UT_LOG("%s: NOT expected " #expected \
" (%d), " \
"actual " #actual " (%d)\n", \
msg, (int)_e, (int)_a); \
_uts_failed++; \
_success = false; \
} \
}
#define CHECK_GT(expected, actual, msg) \
{ \
typeof(actual) _e = expected; \
typeof(actual) _a = actual; \
_uts_total++; \
if (_e <= _a) { \
UT_LOG("%s: expected " #expected \
" (%d), " \
"actual " #actual " (%d)\n", \
msg, (int)_e, (int)_a); \
_uts_failed++; \
_success = false; \
} \
}
#define CHECK_GE_ZERO(actual, msg) \
{ \
typeof(actual) _a = actual; \
_uts_total++; \
if (_a < 0) { \
UT_LOG("%s: expected >= 0, " \
"actual " #actual " (%d)\n", \
msg, (int)_a); \
_uts_failed++; \
_success = false; \
} \
}
#define CHECK_GT_ZERO(actual, msg) \
{ \
typeof(actual) _a = actual; \
_uts_total++; \
if (_a <= 0) { \
UT_LOG("%s: expected > 0, " \
"actual " #actual " (%d)\n", \
msg, (int)_a); \
_uts_failed++; \
_success = false; \
} \
}