From patchwork Wed Dec 18 23:24:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cleber Rosa X-Patchwork-Id: 11302427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B81414F6 for ; Wed, 18 Dec 2019 23:26:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F331021582 for ; Wed, 18 Dec 2019 23:26:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NrAQ9F8a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F331021582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:33844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihiiE-0000ZG-A0 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 18 Dec 2019 18:26:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34945) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihih1-0007CZ-Ji for qemu-devel@nongnu.org; Wed, 18 Dec 2019 18:25:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihigy-0003Ze-Mv for qemu-devel@nongnu.org; Wed, 18 Dec 2019 18:25:21 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:55594 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihigy-0003Z2-Iy for qemu-devel@nongnu.org; Wed, 18 Dec 2019 18:25:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576711519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xsIGFqbdWELPUdKkJ0RdM0GqpnaKBuEs67bNMNVth7Y=; b=NrAQ9F8arLofPigyAAm6P5G1zzZGxMRBja/ypeU0nwv+BYykbydOO/wEspNfZpEVbB8gOL D3O5evUwY2mdIZsOt7c+FyUYEmSI6oGbR162h9t+5bDOStw/DS9oQ3Dac2ln9pkuljQzbo z9xYTVLQHCpvG3pXOcxQgoH/upPtYac= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-37-7s0LT2qfONuSDzlk4m4zmw-1; Wed, 18 Dec 2019 18:25:16 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 29AB0107ACE6; Wed, 18 Dec 2019 23:25:15 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E29E61036D00; Wed, 18 Dec 2019 23:25:12 +0000 (UTC) From: Cleber Rosa To: qemu-devel@nongnu.org Subject: [PATCH v8 1/4] Acceptance tests: introduce BLD_DIR, SRC_DIR and LNK_DIR Date: Wed, 18 Dec 2019 18:24:57 -0500 Message-Id: <20191218232500.23530-2-crosa@redhat.com> In-Reply-To: <20191218232500.23530-1-crosa@redhat.com> References: <20191218232500.23530-1-crosa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: 7s0LT2qfONuSDzlk4m4zmw-1 X-Mimecast-Spam-Score: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Willian Rampazzo , Cleber Rosa , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Some tests may benefit from using resources from a build directory. This introduces three variables that can help tests find resources in those directories. First, a BLD_DIR is assumed to exist, given that the primary form of running the acceptance tests is from a build directory (which may or may not be the same as the source tree, that is, the SRC_DIR). If the directory containing the acceptance tests happens to be a link to a directory (kept as LNK_DIR), it's assumed to it points to the source tree (SRC_DIR), which is the behavior defined on the QEMU Makefiles. If the directory containing the acceptance tests is not a link, then a in-tree build is assumed, and the BLD_DIR and SRC_DIR are the same and LNK_DIR is set None. Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 6618ea67c1..ac7597f7fe 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -16,8 +16,23 @@ import tempfile import avocado -SRC_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..', '..', '..') -sys.path.append(os.path.join(SRC_ROOT_DIR, 'python')) +#: The QEMU build root directory. It may also be the source directory +#: if building from the source dir, but it's safer to use BLD_DIR for +#: that purpose. Be aware that if this code is moved outside of a source +#: and build tree, it will not be accurate. +BLD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) + +if os.path.islink(os.path.dirname(os.path.dirname(__file__))): + #: The link to the acceptance tests dir in the source code directory. If + #: build dir is the same as the source dir, this is set to None + LNK_DIR = os.path.dirname(os.path.dirname(__file__)) + #: The QEMU root source directory + SRC_DIR = os.path.dirname(os.path.dirname(os.readlink(LNK_DIR))) +else: + LNK_DIR = None + SRC_DIR = BLD_DIR + +sys.path.append(os.path.join(SRC_DIR, 'python')) from qemu.machine import QEMUMachine @@ -49,10 +64,10 @@ def pick_default_qemu_bin(arch=None): if is_readable_executable_file(qemu_bin_relative_path): return qemu_bin_relative_path - qemu_bin_from_src_dir_path = os.path.join(SRC_ROOT_DIR, + qemu_bin_from_bld_dir_path = os.path.join(BLD_DIR, qemu_bin_relative_path) - if is_readable_executable_file(qemu_bin_from_src_dir_path): - return qemu_bin_from_src_dir_path + if is_readable_executable_file(qemu_bin_from_bld_dir_path): + return qemu_bin_from_bld_dir_path def wait_for_console_pattern(test, success_message, failure_message=None): @@ -122,7 +137,7 @@ class Test(avocado.Test): self.qemu_bin = self.params.get('qemu_bin', default=default_qemu_bin) if self.qemu_bin is None: - self.cancel("No QEMU binary defined or found in the source tree") + self.cancel("No QEMU binary defined or found in the build tree") def _new_vm(self, *args): vm = QEMUMachine(self.qemu_bin, sock_dir=tempfile.mkdtemp())