From patchwork Mon Mar 15 23:08:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1453612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Y5Xslj8F; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DzsYm14BMz9sRR for ; Tue, 16 Mar 2021 10:09:16 +1100 (AEDT) Received: from localhost ([::1]:40456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLwKo-00016v-6p for incoming@patchwork.ozlabs.org; Mon, 15 Mar 2021 19:09:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLwKQ-00014A-SQ for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:50 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:41676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLwKN-0001vE-II for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:48 -0400 Received: by mail-wm1-x332.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso420171wmi.0 for ; Mon, 15 Mar 2021 16:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7YF3nY7RWwiblpeqYeH6Gr8kBH483IkbOyS8dt/OFw=; b=Y5Xslj8FigNfxfK2NtY+/L1/8mIgEzdkd7LzBgQDoxK8U5zRFgwUG2hhXbrTSlE++n tqIU+FD+VC/GMzNFTNj0lT/nfl61WDHJv1Q9mU5hC4j+K0q/3RGhYXRhbluLU8fxY6Fb fZ46/b91jG0tA2OAeQ3vPGtj2o6ZgZjDhXGacxlajeDTKz2S0R/uUbDsndYe7ygj9ZC6 P2/gkR5TeGQ3p87w1mt/TDlX22pU9kwpw2iihRp1pkBmCv+Dj/CfjeOJeiQD9eKyiQNl 5JjmVi1ZMmZ8Rq//pb4hff9IY/LAexDTxEmq4HnyfcYBZvTHruSWTbJ0mDcvSJY8JJuI j4Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=A7YF3nY7RWwiblpeqYeH6Gr8kBH483IkbOyS8dt/OFw=; b=j0fNCPaZ7HNdc2vbR+FJaU1/hcJTQcv63ZWhY4gTBt3b6rPqtiRTFHPwXZvF2u+eEp ZlvPSEzgDti9zCwDKeMxaZtlXpirkn67Ge490m6cVy1CgDCb5Wi3QHjV4ar6SM67uWp4 MVpbrx0iIME0OwWMlI2V72ikydc4JpcVZEoinVYIi2wT2WvQ5w9Aar9HmGFApfT/22a+ 27jZdM487HzYTpaobqRZg2v1AYGYPPsVeCYlUN3I0llF2tVB4fxsSaMUZ3i2ONwxhtHE viFZNtgUDdq+A2x2FmBEE92c0V2Ni5SSAB7XY+lSP3Zvq/51CZeMf/VLXQNXHQbebULN tYrw== X-Gm-Message-State: AOAM530cu/zJ9k8U3XK9LO6S869p9fVmnWK0SroF2hBsAfzjQEyewHLA wX0Woh19riZnHiqP2Fav2s9g8HwTt21pvQ== X-Google-Smtp-Source: ABdhPJwoHiSGUBNp4mSuUIeBm6B9sh/p+TPGK0n8FVQz33We6hzauGMN3vJ1k1qCDG4FlcFooaQKjg== X-Received: by 2002:a05:600c:198c:: with SMTP id t12mr1706530wmq.183.1615849725878; Mon, 15 Mar 2021 16:08:45 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id p12sm19637868wrx.28.2021.03.15.16.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 16:08:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 1/5] tests/acceptance: Extract QemuBaseTest from Test Date: Tue, 16 Mar 2021 00:08:34 +0100 Message-Id: <20210315230838.2973103-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315230838.2973103-1-f4bug@amsat.org> References: <20210315230838.2973103-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Willian Rampazzo , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The Avocado Test::fetch_asset() is handy to download artifacts before running tests. The current class is named Test but only tests system emulation. As we want to test user emulation, refactor the common code as QemuBaseTest. Signed-off-by: Philippe Mathieu-Daudé --- tests/acceptance/avocado_qemu/__init__.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index df167b142cc..4f814047176 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -155,7 +155,7 @@ def exec_command_and_wait_for_pattern(test, command, """ _console_interaction(test, success_message, failure_message, command + '\r') -class Test(avocado.Test): +class QemuBaseTest(avocado.Test): def _get_unique_tag_val(self, tag_name): """ Gets a tag value, if unique for a key @@ -188,8 +188,6 @@ def require_accelerator(self, accelerator): "available" % accelerator) def setUp(self): - self._vms = {} - self.arch = self.params.get('arch', default=self._get_unique_tag_val('arch')) @@ -202,6 +200,25 @@ def setUp(self): if self.qemu_bin is None: self.cancel("No QEMU binary defined or found in the build tree") + + def fetch_asset(self, name, + asset_hash=None, algorithm=None, + locations=None, expire=None, + find_only=False, cancel_on_missing=True): + return super(QemuBaseTest, self).fetch_asset(name, + asset_hash=asset_hash, + algorithm=algorithm, + locations=locations, + expire=expire, + find_only=find_only, + cancel_on_missing=cancel_on_missing) + +# a.k.a. QemuSystemTest for system emulation... +class Test(QemuBaseTest): + def setUp(self): + self._vms = {} + super(Test, self).setUp() + def _new_vm(self, *args): self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_") vm = QEMUMachine(self.qemu_bin, sock_dir=self._sd.name) From patchwork Mon Mar 15 23:08:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1453617 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Pfp4mXSB; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Dzsf01bR7z9sRR for ; Tue, 16 Mar 2021 10:12:56 +1100 (AEDT) Received: from localhost ([::1]:55036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLwOM-0007Gh-7o for incoming@patchwork.ozlabs.org; Mon, 15 Mar 2021 19:12:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLwKU-0001BT-Bd for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:54 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:53095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLwKS-0001xO-QT for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:54 -0400 Received: by mail-wm1-x333.google.com with SMTP id d191so9053815wmd.2 for ; Mon, 15 Mar 2021 16:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4tUMWakslWwBjVs/0HfBBNZUO07+acnd7bqh9wtAzCw=; b=Pfp4mXSB6BRs6AyUQcrqNueIcckZSnAqKC6YhbHReVFjWbLSlYTTgLFw3UqpVZqofJ 9fQwxPAfZv2vp73qHoqQwx1FfWB6Ph1m05Hd/LE4hNzFpWmUTViP1m4eo0OTNPZUmiNC FQ9AZde3MVcT8z1Yc+KrGDawf7OnLF640Q9VcKIm2y8G53jpQpAqG4q81ZhtyEl0odDO wpABsIoRO6plAQ9ryRWMgszHPhv7IvfXzE5eO5VauiMf5BsS4FTZN5TCC1eF/Lex0qfq rjTQrc9AZ0QHUO3XjxFyWlTPyTIipSlZccZbXbwHr0NVYDeQONlj6/DfF2xyQN8P3Vii Cmng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4tUMWakslWwBjVs/0HfBBNZUO07+acnd7bqh9wtAzCw=; b=TThEewXsFRUUOaMgZ8tvXzqnFsuL5JDl5Usos0LYumnHGMg5T5I5x+nGxG1tHDlT8K lTrJPbIzE4fQe2rMh9kGZ+6IQgW6QZavFnANFEXkL2JLl4gLrJ5DA/dxPCeoWtkr1dSj LYYVhOLMVHpO9uOz8CiDRvDdAdRIOWuO/jSDMvqieJ0H58rrS88meHaDt4rkVrDuT71Q KvHI4KmFsO8XLELAEkjfGfe1og5H/LWcy6LYApeU3GI5veNfhvtk4zEliXuA8Mi+8ZqF 4YjX1I4XNKuG32aigpXctFZ0aPOlssT+wBbdJLd4thSj14T+Olt2vyRIP9lTodj7CGSE m/uQ== X-Gm-Message-State: AOAM530MVr4gWezudjXHMK6gLO9vSq+ENDlup25Ce4D16ewV/MuFZ7MY BSIXsb3/25qyU9Cl/eSsOx6YPGo7phU3XQ== X-Google-Smtp-Source: ABdhPJwdtclBfiy7VjSzlPh5aFxVBpqF8KAyTx6Geszb6/CHdKeZ/m4+P27DNdagmYJgGXaXcMC1Vw== X-Received: by 2002:a1c:7407:: with SMTP id p7mr1774110wmc.51.1615849731136; Mon, 15 Mar 2021 16:08:51 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id r11sm20380080wrm.26.2021.03.15.16.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 16:08:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 2/5] tests/acceptance: Make pick_default_qemu_bin() more generic Date: Tue, 16 Mar 2021 00:08:35 +0100 Message-Id: <20210315230838.2973103-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315230838.2973103-1-f4bug@amsat.org> References: <20210315230838.2973103-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Willian Rampazzo , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Make pick_default_qemu_bin() generic to find qemu-system or qemu-user binaries. Signed-off-by: Philippe Mathieu-Daudé --- tests/acceptance/avocado_qemu/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 4f814047176..08b3fa1124f 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -48,7 +48,7 @@ def is_readable_executable_file(path): return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK) -def pick_default_qemu_bin(arch=None): +def pick_default_qemu_bin(bin_fmt, arch=None): """ Picks the path of a QEMU binary, starting either in the current working directory or in the source tree root directory. @@ -67,7 +67,7 @@ def pick_default_qemu_bin(arch=None): # qemu binary path does not match arch for powerpc, handle it if 'ppc64le' in arch: arch = 'ppc64' - qemu_bin_relative_path = "./qemu-system-%s" % arch + qemu_bin_relative_path = os.path.join(".", bin_fmt % arch) if is_readable_executable_file(qemu_bin_relative_path): return qemu_bin_relative_path @@ -187,14 +187,14 @@ def require_accelerator(self, accelerator): self.cancel("%s accelerator does not seem to be " "available" % accelerator) - def setUp(self): + def setUp(self, bin_fmt): self.arch = self.params.get('arch', default=self._get_unique_tag_val('arch')) self.machine = self.params.get('machine', default=self._get_unique_tag_val('machine')) - default_qemu_bin = pick_default_qemu_bin(arch=self.arch) + default_qemu_bin = pick_default_qemu_bin(bin_fmt, arch=self.arch) self.qemu_bin = self.params.get('qemu_bin', default=default_qemu_bin) if self.qemu_bin is None: @@ -217,7 +217,7 @@ def fetch_asset(self, name, class Test(QemuBaseTest): def setUp(self): self._vms = {} - super(Test, self).setUp() + super(Test, self).setUp("qemu-system-%s") def _new_vm(self, *args): self._sd = tempfile.TemporaryDirectory(prefix="avo_qemu_sock_") From patchwork Mon Mar 15 23:08:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1453613 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=uWa+zjPc; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DzsYy3s8Rz9sRR for ; Tue, 16 Mar 2021 10:09:26 +1100 (AEDT) Received: from localhost ([::1]:41458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLwKy-0001Wq-JJ for incoming@patchwork.ozlabs.org; Mon, 15 Mar 2021 19:09:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLwKZ-0001Nt-Sp for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:59 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:54184) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLwKY-00020q-5x for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:08:59 -0400 Received: by mail-wm1-x330.google.com with SMTP id g20so9080217wmk.3 for ; Mon, 15 Mar 2021 16:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LYhx91+2cSrSGuiAZO0E+KTXwLNRLCou9fW7dMGBBFM=; b=uWa+zjPcEY+4WkLnLT/M9RfTMSvgDnBaM8KKyJVnU2+MsTEHjHQc3oipFtk9Rh2FES JDRxBLmAVkruXfBDvFyYnszDQXfBRlfvkwYp4p4a+n0T4KkuTzGdx/aHAo1k2qnHscE4 G5SsOYDJLz7MTg717LPAUkMG6/mYK+8qWSbAtP5rv+oYpfrb6lT4AVNbKaL2602Ts70B WHf3kyi3d7Y/gYtic6IwiOdGT3Z9VvG5XD8CR0gesnQXHNd6XloKOwbOcp+r1a1PZC7k flW5Z4AIMfVa5n2ZaSQvgoZP+NFoMSiUt7IeK2JvBoKKOcsfwKfFE0r+Dr/ONzI5E9lz 27bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=LYhx91+2cSrSGuiAZO0E+KTXwLNRLCou9fW7dMGBBFM=; b=QstHYi3JJw1Y7g7Ljm32HzVgxvOofdZCISdhdtRA6HMnxij9v6GttKWTLR6rh18qLJ IaU87D7ONaOpTXMhQqiGWjFX7L1PuAxNqvdGeFPreoM2cKqQnZ9X7ECnnCFD0ZLDWV9R Ejd9mGqIqKjXDDpOGOtOzD+GlQzcBMlH2jPVWv7MnOe7dY1nRKQHgyntL1KUb26aLZ52 pmO+ACGsQHwqUJELoH44yOYLBkBt/vNv8uE4ijOJg6P2HWa/a96l6sLuuKix+0t1l5oE O2jTVkXA3k5atPVybi5IBW4e1T5/Sx0Tj6RXO81fcUTvp5uh6Q65RgkuMRBnrt1Argi3 K88w== X-Gm-Message-State: AOAM5326URLWdz+UcljahBgd0XiNvK/0ON3/o1y/QGwg0sKBzN4CLZtd P4RlkcjjPFcPJFOVp4GQxLZIKXcFvMfIdA== X-Google-Smtp-Source: ABdhPJyrH0oTTtqp/LXbCRoChXO34MT6RxjKJDnalIetwHnTkzPXP0Y8OVljKfjzZF6xAG7FC4QEjg== X-Received: by 2002:a7b:c399:: with SMTP id s25mr1755606wmj.124.1615849736276; Mon, 15 Mar 2021 16:08:56 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id c9sm20175456wrr.78.2021.03.15.16.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 16:08:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 3/5] tests/acceptance: Introduce QemuUserTest base class Date: Tue, 16 Mar 2021 00:08:36 +0100 Message-Id: <20210315230838.2973103-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315230838.2973103-1-f4bug@amsat.org> References: <20210315230838.2973103-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Willian Rampazzo , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Similarly to the 'System' Test base class with methods for testing system emulation, the QemuUserTest class contains methods useful to test user-mode emulation. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 08b3fa1124f..b471bee66e0 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -20,6 +20,7 @@ from avocado.utils import cloudinit from avocado.utils import datadrainer from avocado.utils import network +from avocado.utils import process from avocado.utils import vmimage from avocado.utils.path import find_command @@ -256,6 +257,19 @@ def fetch_asset(self, name, find_only=find_only, cancel_on_missing=cancel_on_missing) +class QemuUserTest(QemuBaseTest): + def setUp(self): + self._ldpath = [] + super(QemuUserTest, self).setUp("qemu-%s") + + def add_ldpath(self, ldpath): + self._ldpath += [os.path.abspath(ldpath)] + + def run(self, bin_path, args=[]): + qemu_args = " ".join(["-L %s" % ldpath for ldpath in self._ldpath]) + bin_args = " ".join(args) + return process.run("%s %s %s %s" % (self.qemu_bin, qemu_args, + bin_path, bin_args)) class LinuxTest(Test): """Facilitates having a cloud-image Linux based available. From patchwork Mon Mar 15 23:08:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1453615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=I0uzjyT5; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4Dzsc461bkz9sRf for ; Tue, 16 Mar 2021 10:11:16 +1100 (AEDT) Received: from localhost ([::1]:47218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLwMj-0003wm-2a for incoming@patchwork.ozlabs.org; Mon, 15 Mar 2021 19:11:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58890) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLwKe-0001Y4-LC for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:09:04 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:43898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLwKc-00023k-Ql for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:09:04 -0400 Received: by mail-wm1-x32c.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so398559wmj.2 for ; Mon, 15 Mar 2021 16:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aBbDjOPo2KNb79pU06GVUHksAp78Q462ezyUFGJx4LU=; b=I0uzjyT5ZkiUwsuTCh9Oh/LROMloQWrUChZR5Lgn8bwsELaTlPD7683fg69/dATgNA eO3G1k9ze0UHhr21YmR31ZzYgn3t2xlR2IjSfCohlYlr8saEWIXRD1j08+TqWZ/OT80+ LVp+AIMNCmwPNBDZtetHGWqk6qKT3JvUOAtl1jf2yZBXYLa4RJUp5sSA+OCJh/XJiS3V FlsgvXPvrqDr3H+ayAuUlS2yvAWetuXrjmgGXXv1CG68OQl18AyNBRU/F8pdQ5MQK/2/ +kJ8xjTeGGFQFPhZwYeZjN3XpwF67S2LAhBlN53rLzQ99RcN/2b3Cmld+AZjQC3Uv3QT Rl1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=aBbDjOPo2KNb79pU06GVUHksAp78Q462ezyUFGJx4LU=; b=cuiNmmT8kBCoSrf1BvYyDuRniMw9s3qpoc5SG3XBC5JaRAHdOAlrgzuAkh3pZcDXKE 29jEM+1aRa7huvcT3U+n5k5STk0JLM/HnupCyRrpI0NIme+2VyD8/081oO9aUSdb4Bv5 xF9Q70Bp1LBr5/PC82az2+w9IQ/xP6Sex92/xyrNinJuAaWbYoBq8aMU0a0DN5ciru2a GkXEs0jYXY/jYb9uM095VZ0GY3RMBQD5AR/lP4ZsjLSQYgB8xF2kV3NkYAbt7b8f5kzM jcZVYJ5/UwiDOrDgRe/o10j+wc1i20tggF1Nil6dQCu+nAy37LQVn78h0CkMxFUtA+cq WBuQ== X-Gm-Message-State: AOAM5309QWRvzbtdrfwOsf80u6ZgDwy8dor3Y3zzZ2vYt/kQ5bcVcWjE 2cnkWckgp31J/NeUqsQh2bd2RviU4BeMHQ== X-Google-Smtp-Source: ABdhPJzM1rTP2Ro3XwpejzVpRvf0n2FX/EexqPehL/ELWoM+YV1eaPCLZlgfPDoDkDYQRZ8QGABuZA== X-Received: by 2002:a05:600c:c4:: with SMTP id u4mr1786902wmm.27.1615849741232; Mon, 15 Mar 2021 16:09:01 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id y1sm1059521wmq.29.2021.03.15.16.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 16:09:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 4/5] tests/acceptance: Share useful helpers from virtiofs_submounts test Date: Tue, 16 Mar 2021 00:08:37 +0100 Message-Id: <20210315230838.2973103-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315230838.2973103-1-f4bug@amsat.org> References: <20210315230838.2973103-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x32c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Willian Rampazzo , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Move the useful has_cmd()/has_cmds() helpers from the virtiofs test to the avocado_qemu public class. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 57 ++++++++++++++++++++++ tests/acceptance/virtiofs_submounts.py | 59 +---------------------- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index b471bee66e0..48c705fe3d2 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -11,6 +11,7 @@ import logging import os import shutil +import subprocess import sys import uuid import tempfile @@ -45,6 +46,62 @@ from qemu.accel import tcg_available from qemu.machine import QEMUMachine +def has_cmd(name, args=None): + """ + This function is for use in a @avocado.skipUnless decorator, e.g.: + + @skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true'))) + def test_something_that_needs_sudo(self): + ... + """ + + if args is None: + args = ('which', name) + + try: + _, stderr, exitcode = run_cmd(args) + except Exception as e: + exitcode = -1 + stderr = str(e) + + if exitcode != 0: + cmd_line = ' '.join(args) + err = f'{name} required, but "{cmd_line}" failed: {stderr.strip()}' + return (False, err) + else: + return (True, '') + +def has_cmds(*cmds): + """ + This function is for use in a @avocado.skipUnless decorator and + allows checking for the availability of multiple commands, e.g.: + + @skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')), + 'cmd2', 'cmd3')) + def test_something_that_needs_cmd1_and_cmd2(self): + ... + """ + + for cmd in cmds: + if isinstance(cmd, str): + cmd = (cmd,) + + ok, errstr = has_cmd(*cmd) + if not ok: + return (False, errstr) + + return (True, '') + +def run_cmd(args): + subp = subprocess.Popen(args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + universal_newlines=True) + stdout, stderr = subp.communicate() + ret = subp.returncode + + return (stdout, stderr, ret) + def is_readable_executable_file(path): return os.path.isfile(path) and os.access(path, os.R_OK | os.X_OK) diff --git a/tests/acceptance/virtiofs_submounts.py b/tests/acceptance/virtiofs_submounts.py index 46fa65392a1..201645cd740 100644 --- a/tests/acceptance/virtiofs_submounts.py +++ b/tests/acceptance/virtiofs_submounts.py @@ -6,67 +6,12 @@ from avocado import skipUnless from avocado_qemu import LinuxTest, BUILD_DIR +from avocado_qemu import has_cmds +from avocado_qemu import run_cmd from avocado_qemu import wait_for_console_pattern from avocado.utils import ssh -def run_cmd(args): - subp = subprocess.Popen(args, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - universal_newlines=True) - stdout, stderr = subp.communicate() - ret = subp.returncode - - return (stdout, stderr, ret) - -def has_cmd(name, args=None): - """ - This function is for use in a @avocado.skipUnless decorator, e.g.: - - @skipUnless(*has_cmd('sudo -n', ('sudo', '-n', 'true'))) - def test_something_that_needs_sudo(self): - ... - """ - - if args is None: - args = ('which', name) - - try: - _, stderr, exitcode = run_cmd(args) - except Exception as e: - exitcode = -1 - stderr = str(e) - - if exitcode != 0: - cmd_line = ' '.join(args) - err = f'{name} required, but "{cmd_line}" failed: {stderr.strip()}' - return (False, err) - else: - return (True, '') - -def has_cmds(*cmds): - """ - This function is for use in a @avocado.skipUnless decorator and - allows checking for the availability of multiple commands, e.g.: - - @skipUnless(*has_cmds(('cmd1', ('cmd1', '--some-parameter')), - 'cmd2', 'cmd3')) - def test_something_that_needs_cmd1_and_cmd2(self): - ... - """ - - for cmd in cmds: - if isinstance(cmd, str): - cmd = (cmd,) - - ok, errstr = has_cmd(*cmd) - if not ok: - return (False, errstr) - - return (True, '') - - class VirtiofsSubmountsTest(LinuxTest): """ :avocado: tags=arch:x86_64 From patchwork Mon Mar 15 23:08:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1453616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=taNjqGhN; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4DzscM0pFHz9sTD for ; Tue, 16 Mar 2021 10:11:31 +1100 (AEDT) Received: from localhost ([::1]:48486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lLwMz-0004XY-2r for incoming@patchwork.ozlabs.org; Mon, 15 Mar 2021 19:11:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lLwKk-0001k9-6f for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:09:10 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:40354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lLwKh-000267-Sn for qemu-devel@nongnu.org; Mon, 15 Mar 2021 19:09:09 -0400 Received: by mail-wr1-x42a.google.com with SMTP id l11so9529008wrp.7 for ; Mon, 15 Mar 2021 16:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YTXlhkG2Ovry9Jhj0XTrAo3VZzzvcKLTHnzNgI1T5kA=; b=taNjqGhNnNAXP9edIB3tCuApJx9aESGakqJsWYEr4gMipLwzcBTIpUeJY6WT7+MiqA nDzPx8LwEYtmdqF3DKchjpbDRwRPycIc+bQ9PQdkzU5kuLeRSXG4uJsh64h9rHN87/6h QN2dkI7ochZ2yVCHBVpPGivRVwM7yAHadTCZwucvc53UM+h4QLvfOV3MK/Wzjui6HJky Wx5GcXWW6HKjKFUecN8rlM9YomHAW9EmboZ/DyZc83q1fJRKehHvq7ea7/0g39J3FlnU G5RAXF6heoQco6OtMmxBsJ5/xuI5+onAQBNB4T7SyWRFGGfpHBUtiQlGMUoy2vYPIbwO V+Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=YTXlhkG2Ovry9Jhj0XTrAo3VZzzvcKLTHnzNgI1T5kA=; b=KB9QQuGfujTAs8eKcy36PGhvq1jX89490+qX/QPoWNsGfygt7Qlhacv7XBCNuXGP3L 9r9Yd/A1Vlq3tz1Sgx0CMmSn8R4iVXrLO6RVL+kdCxHUMQPBKJ+w/VREzpWmRFXjoU+c GzFucnK+7mAIu2yN3lhr54awHYzb9lUA/qhHBgFr8umgxHgZqX4n6F7AW9cpydW3Pw+4 V1KNGI2A2FPua5Ns/csjZm4mRY86mergBysqqpnttLSxp1rZ7ogLqM0QTlt+3zaXS2fT hIijqrNN5NcwKRwYQjHlRZpQ3qFnO01kA+OFNj7xiqh4yMGIlR7/e6YtnG5Z4hUeZIpq ULQA== X-Gm-Message-State: AOAM532shIBHet0P8dCWZo3uI7uwhA8xCA2M2H8LB/Vr+e+Ws84/S+El pWTPreXIBz8eKngK82XKR4qe6lBinIV1Xw== X-Google-Smtp-Source: ABdhPJwkMBGsz/pr5WofxyZxjFvwRyMYsUSSi5L2toiV10l3yW/FfnjWubBY8sxz4MWov1pRRi4pCQ== X-Received: by 2002:adf:ab52:: with SMTP id r18mr1757701wrc.65.1615849746231; Mon, 15 Mar 2021 16:09:06 -0700 (PDT) Received: from x1w.redhat.com (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id k12sm20886107wrx.7.2021.03.15.16.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 16:09:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 5/5] tests/acceptance: Add bFLT loader linux-user test Date: Tue, 16 Mar 2021 00:08:38 +0100 Message-Id: <20210315230838.2973103-6-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315230838.2973103-1-f4bug@amsat.org> References: <20210315230838.2973103-1-f4bug@amsat.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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: Willian Rampazzo , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Wainer dos Santos Moschetta , Cleber Rosa Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a very quick test that runs a busybox binary in bFLT format: $ avocado --show=app run -t linux_user tests/acceptance/load_bflt.py JOB ID : db94d5960ce564c50904d666a7e259148c27e88f JOB LOG : ~/avocado/job-results/job-2019-06-25T10.52-db94d59/job.log (1/1) tests/acceptance/load_bflt.py:LoadBFLT.test_stm32: PASS (0.15 s) RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 JOB TIME : 0.54 s Reviewed-by: Willian Rampazzo Signed-off-by: Philippe Mathieu-Daudé --- v3: Check for 'cpio' (thuth) --- tests/acceptance/load_bflt.py | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/acceptance/load_bflt.py diff --git a/tests/acceptance/load_bflt.py b/tests/acceptance/load_bflt.py new file mode 100644 index 00000000000..f071a979d8e --- /dev/null +++ b/tests/acceptance/load_bflt.py @@ -0,0 +1,54 @@ +# Test the bFLT loader format +# +# Copyright (C) 2019 Philippe Mathieu-Daudé +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import bz2 +import subprocess + +from avocado import skipUnless +from avocado_qemu import QemuUserTest +from avocado_qemu import has_cmd + + +class LoadBFLT(QemuUserTest): + + def extract_cpio(self, cpio_path): + """ + Extracts a cpio archive into the test workdir + + :param cpio_path: path to the cpio archive + """ + cwd = os.getcwd() + os.chdir(self.workdir) + with bz2.open(cpio_path, 'rb') as archive_cpio: + subprocess.run(['cpio', '-i'], input=archive_cpio.read(), + stderr=subprocess.DEVNULL) + os.chdir(cwd) + + @skipUnless(*has_cmd('cpio')) + @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') + def test_stm32(self): + """ + :avocado: tags=arch:arm + :avocado: tags=linux_user + :avocado: tags=quick + """ + # See https://elinux.org/STM32#User_Space + rootfs_url = ('https://elinux.org/images/5/51/' + 'Stm32_mini_rootfs.cpio.bz2') + rootfs_hash = '9f065e6ba40cce7411ba757f924f30fcc57951e6' + rootfs_path_bz2 = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) + busybox_path = self.workdir + "/bin/busybox" + + self.extract_cpio(rootfs_path_bz2) + + res = self.run(busybox_path) + ver = 'BusyBox v1.24.0.git (2015-02-03 22:17:13 CET) multi-call binary.' + self.assertIn(ver, res.stdout_text) + + res = self.run(busybox_path, ['uname', '-a']) + unm = 'armv7l GNU/Linux' + self.assertIn(unm, res.stdout_text)