]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: selftests: Fix filename reporting in guest asserts
authorColton Lewis <coltonlewis@google.com>
Wed, 15 Jun 2022 19:31:16 +0000 (19:31 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 14 Jul 2022 01:14:08 +0000 (18:14 -0700)
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: 56da9b317d058e106c63982fe8779260edcda6d1
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>
41 files changed:
tools/testing/selftests/kvm/aarch64/arch_timer.c
tools/testing/selftests/kvm/aarch64/debug-exceptions.c
tools/testing/selftests/kvm/aarch64/hypercalls.c
tools/testing/selftests/kvm/aarch64/psci_test.c
tools/testing/selftests/kvm/aarch64/vgic_irq.c
tools/testing/selftests/kvm/include/ucall_common.h
tools/testing/selftests/kvm/memslot_perf_test.c
tools/testing/selftests/kvm/s390x/tprot.c
tools/testing/selftests/kvm/set_memory_region_test.c
tools/testing/selftests/kvm/steal_time.c
tools/testing/selftests/kvm/system_counter_offset_test.c
tools/testing/selftests/kvm/x86_64/amx_test.c
tools/testing/selftests/kvm/x86_64/cpuid_test.c
tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c
tools/testing/selftests/kvm/x86_64/emulator_error_test.c
tools/testing/selftests/kvm/x86_64/evmcs_test.c
tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c
tools/testing/selftests/kvm/x86_64/hyperv_clock.c
tools/testing/selftests/kvm/x86_64/hyperv_features.c
tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c
tools/testing/selftests/kvm/x86_64/kvm_clock_test.c
tools/testing/selftests/kvm/x86_64/kvm_pv_test.c
tools/testing/selftests/kvm/x86_64/monitor_mwait_test.c
tools/testing/selftests/kvm/x86_64/set_boot_cpu_id.c
tools/testing/selftests/kvm/x86_64/state_test.c
tools/testing/selftests/kvm/x86_64/svm_int_ctl_test.c
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c
tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c
tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c
tools/testing/selftests/kvm/x86_64/tsc_msrs_test.c
tools/testing/selftests/kvm/x86_64/userspace_io_test.c
tools/testing/selftests/kvm/x86_64/userspace_msr_exit_test.c
tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
tools/testing/selftests/kvm/x86_64/vmx_close_while_nested_test.c
tools/testing/selftests/kvm/x86_64/vmx_dirty_log_test.c
tools/testing/selftests/kvm/x86_64/vmx_invalid_nested_guest_state.c
tools/testing/selftests/kvm/x86_64/vmx_nested_tsc_scaling_test.c
tools/testing/selftests/kvm/x86_64/vmx_preemption_timer_test.c
tools/testing/selftests/kvm/x86_64/vmx_tsc_adjust_test.c
tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
tools/testing/selftests/kvm/x86_64/xen_vmcall_test.c

index f68019be67c0c24308c94ec8f1118a55ef5b2074..574eb73f0e904e80b23229d7fe3cab3a1ce4d7c6 100644 (file)
@@ -231,10 +231,13 @@ static void *test_vcpu_run(void *arg)
                break;
        case UCALL_ABORT:
                sync_global_from_guest(vm, *shared_data);
-               TEST_FAIL("%s at %s:%ld\n\tvalues: %lu, %lu; %lu, vcpu: %u; stage: %u; iter: %u",
-                       (const char *)uc.args[0], __FILE__, uc.args[1],
-                       uc.args[2], uc.args[3], uc.args[4], vcpu_idx,
-                       shared_data->guest_stage, shared_data->nr_iter);
+               REPORT_GUEST_ASSERT_N(uc, "values: %lu, %lu; %lu, vcpu %u; stage; %u; iter: %u",
+                                     GUEST_ASSERT_ARG(uc, 0),
+                                     GUEST_ASSERT_ARG(uc, 1),
+                                     GUEST_ASSERT_ARG(uc, 2),
+                                     vcpu_idx,
+                                     shared_data->guest_stage,
+                                     shared_data->nr_iter);
                break;
        default:
                TEST_FAIL("Unexpected guest exit\n");
index b8072b40ccc89c743b98e561f9e757f1ae2b5a53..2ee35cf9801e1398e62caddeea3f9127fd3d3970 100644 (file)
@@ -283,9 +283,7 @@ int main(int argc, char *argv[])
                                stage, (ulong)uc.args[1]);
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld\n\tvalues: %#lx, %#lx",
-                               (const char *)uc.args[0],
-                               __FILE__, uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
                        break;
                case UCALL_DONE:
                        goto done;
