From patchwork Thu Oct 19 09:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 155417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp271302vqb; Thu, 19 Oct 2023 03:00:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXAlG4z6CB6/m8oZeNZ0iJn4DSEVj3Aelx2tq+f1YgEf4TLVg0iWB7eVhoUujd/qm/QnMq X-Received: by 2002:a05:6a21:1ca4:b0:17a:e79c:c5ab with SMTP id sf36-20020a056a211ca400b0017ae79cc5abmr1332519pzb.48.1697709648310; Thu, 19 Oct 2023 03:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697709648; cv=none; d=google.com; s=arc-20160816; b=pt2Ug6M78vULinJ9MlxQcNQE3xyL/UQyXqwSMKXbMFgGN0Wj4+PCqGF6JgSIbf1heS HxuotFOkgC2wcgWurhqC5NfGsRVGGn6WiWB4liVNZRmSFfTQDG+SSKGBhyXid6NrSlfS B8fxLb3ZKEVaJWO0GyNME01kquaTBskLnqI8ywUTSUYQkGJ/96HHF/uVCQ/p5AUyW6iA PvH1smG/lqpL8cNLUwOhDl2jT6joQH2TGBt4H4zh6TgEet/ABz7X4nAPRAQ0GDkh3Bj0 qBKjvEW2KYTPip3KGLxk6z3TCzFYTSRpu78zSGyLYOZ/aWhNCz5mOe3kmoTKLLGmRPHr Zqfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=o0GKBFmVobxSwwKQNWW2TaS9XDs1vVwJ1OIKQU3bmTQ=; fh=pkJvF2e+f61AFw8/qrF6ZpI40sHHMpXrT/Uu50oryIM=; b=BCJzOT+jEobMvK0PI0ieBOBGm04xQ8Lj4BjX931vNffl/2lZeSSBNbmjTGaC/+suw6 M1Ajm0Of4iq1YFCwdbnereItL1WLEZqX3dEUNfZeDJDjmFv7QDVC0J5AMllpSWAupmV5 XhYXr82p0UMTvPE0zQNoYZJB6V7r4W3CsOYcojrdi9JXu7gSaEt0ExGNf0ctmZrzczb3 od7mszxUF4QQmtd6v3axdCkPPl3tcBS0Cip8ZFAMwUN8ztEtrPDbvo4oysFwGlDZkRVo aCimEDXrgKWaPFZ1Rd94x86thhAAQYVPaIWbuBkKeE58rVcRvS1u5A9MkrTJL6aGdPjg b0xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Mce4/mZS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id x5-20020a654145000000b005b4ef61bfc7si3862096pgp.596.2023.10.19.03.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 03:00:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Mce4/mZS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 08C2A8233671; Thu, 19 Oct 2023 03:00:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345137AbjJSJ7z (ORCPT + 24 others); Thu, 19 Oct 2023 05:59:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345060AbjJSJ7z (ORCPT ); Thu, 19 Oct 2023 05:59:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC67A11D for ; Thu, 19 Oct 2023 02:59:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697709550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=o0GKBFmVobxSwwKQNWW2TaS9XDs1vVwJ1OIKQU3bmTQ=; b=Mce4/mZSuadzdZ+eOqyKKrZMAotNxHBXHHm5j/rjtO05zk00bY1lO4bmMeMwazMPlJtXkK dE2KArYSRfOC0TOp5zZFie88nbOYPoUdMNi34dTWcd6jfr7ceK8fMqJOBPLi2yJBxxJTvo kc4HHYErnRLEkUNUZL2HxFnp9XuP1B8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-527-WXWgN8iYMBSDQW7kCX414A-1; Thu, 19 Oct 2023 05:59:02 -0400 X-MC-Unique: WXWgN8iYMBSDQW7kCX414A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 225BB1C068D3; Thu, 19 Oct 2023 09:59:02 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 170208AF; Thu, 19 Oct 2023 09:59:00 +0000 (UTC) From: Thomas Huth To: Paolo Bonzini , kvm@vger.kernel.org Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: selftests: Use TAP in the steal_time test Date: Thu, 19 Oct 2023 11:59:00 +0200 Message-ID: <20231019095900.450467-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 03:00:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780177592174729097 X-GMAIL-MSGID: 1780177592174729097 For easier use of the tests in automation and for having some status information for the user while the test is running, let's provide some TAP output in this test. Signed-off-by: Thomas Huth Reviewed-by: Andrew Jones --- NB: This patch does not use the interface from kselftest_harness.h since it is not very suitable for the for-loop in this patch. tools/testing/selftests/kvm/steal_time.c | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c index 171adfb2a6cb..aa6149eb9ea1 100644 --- a/tools/testing/selftests/kvm/steal_time.c +++ b/tools/testing/selftests/kvm/steal_time.c @@ -81,20 +81,18 @@ static void steal_time_init(struct kvm_vcpu *vcpu, uint32_t i) static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx) { struct kvm_steal_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]); - int i; - pr_info("VCPU%d:\n", vcpu_idx); - pr_info(" steal: %lld\n", st->steal); - pr_info(" version: %d\n", st->version); - pr_info(" flags: %d\n", st->flags); - pr_info(" preempted: %d\n", st->preempted); - pr_info(" u8_pad: "); - for (i = 0; i < 3; ++i) - pr_info("%d", st->u8_pad[i]); - pr_info("\n pad: "); - for (i = 0; i < 11; ++i) - pr_info("%d", st->pad[i]); - pr_info("\n"); + ksft_print_msg("VCPU%d:\n", vcpu_idx); + ksft_print_msg(" steal: %lld\n", st->steal); + ksft_print_msg(" version: %d\n", st->version); + ksft_print_msg(" flags: %d\n", st->flags); + ksft_print_msg(" preempted: %d\n", st->preempted); + ksft_print_msg(" u8_pad: %d %d %d\n", + st->u8_pad[0], st->u8_pad[1], st->u8_pad[2]); + ksft_print_msg(" pad: %d %d %d %d %d %d %d %d %d %d %d\n", + st->pad[0], st->pad[1], st->pad[2], st->pad[3], + st->pad[4], st->pad[5], st->pad[6], st->pad[7], + st->pad[8], st->pad[9], st->pad[10]); } #elif defined(__aarch64__) @@ -197,10 +195,10 @@ static void steal_time_dump(struct kvm_vm *vm, uint32_t vcpu_idx) { struct st_time *st = addr_gva2hva(vm, (ulong)st_gva[vcpu_idx]); - pr_info("VCPU%d:\n", vcpu_idx); - pr_info(" rev: %d\n", st->rev); - pr_info(" attr: %d\n", st->attr); - pr_info(" st_time: %ld\n", st->st_time); + ksft_print_msg("VCPU%d:\n", vcpu_idx); + ksft_print_msg(" rev: %d\n", st->rev); + ksft_print_msg(" attr: %d\n", st->attr); + ksft_print_msg(" st_time: %ld\n", st->st_time); } #endif @@ -267,7 +265,9 @@ int main(int ac, char **av) vm_userspace_mem_region_add(vm, VM_MEM_SRC_ANONYMOUS, ST_GPA_BASE, 1, gpages, 0); virt_map(vm, ST_GPA_BASE, ST_GPA_BASE, gpages); + ksft_print_header(); TEST_REQUIRE(is_steal_time_supported(vcpus[0])); + ksft_set_plan(NR_VCPUS); /* Run test on each VCPU */ for (i = 0; i < NR_VCPUS; ++i) { @@ -308,14 +308,14 @@ int main(int ac, char **av) run_delay, stolen_time); if (verbose) { - pr_info("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld", i, - guest_stolen_time[i], stolen_time); - if (stolen_time == run_delay) - pr_info(" (BONUS: guest test-stolen-time even exactly matches test-run_delay)"); - pr_info("\n"); + ksft_print_msg("VCPU%d: total-stolen-time=%ld test-stolen-time=%ld%s\n", + i, guest_stolen_time[i], stolen_time, + stolen_time == run_delay ? + " (BONUS: guest test-stolen-time even exactly matches test-run_delay)" : ""); steal_time_dump(vm, i); } + ksft_test_result_pass("vcpu%d\n", i); } - return 0; + ksft_finished(); /* Print results and exit() accordingly */ }