Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1925016rwb; Fri, 28 Jul 2023 18:17:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZGZnC3ECxHwpqxgfwffH+D+ySwmSFtpoM5awhZ56XUx0iTcVf7EbueC77e6Q7hIS5kUX0 X-Received: by 2002:a05:6a20:8423:b0:12f:acc9:286 with SMTP id c35-20020a056a20842300b0012facc90286mr4431325pzd.17.1690593461414; Fri, 28 Jul 2023 18:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690593461; cv=none; d=google.com; s=arc-20160816; b=PyPsvTfaJYs4cjCvaysGd472TCwN3iOr9+SUDMKydJIXqo2NdA1gSR1rlt6R8SJtgI l7R32GSEM/XasJYyjkeSjRwEx+cWZXRmB1HCqIna7ZxrM9QzuOXUngypEphykmeVdBkh 9bx/m04QNkneYtP23eOXN2Fb1+Uy/HB433s6KpSOlsNk7KhtSTluR/UD0o9hOUlFuh1w 5F10WxBTHXVcfFfNdhPB7tKqKYVBWLvDSGzHmH4ZNyDb5mN2nrVbeSbQ46dDxZ1mdHHy xbeYITYp+paBVk47aj+t+INJQ/ziodnhwlTMr2lvQtODUgfR29+IPoiLETLKqZuFgyse C5gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=PdMhF3+dbu8TQ3iqZdPs1TdexnvVx+yUupHryp41YZs=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=uAvc2E+dZqkj66oMvF9WyS94dVaWHLc7YgFq7dSCyYBdqeyiJNajDU+Dx0GixyGYqT uDaGAielOfUBpdX/6Ytiq4J7nfkFvEW3Q8YX9ajn09Rg4iyjI0oQSVE2DXtHD11Z/ey+ KQ6VyZsSYOnD8CxvNbEzP/3F8TELdiWymw7shoO73av7L9Go42FViNGcb2hjRwhDZuyp S3Icctif3QfRBAu2cZ1JKjG1W8od8tr7xCR49V4/1WjNZiMG4P3Ky4AfmOcZVgCJnfxL ZOsUuHIlETE8DY6NbVwgVi8H0ZnX0y7IAEp/ixJyqE+ZnKE+EzpCQtEEQKTOYiN4Nw1Z dFnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="g48/ENXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd5-20020a056a00420500b006870b0a14cfsi2195299pfb.134.2023.07.28.18.17.21; Fri, 28 Jul 2023 18:17:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="g48/ENXs"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233262AbjG2Agy (ORCPT + 99 others); Fri, 28 Jul 2023 20:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbjG2Agw (ORCPT ); Fri, 28 Jul 2023 20:36:52 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23EC3C2 for ; Fri, 28 Jul 2023 17:36:51 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d06d36b49f9so2532249276.1 for ; Fri, 28 Jul 2023 17:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591010; x=1691195810; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=PdMhF3+dbu8TQ3iqZdPs1TdexnvVx+yUupHryp41YZs=; b=g48/ENXsZE3ltSl/IkRKy7TA29P1cX8hWNyuXQnOISi+o77fY0rzEcEpSaUCGzHtbC PhFE3nvUYKdM+6pL08G0PIiG/YDC0ZfEhHxCv90zQYJNzPUm015+GM8Ijwd4pGJIOXH3 yTpeOeHTHgFfv3+kFWRtYrvW4JAD+m3tSo+Pxr/TbHE8msuKXqOmrPh8c4IM0wy/t+uw mx1NhRmD4Yg573qf2o0VyjOuMvUaDiRQsccLWxEQqeHf98TR2+Q5dM0FleJ1LtBbFwYD 745nuvDW6t0CkMPbv9trtc4Ozl5io5Xc1LwmNLArSe2A/F0whCXtl59d8/f6Aot9QnOI 5ahQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591010; x=1691195810; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PdMhF3+dbu8TQ3iqZdPs1TdexnvVx+yUupHryp41YZs=; b=TIvpSqBV5GSBXxSBE4PBz7xc/1GQpMDYnB8A0dVsc/AS/LXKgXKqWEC8NhsW/mWYF6 LHVHbMyf2W12YkadLVkhwY4isFm0ogWtV4cc9DLxhVZYk9K1Z8SNOMwwNzwjQHW/6910 W1Wq3CCclF4Z44iF7hQ7eTjNv9dGTZ++9aRXv6uccmZr6Vhe+Tu9Z5JiETGbEhbtk+BR C7DxegCoGUky39agxOB4l7CRmxdNM7RVEFAY0FriOTEzLeHb8K8suKLGeQM8HGxLyaww qUZMt/zuKfNI4yO1op8N3P9Lad63DP7dZAdlfGPb1OOlLuFSKYnNxTsBM0SxIzs/Bq/d yJtA== X-Gm-Message-State: ABy/qLYCWhSNpRD4fFQ6El8pC961puetOE2/+dTgxZNrXxfh51ukPQ+h NILm0dMNniuZg3dYG4PGbgcO2dswCK8= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2083:0:b0:d0d:4910:cf0b with SMTP id g125-20020a252083000000b00d0d4910cf0bmr18518ybg.10.1690591010455; Fri, 28 Jul 2023 17:36:50 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:11 -0700 In-Reply-To: <20230729003643.1053367-1-seanjc@google.com> Mime-Version: 1.0 References: <20230729003643.1053367-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230729003643.1053367-3-seanjc@google.com> Subject: [PATCH v4 02/34] KVM: selftests: Make TEST_ASSERT_EQ() output look like normal TEST_ASSERT() From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Sean Christopherson , Thomas Huth , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Aaron Lewis Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clean up TEST_ASSERT_EQ() so that the (mostly) raw code is captured in the main assert message, not the helper macro's code. E.g. make this: x86_64/tsc_msrs_test.c:106: __a == __b pid=40470 tid=40470 errno=0 - Success 1 0x000000000040170e: main at tsc_msrs_test.c:106 2 0x0000000000416f23: __libc_start_call_main at libc-start.o:? 3 0x000000000041856f: __libc_start_main_impl at ??:? 4 0x0000000000401ef0: _start at ??:? TEST_ASSERT_EQ(rounded_host_rdmsr(MSR_IA32_TSC), val + 1) failed. rounded_host_rdmsr(MSR_IA32_TSC) is 0 val + 1 is 0x1 look like this: x86_64/tsc_msrs_test.c:106: rounded_host_rdmsr(MSR_IA32_TSC) == val + 1 pid=5737 tid=5737 errno=0 - Success 1 0x0000000000401714: main at tsc_msrs_test.c:106 2 0x0000000000415c23: __libc_start_call_main at libc-start.o:? 3 0x000000000041726f: __libc_start_main_impl at ??:? 4 0x0000000000401e60: _start at ??:? 0 != 0x1 (rounded_host_rdmsr(MSR_IA32_TSC) != val + 1) Opportunstically clean up the formatting of the entire macro. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/include/test_util.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index e734e52d8a3a..a4bea44f990c 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -53,14 +53,13 @@ void test_assert(bool exp, const char *exp_str, #define TEST_ASSERT(e, fmt, ...) \ test_assert((e), #e, __FILE__, __LINE__, fmt, ##__VA_ARGS__) -#define TEST_ASSERT_EQ(a, b) do { \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - TEST_ASSERT(__a == __b, \ - "TEST_ASSERT_EQ(%s, %s) failed.\n" \ - "\t%s is %#lx\n" \ - "\t%s is %#lx", \ - #a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \ +#define TEST_ASSERT_EQ(a, b) \ +do { \ + typeof(a) __a = (a); \ + typeof(b) __b = (b); \ + test_assert(__a == __b, #a " == " #b, __FILE__, __LINE__, \ + "%#lx != %#lx (%s != %s)", \ + (unsigned long)(__a), (unsigned long)(__b), #a, #b);\ } while (0) #define TEST_ASSERT_KVM_EXIT_REASON(vcpu, expected) do { \ -- 2.41.0.487.g6d72f3e995-goog