Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp22360lfe; Fri, 15 Apr 2022 17:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTtXmL5u1/LdC+J/uokoLxI87qd6THLScGFoPmz5ulS7XBrXnNN8iMaiGt+XDWovjiVIj/ X-Received: by 2002:a17:902:f60c:b0:156:82c9:e44b with SMTP id n12-20020a170902f60c00b0015682c9e44bmr1445965plg.106.1650069358307; Fri, 15 Apr 2022 17:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069358; cv=none; d=google.com; s=arc-20160816; b=OW40zVyIlhS5eS6/rttgudS2XunCMNaaL/ke1XuyOLurZZBHikVCQnFlLmUg87xGe1 2iqERo+emz/0BcKC0WTLwC45bKNT9ylDSRS5DDF2lc+HxlvHh27Y/F2LW5NU58/sXRGM Q0Ifj2M9GZjgPfNJCsivmL2JlVRyqzYHSuuRFvGDsOyses74Vx9fxDwn+rpDTeZBFxpD AF/Gl7F57HJ0HussTuw+QOUqGm6fFu01xlOG34e1IrAmyqvicLsB2BtFDRfsqMe823WR H0eRyYpMd4PPDT8HzZyEhNgs+JTiE1/EnR2qpgYo3pipxUoV8sWuwsM5m+jny/Lu7iRg EV9g== 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=JCi5qxQYn+gPdrlxquPk+DTTOLGrCxiogm1zo86HhqQ=; b=A5BWh2Xm8/izMZQumFbnmTvaNegnBevJTq/nwNQEe1NK2+v5uOvWJltwtr1y2ER0P1 TzJ2A+PO1baqXIIXWITKGMXdUbgMmuJhwmmNm0oRnaXkTDyktT23tWTktp4LJVKEZLvs HKw+tKuDO34ronHVq0RsPnz4dSze93N8+ooBNaLl2vVAZ6R/R9S2nSaFZvqtISKH+sus BtG26OQiwdbFhNlJrjLQ/tJ5KjI0hOGSXAhTEvus/U7MfU3xHTrSDYoVSg8l1KqBlGFT 8W0pBlmn78+xFXVYOoR7u08mz9T1yZUczZ2Ad6BiFc8U0Y8rdF5fnojnW6EsIclwvph/ 3H9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i3QiKrS6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id g3-20020a655943000000b003816043f141si2730403pgu.822.2022.04.15.17.35.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:35:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i3QiKrS6; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 2D13AEEA46; Fri, 15 Apr 2022 17:31:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242379AbiDNK4E (ORCPT + 99 others); Thu, 14 Apr 2022 06:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiDNKzz (ORCPT ); Thu, 14 Apr 2022 06:55: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 ESMTP id 824C2506FC for ; Thu, 14 Apr 2022 03:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649933610; 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=JCi5qxQYn+gPdrlxquPk+DTTOLGrCxiogm1zo86HhqQ=; b=i3QiKrS64zLLMa1EZzvA+X/zo9TnlXp/Oa9i8ZKMDqRCiR7b3U7hrxH7P8gWffROtnkAuW a5oiZIXhfy1eKSRF7FDT6PfjS28X2l2tPRUseLcFE1qVGYfamqr/qu2W0Fips/Pw5qDKdT rej/DQEsQIPDIFziFcOdBu/HBWVnyys= 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-527-wMJpGBruOquLJvF_KQiL9Q-1; Thu, 14 Apr 2022 06:53:27 -0400 X-MC-Unique: wMJpGBruOquLJvF_KQiL9Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C1A8680005D; Thu, 14 Apr 2022 10:53:26 +0000 (UTC) Received: from thuth.com (dhcp-192-232.str.redhat.com [10.33.192.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F631C27D9A; Thu, 14 Apr 2022 10:53:25 +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 Subject: [PATCH 1/4] KVM: s390: selftests: Use TAP interface in the memop test Date: Thu, 14 Apr 2022 12:53:19 +0200 Message-Id: <20220414105322.577439-2-thuth@redhat.com> In-Reply-To: <20220414105322.577439-1-thuth@redhat.com> References: <20220414105322.577439-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.8 X-Spam-Status: No, score=-2.0 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=no 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..a2783d9afcac 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); + bool needs_extension; +} testlist[] = { + { + .name = "simple copy", + .test = test_copy, + .needs_extension = false, + }, + { + .name = "copy with storage keys", + .test = test_copy_key, + .needs_extension = true, + }, + { + .name = "copy with key storage protection override", + .test = test_copy_key_storage_prot_override, + .needs_extension = true, + }, + { + .name = "copy with key fetch protection", + .test = test_copy_key_fetch_prot, + .needs_extension = true, + }, + { + .name = "copy with key fetch protection override", + .test = test_copy_key_fetch_prot_override, + .needs_extension = true, + }, + { + .name = "error checks with key", + .test = test_errors_key, + .needs_extension = true, + }, + { + .name = "error checks with key storage protection override", + .test = test_errors_key_storage_prot_override, + .needs_extension = true, + }, + { + .name = "error checks without key fetch prot override", + .test = test_errors_key_fetch_prot_override_not_enabled, + .needs_extension = true, + }, + { + .name = "error checks with key fetch prot override", + .test = test_errors_key_fetch_prot_override_enabled, + .needs_extension = true, + }, + { + .name = "generic error checks", + .test = test_errors, + .needs_extension = false, + }, +}; + 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].needs_extension || extension_cap) { + testlist[idx].test(); + ksft_test_result_pass("%s\n", testlist[idx].name); + } else { + ksft_test_result_skip("%s - storage key memop not supported\n", + testlist[idx].name); + } } - test_errors(); - return 0; + ksft_finished(); } -- 2.27.0