From patchwork Thu Nov 8 04:13:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 994640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42r8z74Ytkz9sBk for ; Thu, 8 Nov 2018 15:13:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="SC89ni6D"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42r8z62cBPzF3LQ for ; Thu, 8 Nov 2018 15:13:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="SC89ni6D"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42r8yz0CfMzF3L9 for ; Thu, 8 Nov 2018 15:13:15 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="SC89ni6D"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42r8yy1Y0Cz9sCQ; Thu, 8 Nov 2018 15:13:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1541650394; bh=dug8UXiNubY7cu81+80hgfj1cUM3wW0LKbKvE/M/ilM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SC89ni6DBsD3oN7JBxQ+1KR4gND5zFllVfsdjFKS9xXPPjiuRyq/TOJ3QQ/M28ccA z2DpTzLo04HxEPSa0ltSBpK69AsfS76I7+sKpH+0f3j+0fD6fkNM5tCx/RwJb//yNh hxndtbS444DtVfkPJDt46TyY/U31J+uv8WlAQmJifM057Sez0z2EPlHx8r82HmCsDJ hZ5j5Jk+sxRl6IBppetKiuyv8WFZlUf6KO5vdIzI4/2OuVHzBRwXrHzXWegn9rxq5W PFeSAeFFq0filNzRaltb6hw+Blova7bpP6YGQntG2VZ68N40j1A44OZixN/45zpGYq 0iKmnicAPf4cA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 8 Nov 2018 15:13:08 +1100 Message-Id: <20181108041311.182694-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108041311.182694-1-amitay@ozlabs.org> References: <20181108041311.182694-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/5] tests: Update driver to pass test_wrapper argument X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- tests/driver.sh | 15 +++++++++++---- tests/test_driver.sh | 10 ++++++++-- tests/test_hw_bmc.sh | 6 ++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/driver.sh b/tests/driver.sh index 6df34b3..9e92135 100644 --- a/tests/driver.sh +++ b/tests/driver.sh @@ -44,8 +44,9 @@ # # test_wrapper # -# To execute commands in a special context, test_wrapper function can be -# defined. This function will be passed all the arguments to test_run +# Register a test wrapper function. If test_wrapper is called without +# an argument, then the test wrapper function is set to default. +# The test wrapper function will be passed all the arguments to test_run # command. # # @@ -222,9 +223,15 @@ test_wrapper_default () "$@" } +test_wrapper_func=test_wrapper_default + test_wrapper () { - test_wrapper_default "$@" + if [ $# -eq 0 ] ; then + test_wrapper_func=test_wrapper_default + else + test_wrapper_func="$1" + fi } result_filter_default () @@ -337,7 +344,7 @@ test_run () stderr_file=$(mktemp) - output_raw=$(test_wrapper "$@" 2>"$stderr_file") + output_raw=$($test_wrapper_func "$@" 2>"$stderr_file") rc=$? if [ $rc -ne $required_rc ] ; then diff --git a/tests/test_driver.sh b/tests/test_driver.sh index 6e8343a..803f69f 100755 --- a/tests/test_driver.sh +++ b/tests/test_driver.sh @@ -52,10 +52,14 @@ echo_stderr () echo "$*" >&2 } +test_wrapper echo_stderr + echo "match stderr" test_result 0 -- test_result_stderr foo -test_run echo_stderr foo +test_run foo + +test_wrapper echo @@ -73,11 +77,13 @@ test_run echo 666 echo -test_wrapper () +prefix_output () { echo "output: $*" } +test_wrapper prefix_output + test_result 0 "output: foobar" test_run foobar diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh index c65a630..c35597b 100755 --- a/tests/test_hw_bmc.sh +++ b/tests/test_hw_bmc.sh @@ -40,7 +40,7 @@ copy_pdbg () ${BMC_USER}@${BMC_HOST}:${PDBG_PATH} } -test_wrapper () +run_over_ssh () { sshpass -p "$BMC_PASS" \ ssh ${BMC_USER}@${BMC_HOST} \ @@ -64,7 +64,7 @@ do_skip () echo -n "Checking if the host is up... " -output=$(test_wrapper /usr/sbin/obmcutil state | grep CurrentHostState) +output=$(run_over_ssh /usr/sbin/obmcutil state | grep CurrentHostState) rc=$? if [ $rc -ne 0 ] || \ [ "$output" = "CurrentHostState : xyz.openbmc_project.State.Host.HostState.Running" ] ; then @@ -75,6 +75,8 @@ else echo "$output" fi +test_wrapper run_over_ssh + result_filter () { sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#' \