Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp168897iob; Mon, 2 May 2022 16:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBW63MfmqVIl5QqUMI1Hy5VSr3lWuvb/hsRMpoNKb+gyd9+98OUpJXrVot5hw8gj5AjlUl X-Received: by 2002:a17:90a:a593:b0:1c9:b837:e77d with SMTP id b19-20020a17090aa59300b001c9b837e77dmr1539083pjq.205.1651532965447; Mon, 02 May 2022 16:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651532965; cv=none; d=google.com; s=arc-20160816; b=W5TsgN9gMhQvoVcBwofCkIzQDk7bpxCGab88R6hJ2vy4AnXuUFRKv/k+PRGCS2sKje HTnnwbudCeO6XC08MS7fH99zOF1dHRlkObyw5AMb1w6ozohxrFs1Y6oTRr2xsmqKnXcX iS3HAFY+MsXqh5qBqN5qc3AiLFiE9q57vi7/C8s1kWkwi9+gs0/EtYP+gjajaE4lAY76 cQl1idzQ/R+RAugr0LfG8bI4/ExgU552aT99mEmOqgY9lGbBQ1msdDIQ9NaeleXHI7tw asUuO+14kCy/b9m01qOA5yEsjihKba5UDNgOkFkqpeFc+ib2Xt8taei6j/PW0DQgiueN zZHw== 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=yIng3JzdUPtQk2EgQVeJ1LDlFP3/mpoZsPdx0fgK9Gw=; b=sPp9RyTM1Lx1ZBfdZ2By9pyUqRgKppjYi/KDVX/s3Wmcx7bV9tujR+jv5AOm/JwyRc 1w2SieGBlhc0m313ReT0489JXidVjtS7p5bpTE63M/QQkRcIDUseDQMJksfj2p25nUSW 0fkajAci2xShzHXEzkp9IuyD/pnVfsYbVfpz7V7MfTT7HE0Bgj3YhOLh/V0hjcsLc5MC H+HN6i8UbwaiAkpvJSCDwBDS97uJP0pOVu1+vfk+CljbrpsiOR0kZ1zBWcfJXNYboP7Q hfeat9NIGZMkYl7karbRfVb1/ih8bKU2ERYHGWVfwr/ku+G/IxsWzMRAnpvxGy1Z0kWQ MDRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XFrQsFDk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c188-20020a6335c5000000b003aa65024928si6973142pga.224.2022.05.02.16.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:09:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XFrQsFDk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBE362F004; Mon, 2 May 2022 16:09:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354605AbiD2GlU (ORCPT + 99 others); Fri, 29 Apr 2022 02:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354596AbiD2GlQ (ORCPT ); Fri, 29 Apr 2022 02:41:16 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B7EADB8982 for ; Thu, 28 Apr 2022 23:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651214277; 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=yIng3JzdUPtQk2EgQVeJ1LDlFP3/mpoZsPdx0fgK9Gw=; b=XFrQsFDkDPcJgZhMh8hP/16hICtD8mAAKfVrQ/kFdVsLQ/VhF5C08or2frNDOy8NgegUH5 8uJZXJXObHTC3hVH0EJuzk7TcmYzSexp4mnv8JYbW854Yq/FD+W80i0eCHgzMTV/VrHDnH b96KbnGE0rVVAI70g1WcVCYoVKf0sjY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-C3zT8bG-PVaW5btMnPsgwg-1; Fri, 29 Apr 2022 02:37:54 -0400 X-MC-Unique: C3zT8bG-PVaW5btMnPsgwg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E45DF85A5A8; Fri, 29 Apr 2022 06:37:53 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0669514A5060; Fri, 29 Apr 2022 06:37:50 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, David Hildenbrand , Paolo Bonzini , Shuah Khan , Janis Schoetterl-Glausch , linux-s390@vger.kernel.org Subject: [PATCH v3 1/4] KVM: s390: selftests: Use TAP interface in the memop test Date: Fri, 29 Apr 2022 08:37:21 +0200 Message-Id: <20220429063724.480919-2-thuth@redhat.com> In-Reply-To: <20220429063724.480919-1-thuth@redhat.com> References: <20220429063724.480919-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 The memop test currently does not have any output (unless one of the TEST_ASSERT statement fails), so it's hard to say for a user whether a certain new sub-test has been included in the binary or not. Let's make this a little bit more user-friendly and include some TAP output via the kselftests.h interface. Reviewed-by: Janosch Frank Signed-off-by: Thomas Huth --- tools/testing/selftests/kvm/s390x/memop.c | 90 ++++++++++++++++++----- 1 file changed, 73 insertions(+), 17 deletions(-) diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c index b04c2c1b3c30..79f2ec338161 100644 --- a/tools/testing/selftests/kvm/s390x/memop.c +++ b/tools/testing/selftests/kvm/s390x/memop.c @@ -12,6 +12,7 @@ #include "test_util.h" #include "kvm_util.h" +#include "kselftest.h" enum mop_target { LOGICAL, @@ -648,33 +649,88 @@ static void test_errors(void) kvm_vm_free(t.kvm_vm); } +struct testdef { + const char *name; + void (*test)(void); + int cap; +} testlist[] = { + { + .name = "simple copy", + .test = test_copy, + }, + { + .name = "generic error checks", + .test = test_errors, + }, + { + .name = "copy with storage keys", + .test = test_copy_key, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "copy with key storage protection override", + .test = test_copy_key_storage_prot_override, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "copy with key fetch protection", + .test = test_copy_key_fetch_prot, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "copy with key fetch protection override", + .test = test_copy_key_fetch_prot_override, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "error checks with key", + .test = test_errors_key, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "error checks with key storage protection override", + .test = test_errors_key_storage_prot_override, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "error checks without key fetch prot override", + .test = test_errors_key_fetch_prot_override_not_enabled, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, + { + .name = "error checks with key fetch prot override", + .test = test_errors_key_fetch_prot_override_enabled, + .cap = KVM_CAP_S390_MEM_OP_EXTENSION, + }, +}; + int main(int argc, char *argv[]) { - int memop_cap, extension_cap; + int memop_cap, extension_cap, idx; setbuf(stdout, NULL); /* Tell stdout not to buffer its content */ + ksft_print_header(); + memop_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP); extension_cap = kvm_check_cap(KVM_CAP_S390_MEM_OP_EXTENSION); if (!memop_cap) { - print_skip("CAP_S390_MEM_OP not supported"); - exit(KSFT_SKIP); + ksft_exit_skip("CAP_S390_MEM_OP not supported.\n"); } - test_copy(); - if (extension_cap > 0) { - test_copy_key(); - test_copy_key_storage_prot_override(); - test_copy_key_fetch_prot(); - test_copy_key_fetch_prot_override(); - test_errors_key(); - test_errors_key_storage_prot_override(); - test_errors_key_fetch_prot_override_not_enabled(); - test_errors_key_fetch_prot_override_enabled(); - } else { - print_skip("storage key memop extension not supported"); + ksft_set_plan(ARRAY_SIZE(testlist)); + + for (idx = 0; idx < ARRAY_SIZE(testlist); idx++) { + if (!testlist[idx].cap || (extension_cap && + testlist[idx].cap == KVM_CAP_S390_MEM_OP_EXTENSION)) { + testlist[idx].test(); + ksft_test_result_pass("%s\n", testlist[idx].name); + } else { + ksft_test_result_skip("%s - capability %d not supported\n", + testlist[idx].name, + testlist[idx].cap); + } } - test_errors(); - return 0; + ksft_finished(); /* Print results and exit() accordingly */ } -- 2.27.0