index 5fce4969cbb96f09412c41909e800161abf04e53..a39da3fe49525858baec07585cc00900160c6c60 100644 (file)
@@ -291,9 +291,10 @@ static void test_run(void)
                        guest_done = true;
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld\n\tvalues: 0x%lx, 0x%lx; 0x%lx, stage: %u",
-                       (const char *)uc.args[0], __FILE__, uc.args[1],
-                       uc.args[2], uc.args[3], uc.args[4], stage);
+                       REPORT_GUEST_ASSERT_N(uc, "values: 0x%lx, 0x%lx; 0x%lx, stage: %u",
+                                             GUEST_ASSERT_ARG(uc, 0),
+                                             GUEST_ASSERT_ARG(uc, 1),
+                                             GUEST_ASSERT_ARG(uc, 2), stage);
                        break;
                default:
                        TEST_FAIL("Unexpected guest exit\n");
index b665b534cb78985ff1afc2b5a6c521a6f7226541..f7621f6e938e461a6c2dc1645be11c215b58e68b 100644 (file)
@@ -94,8 +94,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)
 
        vcpu_run(vcpu);
        if (get_ucall(vcpu, &uc) == UCALL_ABORT)
-               TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0], __FILE__,
-                         uc.args[1]);
+               REPORT_GUEST_ASSERT(uc);
 }
 
 static void assert_vcpu_reset(struct kvm_vcpu *vcpu)
index 046ba4fde6484d39bebb3d2a17f5cf83e046f862..17417220a083f65a889d934b013c6ca557134948 100644 (file)
@@ -782,9 +782,7 @@ static void test_vgic(uint32_t nr_irqs, bool level_sensitive, bool eoi_split)
                        run_guest_cmd(vcpu, gic_fd, &inject_args, &args);
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld\n\tvalues: %#lx, %#lx",
-                                       (const char *)uc.args[0],
-                                       __FILE__, uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
                        break;
                case UCALL_DONE:
                        goto done;
index e8af3b4fef6dee94b38a1f3b4650c5960df0b797..ee79d180e07e443d8e4f3e9750bfb7b92f95e875 100644 (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) \
index 5f98489e4f4d4712568fe373bb36890d3babd451..44995446d942a7e91b2da8d5015e2a061dca9e11 100644 (file)
@@ -162,9 +162,7 @@ static void *vcpu_worker(void *__data)
                                goto done;
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld, val = %lu",
-                                       (const char *)uc.args[0],
-                                       __FILE__, uc.args[1], uc.args[2]);
+                       REPORT_GUEST_ASSERT_1(uc, "val = %lu");
                        break;
                case UCALL_DONE:
                        goto done;
index 015a13056503850c837e98c41320ce3ada67e6f8..a9a0b76e5fa458db8785abc45437fb5d235a8f4a 100644 (file)
@@ -181,20 +181,18 @@ static void guest_code(void)
        GUEST_SYNC(perform_next_stage(&i, mapped_0));
 }
 
