From patchwork Fri Nov 9 22:12:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cleber Rosa X-Patchwork-Id: 10676631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07540139B for ; Fri, 9 Nov 2018 22:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDB882F1A5 for ; Fri, 9 Nov 2018 22:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E20DA2F320; Fri, 9 Nov 2018 22:14:18 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A3632F1A5 for ; Fri, 9 Nov 2018 22:14:18 +0000 (UTC) Received: from localhost ([::1]:36278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLF2f-0000Og-PK for patchwork-qemu-devel@patchwork.kernel.org; Fri, 09 Nov 2018 17:14:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45375) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLF1L-0006xE-1k for qemu-devel@nongnu.org; Fri, 09 Nov 2018 17:12:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLF1F-00056s-5p for qemu-devel@nongnu.org; Fri, 09 Nov 2018 17:12:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22740) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gLF0x-0004Sq-1W; Fri, 09 Nov 2018 17:12:33 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7040530820C0; Fri, 9 Nov 2018 22:12:23 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-124-135.rdu2.redhat.com [10.10.124.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAE7C5D6B3; Fri, 9 Nov 2018 22:12:21 +0000 (UTC) From: Cleber Rosa To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Fri, 9 Nov 2018 17:12:12 -0500 Message-Id: <20181109221213.7310-2-crosa@redhat.com> In-Reply-To: <20181109221213.7310-1-crosa@redhat.com> References: <20181109221213.7310-1-crosa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 09 Nov 2018 22:12:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH 1/2] Acceptance Tests: add QemuImgTest base class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Eduardo Habkost , Cleber Rosa , Wainer dos Santos Moschetta , Max Reitz , Caio Carrara , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Testing other utilities such as qemu-img do not require the same infrastructure that testing QEMU itself does. Let's add a base class that just sets the suitable qemu-img binary to be used during test. Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 1e54fd5932..dfd147b7e2 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -40,6 +40,20 @@ def pick_default_qemu_bin(): return qemu_bin_from_src_dir_path +def pick_default_qemu_img_bin(): + """ + Picks the path of a QEMU binary, starting either in the current working + directory or in the source tree root directory. + """ + qemu_img_bin_local = os.path.abspath("qemu-img") + if is_readable_executable_file(qemu_img_bin_local): + return qemu_img_bin_local + + qemu_img_bin_from_src_dir_path = os.path.join(SRC_ROOT_DIR, "qemu-img") + if is_readable_executable_file(qemu_img_bin_from_src_dir_path): + return qemu_img_bin_from_src_dir_path + + class Test(avocado.Test): def setUp(self): self.vm = None @@ -52,3 +66,9 @@ class Test(avocado.Test): def tearDown(self): if self.vm is not None: self.vm.shutdown() + + +class QemuImgTest(avocado.Test): + def setUp(self): + self.qemu_img_bin = self.params.get('qemu_img_bin', + default=pick_default_qemu_img_bin())