From patchwork Mon Jul 15 19:21:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasu Dasari X-Patchwork-Id: 1132221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="iiMY2HNL"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45nYLl3Qppz9sDQ for ; Tue, 16 Jul 2019 05:22:06 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 26E3EF09; Mon, 15 Jul 2019 19:22:05 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 8C464EF9 for ; Mon, 15 Jul 2019 19:22:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4D337879 for ; Mon, 15 Jul 2019 19:22:02 +0000 (UTC) Received: by mail-qt1-f194.google.com with SMTP id k10so16920339qtq.1 for ; Mon, 15 Jul 2019 12:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JNsJm94QBD+dW7RZ+2Z80tWej5l4eiD1/GMVGZ23qhg=; b=iiMY2HNL4/PmA8ZfMNq498yvXj4piu4nL8aDN4bX57CZ9AJjqtQyc1dq9TX5hwJNJp xoxm4DpsV07jYmoYGC+T+25bpoAZ9cAxxSEhFtlfl5rYtfbPjku0Pr5S0GeXstlKbDMT v2Nm0c18e0J2UOaf/GP81PRgsEQJpAlyGXglppR3ZncxWnJiFbhw0jlrjh8/UcZKrm8U 7Fv05Ga86pkinHK5iFolePuXz9nPdxcPL+uOd+Txyv5N0lmANvH/SDRVd6fn6vba+eS3 yDwwdkyyvTP/XSVwY/B3Iczms56y2MG6tXsUyg+ZUT93hfw5qIh/Fdn9rraCLpAYDhyB xQcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JNsJm94QBD+dW7RZ+2Z80tWej5l4eiD1/GMVGZ23qhg=; b=sZJduHz3+ILAZcm6TheSXBlrONw0BdQEzeuc7/QjbwS3t2hihiu+Yb4zM/2LLU0ZEq mgijlzZDUG26pobhGQD3HumMEDw19NRSCar9n2KvCoup+pEHfwvifcBcj3ARxV9Oh++t 8Cttk7xBr/MbWu85c5cJRdhcEKf3cTELtrj8PaiwlTQ7SZ0XH1H2ocdOfNtqocU6QSui sZtoSuilp3pX/3Dng9/X7eKjrXRt6fsJExOSt7H4DygcQRd/1P0clfxPCemZZfdFggIA X9Ugrg2vopIqI2KJrB7SBog1YoXzQ0smeQ2/2OwYrLAHSNlk+pw9qu18u8tySs+g6BNE xE8A== X-Gm-Message-State: APjAAAXd0WywvZ0fJN4mkmEKR4eQ+husen1NDAQaqZ4Bw2ZE0sSPMUeP 3zvuR+eHO/gHrEv081FTJz2qiSW50bk= X-Google-Smtp-Source: APXvYqxvdHsSAYO4cnpTIofTNhhTTvInOfrvqH/ficFdw4ZVte61QgbYBOlIoFpHQ0Ee/hs7dGLUWg== X-Received: by 2002:a0c:b786:: with SMTP id l6mr20480323qve.148.1563218520937; Mon, 15 Jul 2019 12:22:00 -0700 (PDT) Received: from localhost.localdomain ([73.61.23.95]) by smtp.gmail.com with ESMTPSA id k38sm10741032qtk.10.2019.07.15.12.21.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jul 2019 12:22:00 -0700 (PDT) From: Vasu Dasari To: dev@openvswitch.org Date: Mon, 15 Jul 2019 15:21:50 -0400 Message-Id: <20190715192150.82648-1-vdasari@gmail.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovs-macros: An option to suspend test execution on error X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 ctrl-d 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' Signed-off-by: Vasu Dasari Reviewed-by: Ben Pfaff --- v0 -> v1: Discussion at: https://mail.openvswitch.org/pipermail/ovs-dev/2019-July/360589.html 1. Incorporated review commanets from Ben. 2. Changed topics/testing.rst to document this trick 3. Made this trick work via "make check" as well, by issuing command: "OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v'" --- Documentation/topics/testing.rst | 6 ++++++ tests/ovs-macros.at | 24 +++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/topics/testing.rst b/Documentation/topics/testing.rst index a8892e1c1..058b3986f 100644 --- a/Documentation/topics/testing.rst +++ b/Documentation/topics/testing.rst @@ -74,6 +74,12 @@ To run tests matching a keyword, e.g. ``ovsdb``, run:: $ make check TESTSUITEFLAGS='-k ovsdb' +To pause at a failing test (e.g. ``ovsdb``) and inspect the system in failed +state, follow the instructions given out by issuing following command to use +various ovs-* utilities:: + + $ OVS_PAUSE_TEST=1 make check TESTSUITEFLAGS='-v -k ovsdb' + To see a complete list of test options, run:: $ make check TESTSUITEFLAGS=--help diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 10593429d..e58b0a1a0 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() { + $as_echo "=====================================================" + $as_echo "Set following environment variable to use various ovs utilities" + $as_echo "export OVS_RUNDIR=$ovs_base" + $as_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.