From nobody Fri Nov 14 03:51:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1584490891; cv=none; d=zohomail.com; s=zohoarc; b=L/koImhGKEzJUNghG9BVYKkyunkMIWUJB6z92nWjG7nyUmU+tWEvIOZMfphXrvdA+AOTrK8FzrLJUbTjMB3iyvinpm15rKO4zzdRKVLY5TnMhOPx2lgYIjRYIcxvQNXcg25T9rKt/hT/yW8Yj1xwrmyc3iJ7LZEi7F3EiyS+luM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584490891; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bj5Qs3g5aOxqwH63FL3Y0rfKKyCVCNqczX8nCRdvjLc=; b=Shu6xUNxp8O7FADggS77TBskEoUZ8hgz9gUfl8zrmSSbWHvD4R3NJ0/xwWgH77S9DKiZ1Ea7Ro8OCQ+xNwu9Sr6rdSU3yLdqPOQpDnagceOlGrtK8e1kAw+wGlOSgczXpbKREG3tWLxQG/dTMy3rJQBxNt4FCbXCSJ3bzOFabkk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584490891515290.75815497273345; Tue, 17 Mar 2020 17:21:31 -0700 (PDT) Received: from localhost ([::1]:43584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEMSg-0005mm-7o for importer@patchew.org; Tue, 17 Mar 2020 20:21:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45279) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jEMR6-00048t-N8 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 20:19:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jEMR5-0007BX-Dq for qemu-devel@nongnu.org; Tue, 17 Mar 2020 20:19:52 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:57540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jEMR5-00076h-86 for qemu-devel@nongnu.org; Tue, 17 Mar 2020 20:19:51 -0400 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-252-c0WNrO7COAWHFlDPMhlGQw-1; Tue, 17 Mar 2020 20:19:49 -0400 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 9795D1857BE0; Wed, 18 Mar 2020 00:19:47 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-2.rdu2.redhat.com [10.10.117.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AE7710027A3; Wed, 18 Mar 2020 00:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584490790; 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=bj5Qs3g5aOxqwH63FL3Y0rfKKyCVCNqczX8nCRdvjLc=; b=H8hnP0gwh0iun/fEp/Ngan35steGVGj+RfBFWKoMERydHEmMMc2OAncSLdLLc/ZOilWqW5 sEIvPiPZK5bC+Fb7+d0jw54G9M4UcCSaB/DggHWQ7pVRiuNDxs8NuG4sfgj2kHgCIY6Tn+ 26CMJ1egdf1qtb7wsi1wMEze4YV1NU8= X-MC-Unique: c0WNrO7COAWHFlDPMhlGQw-1 From: Cleber Rosa To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 2/6] Acceptance tests: introduce BUILD_DIR and SOURCE_DIR Date: Tue, 17 Mar 2020 20:19:28 -0400 Message-Id: <20200318001932.180617-3-crosa@redhat.com> In-Reply-To: <20200318001932.180617-1-crosa@redhat.com> References: <20200318001932.180617-1-crosa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 63.128.21.74 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 , Beraldo Leal , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Fabien Chouteau , Willian Rampazzo , KONRAD Frederic , qemu-ppc@nongnu.org, Wainer dos Santos Moschetta , Willian Rampazzo , Cleber Rosa , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 BUILD_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 SOURCE_DIR). If the directory containing the acceptance tests happens to be a link to a directory, it's assumed to it points to the source tree (SOURCE_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 BUILD_DIR and SOURCE_DIR have the same value. Signed-off-by: Cleber Rosa Reviewed-by: Wainer dos Santos Moschetta Tested-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo Tested-by: Willian Rampazzo Message-Id: <20200317141654.29355-2-crosa@redhat.com> Signed-off-by: Cleber Rosa --- tests/acceptance/avocado_qemu/__init__.py | 25 +++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/a= vocado_qemu/__init__.py index d4358eb431..59e7b4f763 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -16,8 +16,21 @@ import tempfile =20 import avocado =20 -SRC_ROOT_DIR =3D 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 BUILD_DIR for +#: that purpose. Be aware that if this code is moved outside of a source +#: and build tree, it will not be accurate. +BUILD_DIR =3D os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirn= ame(__file__)))) + +if os.path.islink(os.path.dirname(os.path.dirname(__file__))): + # The link to the acceptance tests dir in the source code directory + lnk =3D os.path.dirname(os.path.dirname(__file__)) + #: The QEMU root source directory + SOURCE_DIR =3D os.path.dirname(os.path.dirname(os.readlink(lnk))) +else: + SOURCE_DIR =3D BUILD_DIR + +sys.path.append(os.path.join(SOURCE_DIR, 'python')) =20 from qemu.machine import QEMUMachine =20 @@ -49,10 +62,10 @@ def pick_default_qemu_bin(arch=3DNone): if is_readable_executable_file(qemu_bin_relative_path): return qemu_bin_relative_path =20 - qemu_bin_from_src_dir_path =3D os.path.join(SRC_ROOT_DIR, + qemu_bin_from_bld_dir_path =3D os.path.join(BUILD_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 =20 =20 def _console_interaction(test, success_message, failure_message, @@ -153,7 +166,7 @@ class Test(avocado.Test): self.qemu_bin =3D self.params.get('qemu_bin', default=3Ddefault_qemu_bin) if self.qemu_bin is None: - self.cancel("No QEMU binary defined or found in the source tre= e") + self.cancel("No QEMU binary defined or found in the build tree= ") =20 def _new_vm(self, *args): vm =3D QEMUMachine(self.qemu_bin, sock_dir=3Dtempfile.mkdtemp()) --=20 2.25.1