-#define HOST_SYNC_NO_TAP(vcpup, stage)                                         \
-({                                                                             \
-       struct kvm_vcpu *__vcpu = (vcpup);                                      \
-       struct ucall uc;                                                        \
-       int __stage = (stage);                                                  \
-                                                                               \
-       vcpu_run(__vcpu);                                                       \
-       get_ucall(__vcpu, &uc);                                                 \
-       if (uc.cmd == UCALL_ABORT) {                                            \
-               TEST_FAIL("line %lu: %s, hints: %lu, %lu", uc.args[1],          \
-                         (const char *)uc.args[0], uc.args[2], uc.args[3]);    \
-       }                                                                       \
-       ASSERT_EQ(uc.cmd, UCALL_SYNC);                                          \
-       ASSERT_EQ(uc.args[1], __stage);                                         \
+#define HOST_SYNC_NO_TAP(vcpup, stage)                         \
+({                                                             \
+       struct kvm_vcpu *__vcpu = (vcpup);                      \
+       struct ucall uc;                                        \
+       int __stage = (stage);                                  \
+                                                               \
+       vcpu_run(__vcpu);                                       \
+       get_ucall(__vcpu, &uc);                                 \
+       if (uc.cmd == UCALL_ABORT)                              \
+               REPORT_GUEST_ASSERT_2(uc, "hints: %lu, %lu");   \
+       ASSERT_EQ(uc.cmd, UCALL_SYNC);                          \
+       ASSERT_EQ(uc.args[1], __stage);                         \
 })
 
 #define HOST_SYNC(vcpu, stage)                 \
index 47b219dd60e4d786420942473308b01245256fdc..0d55f508d595381d7e97ce4ca24744dc2391bfe1 100644 (file)
@@ -88,8 +88,7 @@ static void *vcpu_worker(void *data)
        }
 
        if (run->exit_reason == KVM_EXIT_IO && cmd == UCALL_ABORT)
-               TEST_FAIL("%s at %s:%ld, val = %lu", (const char *)uc.args[0],
-                         __FILE__, uc.args[1], uc.args[2]);
+               REPORT_GUEST_ASSERT_1(uc, "val = %lu");
 
        return NULL;
 }
index d122f1e05cdd18831cb7ad3b8c4039893f704afa..9866a71463d7c444e3d8c2474b5919a72fd6a3b7 100644 (file)
@@ -234,8 +234,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu)
        case UCALL_DONE:
                break;
        case UCALL_ABORT:
-               TEST_ASSERT(false, "%s at %s:%ld", (const char *)uc.args[0],
-                           __FILE__, uc.args[1]);
+               REPORT_GUEST_ASSERT(uc);
        default:
                TEST_ASSERT(false, "Unexpected exit: %s",
                            exit_reason_str(vcpu->run->exit_reason));
index 862a8e93e070b9c97f5b2e1e0a1c4306527c2401..1c274933912bb9cf7fcb657ea596d4f1e33fd540 100644 (file)
@@ -83,8 +83,7 @@ static void handle_sync(struct ucall *uc, uint64_t start, uint64_t end)
 
 static void handle_abort(struct ucall *uc)
 {
-       TEST_FAIL("%s at %s:%ld", (const char *)uc->args[0],
-                 __FILE__, uc->args[1]);
+       REPORT_GUEST_ASSERT(*uc);
 }
 
 static void enter_guest(struct kvm_vcpu *vcpu)
index dab4ca16a2df09a379a660c0307ef175b95e4480..b71763b11b78018a60a85b638800f0176b507069 100644 (file)
@@ -373,8 +373,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        switch (uc.args[1]) {
index 4aa7849325971d0a265fc29188eb98d460c388e0..3767a0cc694b331eedf3005c21342ee1312510fd 100644 (file)
@@ -132,8 +132,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
        case UCALL_DONE:
                return;
        case UCALL_ABORT:
-               TEST_ASSERT(false, "%s at %s:%ld\n\tvalues: %#lx, %#lx", (const char *)uc.args[0],
-                           __FILE__, uc.args[1], uc.args[2], uc.args[3]);
+               REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
        default:
                TEST_ASSERT(false, "Unexpected exit: %s",
                            exit_reason_str(vcpu->run->exit_reason));
index a80940ac420fd7f837e50d61b15b78b801716920..56d8ab92eed49f2ccd66214a20eba8c809f81794 100644 (file)
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
                        vcpu_sregs_set(vcpu, &sregs);
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit.");
+                       REPORT_GUEST_ASSERT(uc);
                        break;
                case UCALL_DONE:
                        goto done;
index bfff2d271c48e0240492bfef7c45db60c3fdb6bb..3aa3d17f230f3f69a41a0380ba2fffa6c2ef37bc 100644 (file)
@@ -92,8 +92,7 @@ static void process_exit_on_emulation_error(struct kvm_vcpu *vcpu)
 
 static void do_guest_assert(struct ucall *uc)
 {
-       TEST_FAIL("%s at %s:%ld", (const char *)uc->args[0], __FILE__,
-                 uc->args[1]);
+       REPORT_GUEST_ASSERT(*uc);
 }
 
 static void check_for_guest_assert(struct kvm_vcpu *vcpu)
index 8dda527cc0809b19a96642204a5b30dd5d5a7594..aacad86d90e139d80cdfc83362da7736e5e10d61 100644 (file)
@@ -236,8 +236,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index f6f251ce59e19162c99f4daaa0ba99a3ca7bdafd..b1905d280ef55891a90a957b5e96e2f3fec5014a 100644 (file)
@@ -112,7 +112,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)
        case UCALL_DONE:
                return;
        case UCALL_ABORT:
