Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2156192rwb; Sat, 29 Jul 2023 00:38:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHBS0xocGT01fj2GxQ5jAtAod/FE84xzbvsWwTfiFRvKKDBdGPMXmCNpGgsRQAIsYrqZaXn X-Received: by 2002:a17:907:6e8c:b0:99b:cadd:c2ee with SMTP id sh12-20020a1709076e8c00b0099bcaddc2eemr2062954ejc.29.1690616294546; Sat, 29 Jul 2023 00:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690616294; cv=none; d=google.com; s=arc-20160816; b=aD4EbfRFE3ogl2CL27f73qWiDUFc1k8OVr9JV/L56VTPoocxeKZX9gJ3e9iZrs3Ipr CZIkZ4yuZljgb6Uc6B72b6x8BJ/D6hySLZ5oAGr5+9emg3HMkdaeur4KrC/T+Xl0Jmqj dSsUoEoH9TZLLjqF9060GaFuH4lXC2krrXf+WPgnoZOVxx19xdby6HYr0HzlcMKw+D76 AtSh1X3vJK31UHb2RVbldTpCYvJRsozvCG0n/qVL2CFOq11tWa18FOFOj0VZfltryMkA KhVA43HNzBdYcPU2Ok7kt1SV/rp7LbbKMoOGaBXluKjGXn5rgLAEuDHES8fhuNNULmV2 myQg== 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=4KUkVA9WMnyLxYGz79SDCJn7ve+A3Wf1F6DPB0+B89Y=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=S7xtMwFjJxTCIL77KGEcejbSMwPeJCVW5YlnEruDSKI5iJjWpdiHOV4g4SImJRzOiQ fOMV3kmalH1K738OFgphICbdN1wqdcUcsbV+keom+1m2YtB8cVTM4PnaDhgMmbOoV+mI yfbZLM5b9Fd+9v0j/10gh2ukOtcxly7h5Qp9C/r7r/7q5ptEXfAKvbFLtVlqzUn5HC21 BX47edrWjAFsRuqCuYggUMrVBrE4X0VUwbg5H8JV9+i+vSODDaie3o6Y8Q0ge3TOvZ/7 7RqjkdN3pylmB9WhlupM/tX+FGF5XHODAsicFzkWnI2zddBxu/69HbPjaLRD5sKbfocT WcyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=m1lnc4WN; 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 i15-20020a1709063c4f00b00989a806b3fasi740171ejg.1031.2023.07.29.00.37.49; Sat, 29 Jul 2023 00:38:14 -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=m1lnc4WN; 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 S236665AbjG2AjQ (ORCPT + 99 others); Fri, 28 Jul 2023 20:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236233AbjG2Aih (ORCPT ); Fri, 28 Jul 2023 20:38:37 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F414688 for ; Fri, 28 Jul 2023 17:37:46 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1bba9a0da10so18216235ad.2 for ; Fri, 28 Jul 2023 17:37:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591042; x=1691195842; 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=4KUkVA9WMnyLxYGz79SDCJn7ve+A3Wf1F6DPB0+B89Y=; b=m1lnc4WNUUb4LhX1UCRMwTzJ/kua4mNB+cCI2zAZJDw/YuWyBNC/mjTXyBnbABdSwK XlTEeooUTC/+KEnZs8SdsD7KD4D5QT2j61EexSFXezqGR/jmMDfqT8QirXCkaEUchBzC yQnQHpQKSbauSGLL1v1IXcHYKGUzNuLGMNkFvyI4TcWFeI2ssuz9YaMH0Oei27k/Nyon 5p7fEQS3naCoN6/hzKKe7XVSJuuPLuc5vpk+ZhrcR46/7R1M/CvlAIb/SNLlgSZcRNvd /rG6QtBHZYxac3GXVkkOzTpCaNB7ZTUbXG+aooqbeSQfPP1kS8AIrJeT4F/CLnedG0IS LNzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591042; x=1691195842; 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=4KUkVA9WMnyLxYGz79SDCJn7ve+A3Wf1F6DPB0+B89Y=; b=ftj50c/TzgJeLrjYxI3nC/UaholO2sUo36Zt7L9zo+nu1sx1ck4rLStJ4ctbQUvgGJ 87ZCuTQ98wYCKNN0ZD0k9nIaz1vG6UJ5VYAcg0LdLknBNguMiez7fNgO15pkAr2EX8Ob hTFFpfuclQ92msIYAN9RYDlpVW2ezPGPS8QR+jGANCFpJXi7qsSR7uVDkOpBcDetOz39 VfJ7SLgW4/GlkobU2DDG4o4bkbyDRAGVps3nmWZ9nkycsHNw4X4R9cTVC2GacCdZKj9U hHEp463UHeeOqZPWD1NrWXvxBMFp1q/43N7MCR+n3vcxAi5H46nncOiB29V40tDzLMiK BBfQ== X-Gm-Message-State: ABy/qLYJ1CiZqfZiJwXD8kEG98AmZpT6tZHqGV+fIMR6vfCWMODNxWyu vf0j1r9d/sKXkyCSu7oMAYp1bPQmhgM= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:d4c9:b0:1bb:8c42:79f4 with SMTP id o9-20020a170902d4c900b001bb8c4279f4mr11146plg.2.1690591042672; Fri, 28 Jul 2023 17:37:22 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:28 -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-20-seanjc@google.com> Subject: [PATCH v4 19/34] KVM: selftests: Convert steal_time test to printf style GUEST_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=unavailable 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 Convert the steal_time test to use printf-based GUEST_ASERT. Opportunistically use GUEST_ASSERT_EQ() and GUEST_ASSERT_NE() so that the test spits out debug information on failure. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/steal_time.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c index c87f38712073..8649c8545882 100644 --- a/tools/testing/selftests/kvm/steal_time.c +++ b/tools/testing/selftests/kvm/steal_time.c @@ -4,6 +4,8 @@ * * Copyright (C) 2020, Red Hat, Inc. */ +#define USE_GUEST_ASSERT_PRINTF 1 + #define _GNU_SOURCE #include #include @@ -31,8 +33,8 @@ static uint64_t guest_stolen_time[NR_VCPUS]; static void check_status(struct kvm_steal_time *st) { GUEST_ASSERT(!(READ_ONCE(st->version) & 1)); - GUEST_ASSERT(READ_ONCE(st->flags) == 0); - GUEST_ASSERT(READ_ONCE(st->preempted) == 0); + GUEST_ASSERT_EQ(READ_ONCE(st->flags), 0); + GUEST_ASSERT_EQ(READ_ONCE(st->preempted), 0); } static void guest_code(int cpu) @@ -40,7 +42,7 @@ static void guest_code(int cpu) struct kvm_steal_time *st = st_gva[cpu]; uint32_t version; - GUEST_ASSERT(rdmsr(MSR_KVM_STEAL_TIME) == ((uint64_t)st_gva[cpu] | KVM_MSR_ENABLED)); + GUEST_ASSERT_EQ(rdmsr(MSR_KVM_STEAL_TIME), ((uint64_t)st_gva[cpu] | KVM_MSR_ENABLED)); memset(st, 0, sizeof(*st)); GUEST_SYNC(0); @@ -122,8 +124,8 @@ static int64_t smccc(uint32_t func, uint64_t arg) static void check_status(struct st_time *st) { - GUEST_ASSERT(READ_ONCE(st->rev) == 0); - GUEST_ASSERT(READ_ONCE(st->attr) == 0); + GUEST_ASSERT_EQ(READ_ONCE(st->rev), 0); + GUEST_ASSERT_EQ(READ_ONCE(st->attr), 0); } static void guest_code(int cpu) @@ -132,15 +134,15 @@ static void guest_code(int cpu) int64_t status; status = smccc(SMCCC_ARCH_FEATURES, PV_TIME_FEATURES); - GUEST_ASSERT(status == 0); + GUEST_ASSERT_EQ(status, 0); status = smccc(PV_TIME_FEATURES, PV_TIME_FEATURES); - GUEST_ASSERT(status == 0); + GUEST_ASSERT_EQ(status, 0); status = smccc(PV_TIME_FEATURES, PV_TIME_ST); - GUEST_ASSERT(status == 0); + GUEST_ASSERT_EQ(status, 0); status = smccc(PV_TIME_ST, 0); - GUEST_ASSERT(status != -1); - GUEST_ASSERT(status == (ulong)st_gva[cpu]); + GUEST_ASSERT_NE(status, -1); + GUEST_ASSERT_EQ(status, (ulong)st_gva[cpu]); st = (struct st_time *)status; GUEST_SYNC(0); -- 2.41.0.487.g6d72f3e995-goog