From patchwork Tue Jan 19 13:24:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 8062011 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7523ABEEE5 for ; Tue, 19 Jan 2016 13:25:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 956FB20364 for ; Tue, 19 Jan 2016 13:25:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC4F52010B for ; Tue, 19 Jan 2016 13:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932158AbcASNZC (ORCPT ); Tue, 19 Jan 2016 08:25:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55387 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754807AbcASNYx (ORCPT ); Tue, 19 Jan 2016 08:24:53 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id AC754471 for ; Tue, 19 Jan 2016 13:24:53 +0000 (UTC) Received: from potion ([10.34.1.163]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u0JDOolH031937; Tue, 19 Jan 2016 08:24:51 -0500 Received: by potion (sSMTP sendmail emulation); Tue, 19 Jan 2016 14:24:50 +0100 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: kvm@vger.kernel.org Cc: Paolo Bonzini , Andrew Jones Subject: [PATCH kvm-unit-tests 10/12] scripts/mkstandalone: simplifiy redirection, again Date: Tue, 19 Jan 2016 14:24:09 +0100 Message-Id: <1453209851-27760-11-git-send-email-rkrcmar@redhat.com> In-Reply-To: <1453209851-27760-1-git-send-email-rkrcmar@redhat.com> References: <1453209851-27760-1-git-send-email-rkrcmar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We don't have variables all over the place now, so it's nicer to move script generator into a separate function and redirect its output. Signed-off-by: Radim Kr?má? --- scripts/mkstandalone.sh | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh index d9cfded36d5e..6ced8e5970ef 100755 --- a/scripts/mkstandalone.sh +++ b/scripts/mkstandalone.sh @@ -42,24 +42,10 @@ temp_file () echo "chmod +x \$$var" } -function mkstandalone() +generate_test () { - local testname="$1" local args=( $(escape "${@}") ) - if [ -z "$testname" ]; then - return 1 - fi - - if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then - return 1 - fi - - standalone=tests/$testname - - exec {tmpfd}<&1 - exec > $standalone - echo "#!/bin/bash" cat config.mak | grep '^ARCH=' @@ -67,8 +53,8 @@ function mkstandalone() if [ ! -f $kernel ]; then echo 'echo "skip '"$testname"' (test kernel not present)"' echo 'exit 1' - else - # XXX: bad indentation + return 1 + fi echo "trap 'rm -f \$cleanup' EXIT" @@ -81,9 +67,24 @@ function mkstandalone() echo "run ${args[@]}" echo "exit 0" +} + +function mkstandalone() +{ + local testname="$1" + + if [ -z "$testname" ]; then + return 1 fi - exec 1<&$tmpfd {tmpfd}<&- + if [ -n "$one_testname" ] && [ "$testname" != "$one_testname" ]; then + return 1 + fi + + standalone=tests/$testname + + generate_test "$@" > $standalone + chmod +x $standalone return 0