Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5918620ybf; Thu, 5 Mar 2020 09:27:26 -0800 (PST) X-Google-Smtp-Source: ADFU+vvZM37bWQiiU/EPb1DPJVpEgAjHzfozOih04iRp5SsCOLggRQCAZe1UTJ/m300D49spuK5v X-Received: by 2002:aca:4b47:: with SMTP id y68mr124525oia.38.1583429246508; Thu, 05 Mar 2020 09:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583429246; cv=none; d=google.com; s=arc-20160816; b=rqDZSTHPu5rNdVx4zLCuZNv7fax+Ms9MwcxVmCbohTbsMJWFi+PE853j+7DfxaCaE3 vRrGUmaUaMW3YfV0jIZoUqPMUtb61dXRLI5zWrSwZmuy66C/670bXXsN1sc+tty14J2Q LEbb6dVjVhaWj+wB4PYkmF0dNLftgF4NPmCR9aLxW/V2vfvugj8NXApPTBP0zNlR4nJs B2K6Ilv3688lxyYo+C1apzaP83xnPB1AEwcL88pCV/TF4ytKqtgmx3Qh3fJKfWAiq/Nm vGRLt6+5C+XjX4Py2GdRb5GowTzvrnWVRU1i/ktsX7C0V+eWGFwrUBkR5rWwJamRz2aT 69WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=jKNSxLmMS1+TC7wrcKR5f9MZfVifwBf0zoemzoIpDZ4=; b=xkZcXkU64Gq1PvrDwPAQzkYrrxyyZmjnULIPMghfqDp0n/5uWf3Jt3DyM5AnVwJZUN Vcvk6CY8h25kkJAyyVZzWa8GpDTjqxfzoPLGLhPFS08HmZqDf4nIKIqHgd7GZmLSsfOd wIqaz4u+E2HiwEr92usJDjfPHbStoYbvRqPFcwXnuXw+LjVQWbuiVcc7/P87jfTy6gkS hRVtw074vqQLu1SI0TqeuF7e3sC0colGVVPJ4xsCJZWI0wV8xSMCWIB1JgiXsMqaOyKT XUj+BP8yGW4ao1G3zpomZarUL/6ePKWkTO+RJp866RK+O21w2O2x7x2yWY/f+X34OvnP +OTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PrjNqRBG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c80si3816955oib.276.2020.03.05.09.27.14; Thu, 05 Mar 2020 09:27:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PrjNqRBG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727312AbgCERZ5 (ORCPT + 99 others); Thu, 5 Mar 2020 12:25:57 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:32513 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725938AbgCERZ4 (ORCPT ); Thu, 5 Mar 2020 12:25:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583429155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=jKNSxLmMS1+TC7wrcKR5f9MZfVifwBf0zoemzoIpDZ4=; b=PrjNqRBGvDEhAGNdNKzpSgOomWNjMjaWDBIPCKhTsxChhU70FTjnIe74Zbe2ABbeF/79Nm qQ7xIjR+Qv60DncTLu0atJh6cNrNC+xfiFMs2p4K6QBiuKjCOYYaqzKK4bQ+0lPLfSPfwM l2DAQfvCy0u2vAbHv0jWiT67ldGn76c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-3ZC_uy4VOi-n-Fq54ncYwQ-1; Thu, 05 Mar 2020 12:25:54 -0500 X-MC-Unique: 3ZC_uy4VOi-n-Fq54ncYwQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D0F8800D50; Thu, 5 Mar 2020 17:25:50 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-124.gru2.redhat.com [10.97.116.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98B505C290; Thu, 5 Mar 2020 17:25:46 +0000 (UTC) From: Wainer dos Santos Moschetta To: kvm@vger.kernel.org, pbonzini@redhat.com Cc: shuah@kernel.org, tglx@linutronix.de, thuth@redhat.com, sean.j.christopherson@intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/1] kvm: selftests: Add TEST_FAIL macro Date: Thu, 5 Mar 2020 14:25:32 -0300 Message-Id: <20200305172532.9360-2-wainersm@redhat.com> In-Reply-To: <20200305172532.9360-1-wainersm@redhat.com> References: <20200305172532.9360-1-wainersm@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some tests/utilities use the TEST_ASSERT(false, ...) pattern to indicate a failure and stop execution. This change introduces the TEST_FAIL macro which is a wrap around TEST_ASSERT(false, ...) and so provides a direct alternative for failing a test. Signed-off-by: Wainer dos Santos Moschetta --- tools/testing/selftests/kvm/dirty_log_test.c | 7 +++---- tools/testing/selftests/kvm/include/test_util.h | 3 +++ tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm/dirty_log_test.c index 5614222a6628..137c1cfec2cc 100644 --- a/tools/testing/selftests/kvm/dirty_log_test.c +++ b/tools/testing/selftests/kvm/dirty_log_test.c @@ -166,10 +166,9 @@ static void *vcpu_worker(void *data) pages_count += TEST_PAGES_PER_LOOP; generate_random_array(guest_array, TEST_PAGES_PER_LOOP); } else { - TEST_ASSERT(false, - "Invalid guest sync status: " - "exit_reason=%s\n", - exit_reason_str(run->exit_reason)); + TEST_FAIL("Invalid guest sync status: " + "exit_reason=%s\n", + exit_reason_str(run->exit_reason)); } } diff --git a/tools/testing/selftests/kvm/include/test_util.h b/tools/testing/selftests/kvm/include/test_util.h index a41db6fb7e24..336b16500b0f 100644 --- a/tools/testing/selftests/kvm/include/test_util.h +++ b/tools/testing/selftests/kvm/include/test_util.h @@ -39,4 +39,7 @@ void test_assert(bool exp, const char *exp_str, #a, #b, #a, (unsigned long) __a, #b, (unsigned long) __b); \ } while (0) +#define TEST_FAIL(fmt, ...) \ + TEST_ASSERT(false, fmt, ##__VA_ARGS__) + #endif /* SELFTEST_KVM_TEST_UTIL_H */ diff --git a/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c b/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c index 63cc9c3f5ab6..501d6217b9ed 100644 --- a/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c +++ b/tools/testing/selftests/kvm/x86_64/cr4_cpuid_sync_test.c @@ -101,12 +101,12 @@ int main(int argc, char *argv[]) vcpu_sregs_set(vm, VCPU_ID, &sregs); break; case UCALL_ABORT: - TEST_ASSERT(false, "Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit."); + TEST_FAIL("Guest CR4 bit (OSXSAVE) unsynchronized with CPUID bit."); break; case UCALL_DONE: goto done; default: - TEST_ASSERT(false, "Unknown ucall 0x%x.", uc.cmd); + TEST_FAIL("Unknown ucall 0x%x.", uc.cmd); } } -- 2.17.2