Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp44032pxb; Wed, 20 Apr 2022 15:34:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE4JEpacvjdYNBAuglWpR1MdQRS0VUXH4Z5lIugWekbCXC8HAQgG1aJpmY71FCd+obGqRS X-Received: by 2002:a17:902:d709:b0:155:d473:2be0 with SMTP id w9-20020a170902d70900b00155d4732be0mr21991625ply.151.1650494090004; Wed, 20 Apr 2022 15:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650494089; cv=none; d=google.com; s=arc-20160816; b=gEv+r6PDsUtd4GAdDT3ZLhVgkpG0KOB9O42nUw6Q+/RghI0t2VAyF+rBzcaLANjLoG lgb456MYGXoGZPR+RkpD/OcMaVYa1ayMWK9TUbGJ1njBsH7gMJ8Oe2AQS1Zw31xCLfDF zQXAVB4fxuu6qtsb99BYWo3eCCn6mt+wLo5pDigLw2JS+cDM9j9z3ynOaoKzONsYtlmZ 9G6mmEFecuTWElCgSzOw4L3z8tvFHYhRr2mRIhdNhKkIM18R1byi5KGw0DCMg1RZvZOP nDSpN/TLucbCKiGZ3MBMBEYkAziaXP4Z/jlsEA7efncdoNOp2Jbx8wMvR02b5poGtVj5 vAvg== 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=b6TJcLIz+PLFCqxxbKdWxXuszexJOjQzXUcB5qmATSg=; b=artHLLrWu8fpl82GC8RP8LOJNMQmQBIGtRoctSgkQJnB9SQFPSQmkZCFFQYX8/aqF1 e7+Sqg2raYXAXutBM5CmPkUKH5NqmsckEDntpk2dBgQFpx8eIghg3vYlA1fVy8/c3L+b 0NPsb0DpVxAhBvjsNEfBYQT/Dksu4TxRfB+e7ENJVTwil2kSTqi1VgkNpvjTdmkEwlPI Dert8MtTm2hvczJV5CSrnmK1ZRcYf9wHTw78k6c8f6OBk80w2nLO0OEbEbMrDfEWCDbU BT8Qk0ZAkwOaV12m/hYEndTX6vV3xpE7T/6rOmHK3CI5/3z5EJKJpHhoYBNKJBbz3+Mp m7pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YWUrpfHd; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a632113000000b003aa33a4e6e7si3580545pgh.621.2022.04.20.15.34.03; Wed, 20 Apr 2022 15:34:49 -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=@redhat.com header.s=mimecast20190719 header.b=YWUrpfHd; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357401AbiDSTB6 (ORCPT + 99 others); Tue, 19 Apr 2022 15:01:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355214AbiDSTB5 (ORCPT ); Tue, 19 Apr 2022 15:01:57 -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 ESMTP id 1252F3EF38 for ; Tue, 19 Apr 2022 11:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650394753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b6TJcLIz+PLFCqxxbKdWxXuszexJOjQzXUcB5qmATSg=; b=YWUrpfHdqY1ZhCLfaBbuo/1xQKWgsXy4uVIny86XZ8HDAWt53V8VM6/Hq94xR0mCJc0yql oYrHTaQXNYH65xXDpKwBOPtXexnYfpKCCPTX6JE6rj2R3pWivenQAbC0zm7fTB9lmx1dMQ wK/gtm0/1nQApwX9R4obI3Y2cn5Hh80= Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-255-vO6CQVmpOBWxGc2LPeQMjA-1; Tue, 19 Apr 2022 14:59:08 -0400 X-MC-Unique: vO6CQVmpOBWxGc2LPeQMjA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7988438025EE; Tue, 19 Apr 2022 18:59:07 +0000 (UTC) Received: from thuth.com (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 532C9572321; Tue, 19 Apr 2022 18:59:04 +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 v2 1/4] KVM: s390: selftests: Use TAP interface in the memop test Date: Tue, 19 Apr 2022 20:58:54 +0200 Message-Id: <20220419185857.128351-2-thuth@redhat.com> In-Reply-To: <20220419185857.128351-1-thuth@redhat.com> References: <20220419185857.128351-1-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_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. 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..ad9fe86c0592 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(); } -- 2.27.0