-               TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0], __FILE__, uc.args[1]);
+               REPORT_GUEST_ASSERT(uc);
        default:
                TEST_FAIL("Unhandled ucall: %ld\nexit_reason: %u (%s)",
                          uc.cmd, run->exit_reason, exit_reason_str(run->exit_reason));
index f7a9e29ff0c7585587b7f7abc4dd927b826b7daa..d576bc8ce8235ca2f39b24ffea452459d3f46261 100644 (file)
@@ -234,8 +234,7 @@ int main(void)
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index c05acd78548ffa2ab3499b0bb550af881f5cc96b..2070ba0d63926941c27e9c2e4f1ebe30605150eb 100644 (file)
@@ -447,9 +447,7 @@ static void guest_test_msrs_access(void)
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld, MSR = %lx, vector = %lx",
-                                 (const char *)uc.args[0], __FILE__,
-                                 uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "MSR = %lx, vector = %lx");
                        return;
                case UCALL_DONE:
                        break;
@@ -618,9 +616,7 @@ static void guest_test_hcalls_access(void)
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld, arg1 = %lx, arg2 = %lx",
-                                 (const char *)uc.args[0], __FILE__,
-                                 uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "arg1 = %lx, arg2 = %lx");
                        return;
                case UCALL_DONE:
                        break;
index c5cd9835dbd68ae91f9c7b0b9659d4deaded2f12..b7dc243ab8d59b21f5b736da65c7928f2575e237 100644 (file)
@@ -145,8 +145,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index 138455575a11f368e7ac1e13440fdfc787d95ad4..813ce282cf5612b72e9909c7f825f94dfb2bc231 100644 (file)
@@ -71,8 +71,7 @@ static void handle_sync(struct ucall *uc, struct kvm_clock_data *start,
 
 static void handle_abort(struct ucall *uc)
 {
-       TEST_FAIL("%s at %s:%ld", (const char *)uc->args[0],
-                 __FILE__, uc->args[1]);
+       REPORT_GUEST_ASSERT(*uc);
 }
 
 static void setup_clock(struct kvm_vm *vm, struct test_case *test_case)
index feff85e43be37d772863bf180f15e6fe6846d9cb..ea452444f4af96e27cd44c380df2fbd460a7567f 100644 (file)
@@ -137,9 +137,7 @@ static void enter_guest(struct kvm_vcpu *vcpu)
                        pr_hcall(&uc);
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld, vector = %lu",
-                                 (const char *)uc.args[0], __FILE__,
-                                 uc.args[1], uc.args[2]);
+                       REPORT_GUEST_ASSERT_1(uc, "vector = %lu");
                        return;
                case UCALL_DONE:
                        return;
index 094c68d744c0c56dc2eed8864149a5d3072393be..2bf6851b4f426cd6984892bff4a41fd65f08271e 100644 (file)
@@ -100,9 +100,7 @@ int main(int argc, char *argv[])
                        testcase = uc.args[1];
                        break;
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld, testcase = %lx, vector = %ld",
-                                 (const char *)uc.args[0], __FILE__,
-                                 uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "testcase = %lx, vector = %ld");
                        goto done;
                case UCALL_DONE:
                        goto done;
