From patchwork Fri Oct 23 10:20:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1386642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ilfUIInl; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHgHx4KGZz9sSs for ; Fri, 23 Oct 2020 21:21:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 607E420534; Fri, 23 Oct 2020 10:21:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zZSIJm6WKW6A; Fri, 23 Oct 2020 10:21:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 6FFA1203BD; Fri, 23 Oct 2020 10:21:28 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4C10DC0893; Fri, 23 Oct 2020 10:21:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id EA1E5C0052 for ; Fri, 23 Oct 2020 10:21:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id C511D203BF for ; Fri, 23 Oct 2020 10:21:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2xxWbs7SjDTc for ; Fri, 23 Oct 2020 10:21:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by silver.osuosl.org (Postfix) with ESMTPS id D6468203BD for ; Fri, 23 Oct 2020 10:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603448483; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type; bh=ZTrzsrEbaJS1Yh77YBU3DOqGd9sfSj5ddjfVuVvb4Ko=; b=ilfUIInlzi7jZrQ/yjBSXqECcJDkH170gqWljYsEai62/J0O9+5hRW9RtX+LhqTrnwkpQt T+3e4gf+vyqbcI8vs6kKhgvl28HWkESqPlasvNCkHhXMdCBvv/FqoqB5v+XlaYdev6tRiL QbB3VHrgy8ngk/SAH+T2qcg4FSCSvKI= 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-499-Q0hLnjbzMUqr92EZqMeWvA-1; Fri, 23 Oct 2020 06:21:20 -0400 X-MC-Unique: Q0hLnjbzMUqr92EZqMeWvA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 986E780733D; Fri, 23 Oct 2020 10:21:19 +0000 (UTC) Received: from dceara.remote.csb (ovpn-114-84.ams2.redhat.com [10.36.114.84]) by smtp.corp.redhat.com (Postfix) with ESMTP id CCAFE60BFA; Fri, 23 Oct 2020 10:21:18 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Fri, 23 Oct 2020 12:20:55 +0200 Message-Id: <1603448455-22787-1-git-send-email-dceara@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2] ovs-macros: Port OVS_PAUSE_TEST support from OpenvSwitch. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Vasu Dasari Upstream OVS commit: commit c99d14775f78cb38b2109add063f58201ba07652 Author: Vasu Dasari Date: Mon Jul 15 17:15:01 2019 -0400 ovs-macros: An option to suspend test execution on error Origins for this patch are captured at https://mail.openvswitch.org/pipermail/ovs-discuss/2019-June/048923.html. Summarizing here, when a test fails, it would be good to pause test execution and let the developer poke around the system to see current status of system. As part of this patch, made a small tweaks to ovs-macros.at, so that when test suite fails, ovs_on_exit() function will be called. And in this function, a check is made to see if an environment variable to OVS_PAUSE_TEST is set. If it is set, then test suite is paused and will continue to wait for user input Ctrl-D. Meanwhile user can poke around the system to see why test case has failed. Once done with investigation, user can press ctrl-d to cleanup the test suite. For example, to re-run test case 139: export OVS_PAUSE_TEST=1 cd tests/system-userspace-testsuite.dir/139 sudo -E ./run When error occurs, above command would display something like this: ===================================================== Set environment variable to use various ovs utilities export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139 Press ENTER to continue: ===================================================== And from another window, one can execute ovs-xxx commands like: export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/system-userspace-testsuite.dir/139 $ ovs-ofctl dump-ports br0 . . To be able to pause while performing `make check`, one can do: $ OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v' Acked-by: Aaron Conole Signed-off-by: Vasu Dasari Signed-off-by: Ben Pfaff Signed-off-by: Dumitru Ceara Acked-by: Mark Gray --- Documentation/topics/testing.rst | 24 ++++++++++++++++++++++++ tests/ovs-macros.at | 24 +++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Documentation/topics/testing.rst b/Documentation/topics/testing.rst index 242608a..e07cdf8 100644 --- a/Documentation/topics/testing.rst +++ b/Documentation/topics/testing.rst @@ -89,6 +89,30 @@ report test failures as bugs and include the ``testsuite.log`` in your report. $ make check TESTSUITEFLAGS=-j8 RECHECK=yes +Debugging unit tests +++++++++++++++++++++ + +To initiate debugging from artifacts generated from `make check` run, set the +``OVS_PAUSE_TEST`` environment variable to 1. For example, to run test case +139 and pause on error:: + + $ OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v 139' + +When error occurs, above command would display something like this:: + + Set environment variable to use various ovs utilities + export OVS_RUNDIR=/ovs/_build-gcc/tests/testsuite.dir/0139 + Press ENTER to continue: + +And from another window, one can execute ovs-xxx commands like:: + + export OVS_RUNDIR=/opt/vdasari/Developer/ovs/_build-gcc/tests/testsuite.dir/0139 + $ ovs-ofctl dump-ports br0 + . + . + +Once done with investigation, press ENTER to perform cleanup operation. + .. _testing-coverage: Coverage diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 3dcf8f9..2370cd2 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -35,11 +35,33 @@ m4_divert_push([PREPARE_TESTS]) # directory. ovs_init() { ovs_base=`pwd` - trap '. "$ovs_base/cleanup"' 0 + trap ovs_on_exit 0 : > cleanup ovs_setenv } +# Catch testsuite error condition and cleanup test environment by tearing down +# all interfaces and processes spawned. +# User has an option to leave the test environment in error state so that system +# can be poked around to get more information. User can enable this option by setting +# environment variable OVS_PAUSE_TEST=1. User needs to press CTRL-D to resume the +# cleanup operation. +ovs_pause() { + echo "=====================================================" + echo "Set following environment variable to use various ovs utilities" + echo "export OVS_RUNDIR=$ovs_base" + echo "Press ENTER to continue: " + read +} + +ovs_on_exit () { + if [ ! -z "${OVS_PAUSE_TEST}" ] && [ -z $at_verbose ]; then + trap '' INT + ovs_pause + fi + . "$ovs_base/cleanup" +} + # With no parameter or an empty parameter, sets the OVS_*DIR # environment variables to point to $ovs_base, the base directory in # which the test is running.