{"id":815047,"url":"http://patchwork.ozlabs.org/api/patches/815047/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170918171149.23792-3-swarren@wwwdotorg.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170918171149.23792-3-swarren@wwwdotorg.org>","list_archive_url":null,"date":"2017-09-18T17:11:49","name":"[U-Boot,3/3] test/py: add skip marker for reliance on tools","commit_ref":"2d26bf6c26b2507fb597b7d265efe7d61cb2d6b2","pull_url":null,"state":"accepted","archived":false,"hash":"1910bdee988445d2c2cda78ec94913386911fdbd","submitter":{"id":12517,"url":"http://patchwork.ozlabs.org/api/people/12517/?format=json","name":"Stephen Warren","email":"swarren@wwwdotorg.org"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170918171149.23792-3-swarren@wwwdotorg.org/mbox/","series":[{"id":3685,"url":"http://patchwork.ozlabs.org/api/series/3685/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3685","date":"2017-09-18T17:11:47","name":"[U-Boot,1/3] test/py: Document required tools/packages","version":1,"mbox":"http://patchwork.ozlabs.org/series/3685/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815047/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815047/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwszH1StWz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 03:13:31 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid CB80FC21DB9; Mon, 18 Sep 2017 17:12:32 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id D0701C21D90;\n\tMon, 18 Sep 2017 17:11:59 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 92037C21C2B; Mon, 18 Sep 2017 17:11:55 +0000 (UTC)","from avon.wwwdotorg.org (avon.wwwdotorg.org [104.237.132.123])\n\tby lists.denx.de (Postfix) with ESMTPS id D9583C21C2B\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 17:11:54 +0000 (UTC)","from swarren-lx1.nvidia.com (thunderhill.nvidia.com\n\t[216.228.112.22])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby avon.wwwdotorg.org (Postfix) with ESMTPSA id 3DCB11C0419;\n\tMon, 18 Sep 2017 11:11:53 -0600 (MDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=none autolearn=unavailable\n\tautolearn_force=no version=3.4.0","X-Virus-Status":"Clean","X-Virus-Scanned":"clamav-milter 0.99.2 at avon.wwwdotorg.org","From":"Stephen Warren <swarren@wwwdotorg.org>","To":"Tom Rini <trini@konsulko.com>","Date":"Mon, 18 Sep 2017 11:11:49 -0600","Message-Id":"<20170918171149.23792-3-swarren@wwwdotorg.org>","X-Mailer":"git-send-email 2.14.1","In-Reply-To":"<20170918171149.23792-1-swarren@wwwdotorg.org>","References":"<20170918171149.23792-1-swarren@wwwdotorg.org>","X-NVConfidentiality":"public","Cc":"Alison Chaiken <alison@peloton-tech.com>, u-boot@lists.denx.de,\n\tStephen Warren <swarren@nvidia.com>","Subject":"[U-Boot] [PATCH 3/3] test/py: add skip marker for reliance on tools","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"From: Stephen Warren <swarren@nvidia.com>\n\nSome tests use external tools (executables) during their operation. Add\na test.py mark to indicate this. This allows those tests to be skipped if\nthe required tool is not present.\n\nSigned-off-by: Stephen Warren <swarren@nvidia.com>\n---\n test/py/conftest.py         | 29 +++++++++++++++++++++++++++++\n test/py/tests/test_dfu.py   |  1 +\n test/py/tests/test_fit.py   |  1 +\n test/py/tests/test_gpt.py   | 13 ++++++++-----\n test/py/tests/test_vboot.py |  4 ++++\n 5 files changed, 43 insertions(+), 5 deletions(-)","diff":"diff --git a/test/py/conftest.py b/test/py/conftest.py\nindex e2fc7fd7ef78..6e66a48c15fd 100644\n--- a/test/py/conftest.py\n+++ b/test/py/conftest.py\n@@ -457,6 +457,34 @@ def setup_buildconfigspec(item):\n         if not ubconfig.buildconfig.get('config_' + option.lower(), None):\n             pytest.skip('.config feature \"%s\" not enabled' % option.lower())\n \n+def tool_is_in_path(tool):\n+    for path in os.environ[\"PATH\"].split(os.pathsep):\n+        fn = os.path.join(path, tool)\n+        if os.path.isfile(fn) and os.access(fn, os.X_OK):\n+            return True\n+    return False\n+\n+def setup_requiredtool(item):\n+    \"\"\"Process any 'requiredtool' marker for a test.\n+\n+    Such a marker lists some external tool (binary, executable, application)\n+    that the test requires. If tests are being executed on a system that\n+    doesn't have the required tool, the test is marked to be skipped.\n+\n+    Args:\n+        item: The pytest test item.\n+\n+    Returns:\n+        Nothing.\n+    \"\"\"\n+\n+    mark = item.get_marker('requiredtool')\n+    if not mark:\n+        return\n+    for tool in mark.args:\n+        if not tool_is_in_path(tool):\n+            pytest.skip('tool \"%s\" not in $PATH' % tool)\n+\n def start_test_section(item):\n     anchors[item.name] = log.start_section(item.name)\n \n@@ -476,6 +504,7 @@ def pytest_runtest_setup(item):\n     start_test_section(item)\n     setup_boardspec(item)\n     setup_buildconfigspec(item)\n+    setup_requiredtool(item)\n \n def pytest_runtest_protocol(item, nextitem):\n     \"\"\"pytest hook: Called to execute a test.\ndiff --git a/test/py/tests/test_dfu.py b/test/py/tests/test_dfu.py\nindex fba67d585b9f..8f6877c5c264 100644\n--- a/test/py/tests/test_dfu.py\n+++ b/test/py/tests/test_dfu.py\n@@ -113,6 +113,7 @@ test_sizes_default = (\n first_usb_dev_port = None\n \n @pytest.mark.buildconfigspec('cmd_dfu')\n+@pytest.mark.requiredtool('dfu-util')\n def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):\n     \"\"\"Test the \"dfu\" command; the host system must be able to enumerate a USB\n     device when \"dfu\" is running, various DFU transfers are tested, and the\ndiff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py\nindex 7e6b96dae45a..4b32bb18b8b3 100755\n--- a/test/py/tests/test_fit.py\n+++ b/test/py/tests/test_fit.py\n@@ -111,6 +111,7 @@ sb save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x\n \n @pytest.mark.boardspec('sandbox')\n @pytest.mark.buildconfigspec('fit_signature')\n+@pytest.mark.requiredtool('dtc')\n def test_fit(u_boot_console):\n     def make_fname(leaf):\n         \"\"\"Make a temporary filename\ndiff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py\nindex e2bbd08e6d42..ec25fbbc5a10 100644\n--- a/test/py/tests/test_gpt.py\n+++ b/test/py/tests/test_gpt.py\n@@ -38,15 +38,14 @@ class GptTestDiskImage(object):\n             fd = os.open(self.path, os.O_RDWR | os.O_CREAT)\n             os.ftruncate(fd, 4194304)\n             os.close(fd)\n-            sgdisk = '/sbin/sgdisk'\n-            cmd = (sgdisk, '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe',\n+            cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe',\n                 self.path)\n             u_boot_utils.run_and_log(u_boot_console, cmd)\n-            cmd = (sgdisk, '--new=1:2048:2560', self.path)\n+            cmd = ('sgdisk', '--new=1:2048:2560', self.path)\n             u_boot_utils.run_and_log(u_boot_console, cmd)\n-            cmd = (sgdisk, '--new=2:4096:4608', self.path)\n+            cmd = ('sgdisk', '--new=2:4096:4608', self.path)\n             u_boot_utils.run_and_log(u_boot_console, cmd)\n-            cmd = (sgdisk, '-l', self.path)\n+            cmd = ('sgdisk', '-l', self.path)\n             u_boot_utils.run_and_log(u_boot_console, cmd)\n \n gtdi = None\n@@ -64,6 +63,7 @@ def state_disk_image(u_boot_console):\n \n @pytest.mark.boardspec('sandbox')\n @pytest.mark.buildconfigspec('cmd_gpt')\n+@pytest.mark.requiredtool('sgdisk')\n def test_gpt_guid(state_disk_image, u_boot_console):\n     \"\"\"Test the gpt guid command.\"\"\"\n \n@@ -73,6 +73,7 @@ def test_gpt_guid(state_disk_image, u_boot_console):\n \n @pytest.mark.boardspec('sandbox')\n @pytest.mark.buildconfigspec('cmd_gpt')\n+@pytest.mark.requiredtool('sgdisk')\n def test_gpt_save_guid(state_disk_image, u_boot_console):\n     \"\"\"Test the gpt guid command to save GUID into a string.\"\"\"\n \n@@ -86,6 +87,7 @@ def test_gpt_save_guid(state_disk_image, u_boot_console):\n @pytest.mark.boardspec('sandbox')\n @pytest.mark.buildconfigspec('cmd_gpt')\n @pytest.mark.buildconfigspec('cmd_gpt_rename')\n+@pytest.mark.requiredtool('sgdisk')\n def test_gpt_rename_partition(state_disk_image, u_boot_console):\n     \"\"\"Test the gpt rename command to write partition names.\"\"\"\n \n@@ -101,6 +103,7 @@ def test_gpt_rename_partition(state_disk_image, u_boot_console):\n @pytest.mark.buildconfigspec('cmd_gpt')\n @pytest.mark.buildconfigspec('cmd_gpt_rename')\n @pytest.mark.buildconfigspec('cmd_part')\n+@pytest.mark.requiredtool('sgdisk')\n def test_gpt_swap_partitions(state_disk_image, u_boot_console):\n     \"\"\"Test the gpt swap command to exchange two partition names.\"\"\"\n \ndiff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py\nindex 6e62820743fe..c4da79d11407 100644\n--- a/test/py/tests/test_vboot.py\n+++ b/test/py/tests/test_vboot.py\n@@ -31,6 +31,10 @@ import u_boot_utils as util\n \n @pytest.mark.boardspec('sandbox')\n @pytest.mark.buildconfigspec('fit_signature')\n+@pytest.mark.requiredtool('dtc')\n+@pytest.mark.requiredtool('fdtget')\n+@pytest.mark.requiredtool('fdtput')\n+@pytest.mark.requiredtool('openssl')\n def test_vboot(u_boot_console):\n     \"\"\"Test verified boot signing with mkimage and verification with 'bootm'.\n \n","prefixes":["U-Boot","3/3"]}