index 7ef713fdd0a5ab85b72495ff2967f8b09bf32a66..b25d7556b6385fb0c19d770da62b2db0b7658e42 100644 (file)
@@ -65,9 +65,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu)
                                        stage);
                        break;
                case UCALL_ABORT:
-                       TEST_ASSERT(false, "%s at %s:%ld\n\tvalues: %#lx, %#lx",
-                                               (const char *)uc.args[0], __FILE__,
-                                               uc.args[1], uc.args[2], uc.args[3]);
+                       REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
                default:
                        TEST_ASSERT(false, "Unexpected exit: %s",
                                    exit_reason_str(vcpu->run->exit_reason));
index e2f1f35e51ff09574e661194b2f3711ace867131..2b0de1598ab85f189a3ad16424cde92da13ded89 100644 (file)
@@ -190,8 +190,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index 9c68a47b69e14874370809bbd4ffdfeeef0b0a00..d978d1697f5a3f8a1757cc3287100768fba46440 100644 (file)
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
 
        switch (get_ucall(vcpu, &uc)) {
        case UCALL_ABORT:
-               TEST_FAIL("%s", (const char *)uc.args[0]);
+               REPORT_GUEST_ASSERT(uc);
                break;
                /* NOT REACHED */
        case UCALL_DONE:
index 1c3f457aa3aaf91b947f2e6d34f168cb211574b2..07253e22defdaa4fdb327df0979a9a2dd8708e24 100644 (file)
@@ -181,8 +181,7 @@ static void run_test(bool is_nmi)
 
        switch (get_ucall(vcpu, &uc)) {
        case UCALL_ABORT:
-               TEST_FAIL("%s at %s:%ld, vals = 0x%lx 0x%lx 0x%lx", (const char *)uc.args[0],
-                         __FILE__, uc.args[1], uc.args[2], uc.args[3], uc.args[4]);
+               REPORT_GUEST_ASSERT_3(uc, "vals = 0x%lx 0x%lx 0x%lx");
                break;
                /* NOT REACHED */
        case UCALL_DONE:
index e6d7191866a5c2d227eeea771668aa2da8856e2b..d53b1f7abb56a22c509948a853db390df975c25a 100644 (file)
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *)uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index 5a202ecb8ea0146df5378ae0a56ad3e27e008ed7..d1274c097b36f974701d7696d8274954ea140b51 100644 (file)
@@ -82,7 +82,7 @@ int main(void)
        case UCALL_DONE:
                break;
        case UCALL_ABORT:
-               TEST_FAIL("%s", (const char *)uc.args[0]);
+               REPORT_GUEST_ASSERT(uc);
        default:
                TEST_FAIL("Unexpected ucall: %lu", uc.cmd);
        }
index 3165d3f7e065f8b980162880e65cb622ec8bfd80..22d366c697f7d1b601dd5559ed7025714220bbc8 100644 (file)
@@ -79,9 +79,7 @@ static void run_vcpu(struct kvm_vcpu *vcpu, int stage)
        case UCALL_DONE:
                return;
        case UCALL_ABORT:
-               TEST_ASSERT(false, "%s at %s:%ld\n" \
-                           "\tvalues: %#lx, %#lx", (const char *)uc.args[0],
-                           __FILE__, uc.args[1], uc.args[2], uc.args[3]);
+               REPORT_GUEST_ASSERT_2(uc, "values: %#lx, %#lx");
        default:
                TEST_ASSERT(false, "Unexpected exit: %s",
                            exit_reason_str(vcpu->run->exit_reason));
index 7538d57a41d5614274a8fcc630913fad9ad1867e..7316521428f86175345970c7a6d8c3be34abc481 100644 (file)
@@ -98,9 +98,7 @@ int main(int argc, char *argv[])
        case UCALL_DONE:
                break;
        case UCALL_ABORT:
