Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp356358rdb; Thu, 5 Oct 2023 07:58:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQjfMqwWA5Cy+yZIMtMsVS4GTV72ZmArc7QOvL8ld2wyfhkmBeNl0TNXhdMsCt3Gm9nfDd X-Received: by 2002:aca:220e:0:b0:3af:26e3:92e with SMTP id b14-20020aca220e000000b003af26e3092emr4781282oic.28.1696517903250; Thu, 05 Oct 2023 07:58:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517903; cv=none; d=google.com; s=arc-20160816; b=sVuiliKGeH0DP/G2yQyEIaJFQ5lW92YAPel/xStQ4mp+5XV2c2gP91OyGoi4kB3Fuz jphz1hlpnTQGEvoCMn9Pn8zmp+cTif7t4Z2xrjNwZNWYsKuRuHPpjwRKhIYSB2yzUea4 bF1IlrbptwdICE0UGBkJaW2CYQlXNMlJD76SJ7XeW/ejIIuhmR5f3OCD4258biXlONek YVMfCjfNsO9LCs0AxOFhBLZyDvQOQlTSr/lC44saGyRbOAACwV/duJY1NcXiQuwHzDfu V+F71i2IW+O4mGpnNuia2L5HwnCt0Qmhh+VftOVpHdYx04j9V7MImlnvd2flew8jzCxw AVDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vazohg9FZ6E9GP8kzgkpGCob+IwdhO7BJaWstWzvEzQ=; fh=WOoc99rHeo9qxHvnIaWffALNRebT/42m1dldSuRpBY0=; b=BIjy3QtsYg6en+6dNM1yIYpFmW42jSxfMyJ4bfwrlu9wvVBhkqqzqSWHQIiEqAQIVL QWRuzLYqVOFWxcr1SN9je9xHKXTCQN6bEJsB6/WH4p3P4aHh6Al2c3y3pJLwFaYppSSF +pr7P4JSyZr75Wz9Ah2hhxoumxhM7OT37lZ7LJQzDpV9icmsiALHhshoxpF/sGv3dFzX xSCTvB1FepkxJ8ye56gxWwhv+z2YzgQdG2beP8Sw+8ZyarVhFJBEoq2o2EMPInt2XGUn hkQPCxVO1N5UytzalCDK/1bpkEZNwyuBDaC8vesgATfvw+Wym/CHIsnxo+QsbE806LRq hSFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="S/twEhDr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o2-20020a634102000000b00564bcae8b53si1544617pga.803.2023.10.05.07.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="S/twEhDr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 11BDA82F4E26; Thu, 5 Oct 2023 07:58:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234295AbjJEO46 (ORCPT + 99 others); Thu, 5 Oct 2023 10:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237459AbjJEOz2 (ORCPT ); Thu, 5 Oct 2023 10:55:28 -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 8805D26A4D for ; Thu, 5 Oct 2023 07:38:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696516729; 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: in-reply-to:in-reply-to:references:references; bh=vazohg9FZ6E9GP8kzgkpGCob+IwdhO7BJaWstWzvEzQ=; b=S/twEhDraY8Vsn5CJJfUD7aYTGADaVG2MyFDXe7gNRSOYyXSQSQkjGuUQjUWoT5pB4j6ts +BhjBOonoSxb5icaZUr5pY+mn2z+IxcP+WvsIsyD6AlrhLpAT0JqJoFRLP8eKjsYoKXtZz eiBxYMDBlkvXWeRS3+BnDCnN7AWOO2Y= 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-183-RutCxQ4vM7W0K_V5cIuMSw-1; Thu, 05 Oct 2023 10:38:47 -0400 X-MC-Unique: RutCxQ4vM7W0K_V5cIuMSw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 BFF9C3C1E9D7; Thu, 5 Oct 2023 14:38:46 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BA0A40C6EA8; Thu, 5 Oct 2023 14:38:45 +0000 (UTC) From: Thomas Huth To: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 3/7] KVM: selftests: Add a macro to define a test with one vcpu Date: Thu, 5 Oct 2023 16:38:35 +0200 Message-ID: <20231005143839.365297-4-thuth@redhat.com> In-Reply-To: <20231005143839.365297-1-thuth@redhat.com> References: <20231005143839.365297-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:58:22 -0700 (PDT) Most tests are currently not giving any proper output for the user to see how much sub-tests have already been run, or whether new sub-tests are part of a binary or not. So it would be good to support TAP output in the KVM selftests. There is already a nice framework for this in the kselftest_harness.h header which we can use. But since we also need a vcpu in most KVM selftests, it also makes sense to introduce our own wrapper around this which takes care of creating a VM with one vcpu, so we don't have to repeat this boilerplate in each and every test. Thus let's introduce a KVM_ONE_VCPU_TEST() macro here which takes care of this. Suggested-by: Sean Christopherson Link: https://lore.kernel.org/all/Y2v+B3xxYKJSM%2FfH@google.com/ Signed-off-by: Thomas Huth --- .../selftests/kvm/include/kvm_test_harness.h | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tools/testing/selftests/kvm/include/kvm_test_harness.h diff --git a/tools/testing/selftests/kvm/include/kvm_test_harness.h b/tools/testing/selftests/kvm/include/kvm_test_harness.h new file mode 100644 index 0000000000000..04cfc44e3b506 --- /dev/null +++ b/tools/testing/selftests/kvm/include/kvm_test_harness.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Macros for defining a KVM test + * + * Copyright (C) 2022, Google LLC. + */ + +#ifndef SELFTEST_KVM_TEST_HARNESS_H +#define SELFTEST_KVM_TEST_HARNESS_H + +#include "kselftest_harness.h" + +#define KVM_ONE_VCPU_TEST_SUITE(name, guest_code) \ + FIXTURE(name) { \ + struct kvm_vcpu *vcpu; \ + }; \ + \ + FIXTURE_SETUP(name) { \ + (void)vm_create_with_one_vcpu(&self->vcpu, guest_code); \ + } \ + \ + FIXTURE_TEARDOWN(name) { \ + kvm_vm_free(self->vcpu->vm); \ + } + +#define KVM_ONE_VCPU_TEST(suite, test) \ +static void __suite##_##test(struct kvm_vcpu *vcpu); \ + \ +TEST_F(suite, test) \ +{ \ + __suite##_##test(self->vcpu); \ +} \ +static void __suite##_##test(struct kvm_vcpu *vcpu) + +#endif /* SELFTEST_KVM_TEST_HARNESS_H */ -- 2.41.0