{"id":818799,"url":"http://patchwork.ozlabs.org/api/patches/818799/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170926192142.42308-14-sjg@chromium.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":"<20170926192142.42308-14-sjg@chromium.org>","list_archive_url":null,"date":"2017-09-26T19:21:41","name":"[U-Boot,v2,13/14] log: test: Add a pytest for logging","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2f163d9a70b57d9e2091546d730a588463efea16","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3184,"url":"http://patchwork.ozlabs.org/api/users/3184/?format=json","username":"sjg","first_name":"Simon","last_name":"Glass","email":"sjg@chromium.org"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170926192142.42308-14-sjg@chromium.org/mbox/","series":[{"id":5217,"url":"http://patchwork.ozlabs.org/api/series/5217/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=5217","date":"2017-09-26T19:21:28","name":"log: Add a new logging feature","version":2,"mbox":"http://patchwork.ozlabs.org/series/5217/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818799/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818799/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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"GNCywuPg\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3y1rdL6K80z9t3F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 05:30:14 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 71A9CC21F02; Tue, 26 Sep 2017 19:26:22 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 18EBDC21F2C;\n\tTue, 26 Sep 2017 19:24:10 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 19A14C21F35; Tue, 26 Sep 2017 19:22:32 +0000 (UTC)","from mail-oi0-f52.google.com (mail-oi0-f52.google.com\n\t[209.85.218.52])\n\tby lists.denx.de (Postfix) with ESMTPS id 55DDCC21F58\n\tfor <u-boot@lists.denx.de>; Tue, 26 Sep 2017 19:22:29 +0000 (UTC)","by mail-oi0-f52.google.com with SMTP id l74so13525450oih.1\n\tfor <u-boot@lists.denx.de>; Tue, 26 Sep 2017 12:22:29 -0700 (PDT)","from kiwi.bld.corp.google.com ([100.101.164.89])\n\tby smtp.gmail.com with ESMTPSA id\n\tp19sm1492000ota.14.2017.09.26.12.22.26\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 26 Sep 2017 12:22:27 -0700 (PDT)","by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid C9F60140573; Tue, 26 Sep 2017 13:22:25 -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=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=adH99Q2BxtPU+6V8mVjqp+FT8Ns2B+2SMBjqFvoVWjM=;\n\tb=GNCywuPgKOtQyINH621gsA3deXd58Y/aMAV2Wo10s4TRljCePD5iM5f94E4tPP+obE\n\t7/0TSMpG5Q5bREof+ZyxM7pzQzopW2SYiUKiU/Xg8vzuvGqqcVWtfmh6Hej5oXD5KHoY\n\tO6d7am+EnXij/7ZfuF8X4ragd2VzncP1krZ18expyXpiuP76Z54Y3xh4HFVbqcL1dml5\n\tk3uj8IVihc9xlQQUSEXmmibCsPBEbauoSiJlqBjwxLI+hcfFkPJSpMmtA+6eN0e8CUfQ\n\tZlCmV6MiJx+SntSxSMpMHwb+0WMK7RH541py7WT1AV0Trd6IV0U6GX3YvUUxUCVkFXfv\n\t/G/g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=adH99Q2BxtPU+6V8mVjqp+FT8Ns2B+2SMBjqFvoVWjM=;\n\tb=qGDHwKv0InfRMiPogk5IjNwUbQihSfxIm/q6AgItcPbru6kwzRRUG2oHsIJ7uRHN+U\n\tA+eHywAhYS8PYnlPN9LzChUru1TOzn2XJ9QJ/gtUpNIBP6J4qknTAKE0Dwtz3K3AmTg2\n\t9VkL4RGSvt9fDWkx07sckaVxt7nVn1Jt9bJ/cE2AXjuX18HR5fqaw1MU2d7Qnz70VY2P\n\tJ6r6jR/BiGhL1lAZpGM8jD7m1E/wyhmFmHMROvqDLyhoGEUks0PNn0CnN9CjKdZ205Hy\n\tYHZp/Ub91kyEIZ/htrXFVK0/ylV9F4UWjmI0eAqTayILteArpylYuVSfR7NWqXO6F/+O\n\tYsAg==","X-Gm-Message-State":"AHPjjUiiVqrbQMC2BNmEuIOU61t6h3yM2BuG6+GPvJDn8j4xg+uCsAC+\n\ti12lgOYxgNXo9aiOcG7S6LpwFg==","X-Google-Smtp-Source":"AOwi7QDLInT3/KIDB+/r0WyCMMKmtn+ga5Q1y8lugds1Sg3Lf4hwPvi5JlZiil4sNrL0wbuDkhG1/A==","X-Received":"by 10.157.68.121 with SMTP id f54mr2730800otj.288.1506453747907; \n\tTue, 26 Sep 2017 12:22:27 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Tue, 26 Sep 2017 13:21:41 -0600","Message-Id":"<20170926192142.42308-14-sjg@chromium.org>","X-Mailer":"git-send-email 2.14.1.992.g2c7b836f3a-goog","In-Reply-To":"<20170926192142.42308-1-sjg@chromium.org>","References":"<20170926192142.42308-1-sjg@chromium.org>","Cc":"Tom Rini <trini@konsulko.com>","Subject":"[U-Boot] [PATCH v2 13/14] log: test: Add a pytest for logging","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":"Add a test which tries out various filters and options to make sure that\nlogging works as expected.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\nChanges in v2:\n- Change log levels to match new header\n- Only execute log tests if CONFIG_LOG is enabled\n- Rename LOGL_WARN to LOGL_WARNING\n\n MAINTAINERS               |   1 +\n test/py/tests/test_log.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 108 insertions(+)\n create mode 100644 test/py/tests/test_log.py","diff":"diff --git a/MAINTAINERS b/MAINTAINERS\nindex ca5224341e..eb420afa8d 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -297,6 +297,7 @@ T:\tgit git://git.denx.de/u-boot.git\n F:\tcommon/log.c\n F:\tcmd/log.c\n F:\ttest/log/log_test.c\n+F:\ttest/py/tests/test_log.py\n \n MICROBLAZE\n M:\tMichal Simek <monstr@monstr.eu>\ndiff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py\nnew file mode 100644\nindex 0000000000..bed040b4d7\n--- /dev/null\n+++ b/test/py/tests/test_log.py\n@@ -0,0 +1,107 @@\n+# Copyright (c) 2016, Google Inc.\n+#\n+# SPDX-License-Identifier:      GPL-2.0+\n+#\n+# U-Boot Verified Boot Test\n+\n+\"\"\"\n+This tests U-Boot logging. It uses the 'log test' command with various options\n+and checks that the output is correct.\n+\"\"\"\n+\n+import pytest\n+\n+LOGL_FIRST, LOGL_WARNING, LOGL_INFO = (0, 4, 6)\n+\n+@pytest.mark.buildconfigspec('log')\n+def test_log(u_boot_console):\n+    \"\"\"Test that U-Boot logging works correctly.\"\"\"\n+    def check_log_entries(lines, mask, max_level=LOGL_INFO):\n+        \"\"\"Check that the expected log records appear in the output\n+\n+        Args:\n+            lines: iterator containing lines to check\n+            mask: bit mask to select which lines to check for:\n+                bit 0: standard log line\n+                bit 1: _log line\n+            max_level: maximum log level to expect in the output\n+        \"\"\"\n+        for i in range(max_level):\n+            if mask & 1:\n+                assert 'log %d' % i == lines.next()\n+            if mask & 3:\n+                assert '_log %d' % i == lines.next()\n+\n+    def run_test(testnum):\n+        \"\"\"Run a particular test number (the 'log test' command)\n+\n+        Args:\n+            testnum: Test number to run\n+        Returns:\n+            iterator containing the lines output from the command\n+        \"\"\"\n+\n+        with cons.log.section('basic'):\n+           output = u_boot_console.run_command('log test %d' % testnum)\n+        split = output.replace('\\r', '').splitlines()\n+        lines = iter(split)\n+        assert 'test %d' % testnum == lines.next()\n+        return lines\n+\n+    def test0():\n+        lines = run_test(0)\n+        assert 'error' == lines.next()\n+        check_log_entries(lines, 3)\n+\n+    def test1():\n+        lines = run_test(1)\n+        check_log_entries(lines, 3)\n+\n+    def test2():\n+        lines = run_test(2)\n+        assert 'error' == lines.next()\n+\n+    def test3():\n+        lines = run_test(3)\n+        check_log_entries(lines, 2)\n+\n+    def test4():\n+        lines = run_test(4)\n+        assert next(lines, None) == None\n+\n+    def test5():\n+        lines = run_test(5)\n+        check_log_entries(lines, 2)\n+\n+    def test6():\n+        lines = run_test(6)\n+        assert 'error' == lines.next()\n+        check_log_entries(lines, 3)\n+\n+    def test7():\n+        lines = run_test(7)\n+        assert 'error' == lines.next()\n+        check_log_entries(lines, 3, LOGL_WARNING)\n+\n+    def test8():\n+        lines = run_test(8)\n+        assert 'error' == lines.next()\n+        check_log_entries(lines, 3)\n+\n+    def test9():\n+        lines = run_test(8)\n+        assert 'error' == lines.next()\n+        check_log_entries(lines, 3)\n+\n+    # TODO(sjg@chromium.org): Consider structuring this as separate tests\n+    cons = u_boot_console\n+    test0()\n+    test1()\n+    test2()\n+    test3()\n+    test4()\n+    test5()\n+    test6()\n+    test7()\n+    test8()\n+    test9()\n","prefixes":["U-Boot","v2","13/14"]}