KVM: selftests: Fix filename reporting in guest asserts

Fix filename reporting in guest asserts by ensuring the GUEST_ASSERT
macro records __FILE__ and substituting REPORT_GUEST_ASSERT for many
repetitive calls to TEST_FAIL.

Previously filename was reported by using __FILE__ directly in the
selftest, wrongly assuming it would always be the same as where the
assertion failed.

Signed-off-by: Colton Lewis <coltonlewis@google.com>
Reported-by: Ricardo Koller <ricarkol@google.com>
Fixes: 4e18bccc2e
Link: https://lore.kernel.org/r/20220615193116.806312-5-coltonlewis@google.com
[sean: convert more TEST_FAIL => REPORT_GUEST_ASSERT instances]
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
Colton Lewis
2022-06-15 19:31:16 +00:00
committed by Sean Christopherson
parent ddcb57afd5
commit 594a1c271c
41 changed files with 68 additions and 102 deletions

View File

@@ -41,11 +41,12 @@ enum guest_assert_builtin_args {
GUEST_ASSERT_BUILTIN_NARGS
};
#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \
if (!(_condition)) \
ucall(UCALL_ABORT, 2 + _nargs, \
"Failed guest assert: " \
_condstr, __LINE__, _args); \
#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) \
do { \
if (!(_condition)) \
ucall(UCALL_ABORT, GUEST_ASSERT_BUILTIN_NARGS + _nargs, \
"Failed guest assert: " _condstr, \
__FILE__, __LINE__, ##_args); \
} while (0)
#define GUEST_ASSERT(_condition) \