From patchwork Wed Jun 28 20:08:55 2017 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: 9815315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E05760365 for ; Wed, 28 Jun 2017 20:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80D24284EA for ; Wed, 28 Jun 2017 20:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75A8628517; Wed, 28 Jun 2017 20:09:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D47A284EA for ; Wed, 28 Jun 2017 20:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751804AbdF1UJX (ORCPT ); Wed, 28 Jun 2017 16:09:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787AbdF1UJU (ORCPT ); Wed, 28 Jun 2017 16:09:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 124E8FD09 for ; Wed, 28 Jun 2017 20:09:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 124E8FD09 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=rkrcmar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 124E8FD09 Received: from potion (unknown [10.43.2.65]) by smtp.corp.redhat.com (Postfix) with SMTP id A0C011825A; Wed, 28 Jun 2017 20:09:17 +0000 (UTC) Received: by potion (sSMTP sendmail emulation); Wed, 28 Jun 2017 22:09:16 +0200 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: kvm@vger.kernel.org Cc: Paolo Bonzini , Drew Jones , Laurent Vivier , Thomas Huth , David Hildenbrand Subject: [kvm-unit-tests PATCH 3/5] s390+powerpc/run: improve output handling Date: Wed, 28 Jun 2017 22:08:55 +0200 Message-Id: <20170628200857.1718-4-rkrcmar@redhat.com> In-Reply-To: <20170628200857.1718-1-rkrcmar@redhat.com> References: <20170628200857.1718-1-rkrcmar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 28 Jun 2017 20:09:20 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the test is hanging, then using arch/run would produce no output, because of caching in a temporary variable. Use the `tee` trick to save the output while passing it through. They were also using the very same code. Signed-off-by: Radim Krčmář --- powerpc/run | 15 +-------------- s390x/run | 15 +-------------- scripts/arch-run.bash | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/powerpc/run b/powerpc/run index 3fd5a91aeffb..3f69386c642a 100755 --- a/powerpc/run +++ b/powerpc/run @@ -46,17 +46,4 @@ command="$(migration_cmd) $(timeout_cmd) $command" # to fixup the fixup below by parsing the true exit code from the output. # The second fixup is also a FIXME, because once we add chr-testdev # support for powerpc, we won't need the second fixup. -lines=$(run_qemu $command "$@") -ret=$? -echo "$lines" -if [ $ret -eq 1 ]; then - testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') - if [ "$testret" ]; then - if [ $testret -eq 1 ]; then - ret=0 - else - ret=$testret - fi - fi -fi -exit $ret +run_qemu_status $command "$@" diff --git a/s390x/run b/s390x/run index 89210f4fb6b6..6df348a93783 100755 --- a/s390x/run +++ b/s390x/run @@ -38,17 +38,4 @@ command+=" -kernel" command="$(timeout_cmd) $command" # We return the exit code via stdout, not via the QEMU return code -lines=$(run_qemu $command "$@") -ret=$? -echo "$lines" -if [ $ret -eq 1 ]; then - testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') - if [ "$testret" ]; then - if [ $testret -eq 1 ]; then - ret=0 - else - ret=$testret - fi - fi -fi -exit $ret +run_qemu_status $command "$@" diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 8ad37e4ebf97..6e429a8748f4 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -69,6 +69,29 @@ run_qemu () return $ret } +run_qemu_status () +{ + local stdout ret + + exec {stdout}>&1 + lines=$(run_qemu "$@" > >(tee /dev/fd/$stdout)) + ret=$? + exec {stdout}>&- + + if [ $ret -eq 1 ]; then + testret=$(grep '^EXIT: ' <<<"$lines" | sed 's/.*STATUS=\([0-9][0-9]*\).*/\1/') + if [ "$testret" ]; then + if [ $testret -eq 1 ]; then + ret=0 + else + ret=$testret + fi + fi + fi + + return $ret +} + timeout_cmd () { if [ "$TIMEOUT" ] && [ "$TIMEOUT" != "0" ]; then