-               TEST_FAIL("%s at %s:%ld : argN+1 = 0x%lx, argN+2 = 0x%lx",
-                         (const char *)uc.args[0], __FILE__, uc.args[1],
-                         uc.args[2], uc.args[3]);
+               REPORT_GUEST_ASSERT_2(uc, "argN+1 = 0x%lx, argN+2 = 0x%lx");
        default:
                TEST_FAIL("Unknown ucall %lu", uc.cmd);
        }
index f84dc37426f535d754c839fd0d27d7828744fe42..a4f06370a24544414f3cf3f5ab05a3c167871d38 100644 (file)
@@ -400,8 +400,7 @@ static void check_for_guest_assert(struct kvm_vcpu *vcpu)
 
        if (vcpu->run->exit_reason == KVM_EXIT_IO &&
            get_ucall(vcpu, &uc) == UCALL_ABORT) {
-               TEST_FAIL("%s at %s:%ld",
-                         (const char *)uc.args[0], __FILE__, uc.args[1]);
+               REPORT_GUEST_ASSERT(uc);
        }
 }
 
@@ -610,7 +609,7 @@ static int handle_ucall(struct kvm_vcpu *vcpu)
 
        switch (get_ucall(vcpu, &uc)) {
        case UCALL_ABORT:
-               TEST_FAIL("Guest assertion not met");
+               REPORT_GUEST_ASSERT(uc);
                break;
        case UCALL_SYNC:
                vm_ioctl(vcpu->vm, KVM_X86_SET_MSR_FILTER, &no_filter_deny);
index ccb05ef7234e0964a09e4025b82d34370c760699..d3582cea1258a53ba231cbe57413fc007b1e96f4 100644 (file)
@@ -114,8 +114,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        apic_access_addr = uc.args[1];
index 40c77bb706a1d1f36096f21929e580c84a5fe672..e69e8963ed08c81e7e44fbf440bac6a602d95066 100644 (file)
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *)uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                default:
                        TEST_FAIL("Unknown ucall %lu", uc.cmd);
index 215ffa0589d46bfeae192c7875dc5d5536b1ff93..f378960299c01d8fdc319861cda2458f4f43e585 100644 (file)
@@ -123,8 +123,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        /*
index 683f4f0a1616a86322137ffcfff016a6b22355b3..8c854738f2ccf1e3a2ad96b839a8199802b49448 100644 (file)
@@ -98,7 +98,7 @@ int main(int argc, char *argv[])
        case UCALL_DONE:
                break;
        case UCALL_ABORT:
-               TEST_FAIL("%s", (const char *)uc.args[0]);
+               REPORT_GUEST_ASSERT(uc);
        default:
                TEST_FAIL("Unexpected ucall: %lu", uc.cmd);
        }
index ff4644038c557902da2d07d747e5dc363eeddf18..6bfef77b87b717801bd608e82b5d577fd444d4aa 100644 (file)
@@ -194,7 +194,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *) uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                case UCALL_SYNC:
                        switch (uc.args[0]) {
                        case USLEEP:
index 99e57b0cc2c95c5958abaecc0b4f1e73f281ed65..0a8e989d4200a64c9014fd38b38fb6e1542566a3 100644 (file)
@@ -189,8 +189,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
-                                 __FILE__, uc.args[1]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;
index e32bfb102699403d01a37c4cfc4d4dbbf0ac3a80..2e75eef926ca9ee7e3c4a4c4a29182167b6140a3 100644 (file)
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *)uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        report(uc.args[1]);
index a4a78637c35a30a89d96e7c5fcaa55afee7a6440..8a5cb800f50ed4ffa7fc0b6497361a5e27c29d1c 100644 (file)
@@ -542,7 +542,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *)uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC: {
                        struct kvm_xen_vcpu_attr rst;
index 8b76cade9bcd169c462edb6f5337b60b27ec6633..88914d48c65ed8fb5270c5d96ae45c9c55faee5d 100644 (file)
@@ -129,7 +129,7 @@ int main(int argc, char *argv[])
 
                switch (get_ucall(vcpu, &uc)) {
                case UCALL_ABORT:
-                       TEST_FAIL("%s", (const char *)uc.args[0]);
+                       REPORT_GUEST_ASSERT(uc);
                        /* NOT REACHED */
                case UCALL_SYNC:
                        break;