{"id":814560,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814560/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-13-sjg@chromium.org/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/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":"<20170916212331.170463-13-sjg@chromium.org>","list_archive_url":null,"date":"2017-09-16T21:23:25","name":"[U-Boot,12/13] log: test: Add a pytest for logging","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"e934293719acd58fea54a7564f79f6b838c06e2f","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/1.2/people/6170/?format=json","name":"Simon Glass","email":"sjg@chromium.org"},"delegate":{"id":3184,"url":"http://patchwork.ozlabs.org/api/1.2/users/3184/?format=json","username":"sjg","first_name":"Simon","last_name":"Glass","email":"sjg@chromium.org"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-13-sjg@chromium.org/mbox/","series":[{"id":3473,"url":"http://patchwork.ozlabs.org/api/1.2/series/3473/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3473","date":"2017-09-16T21:23:14","name":"log: Add a new logging feature","version":1,"mbox":"http://patchwork.ozlabs.org/series/3473/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814560/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814560/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=\"ST/M+GWm\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xvlmx3LDqz9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 17 Sep 2017 07:30:41 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 2A377C21E42; Sat, 16 Sep 2017 21:27:37 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 5FA21C21DDE;\n\tSat, 16 Sep 2017 21:26:12 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 98351C21DDE; Sat, 16 Sep 2017 21:24:21 +0000 (UTC)","from mail-oi0-f50.google.com (mail-oi0-f50.google.com\n\t[209.85.218.50])\n\tby lists.denx.de (Postfix) with ESMTPS id CC6E2C21DE9\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 21:24:16 +0000 (UTC)","by mail-oi0-f50.google.com with SMTP id l74so2372923oih.1\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 14:24:16 -0700 (PDT)","from kiwi.bld.corp.google.com ([100.101.164.89])\n\tby smtp.gmail.com with ESMTPSA id\n\tf6sm4674465oib.27.2017.09.16.14.24.14\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 16 Sep 2017 14:24:14 -0700 (PDT)","by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid C3DC7140A54; Sat, 16 Sep 2017 15:24:13 -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=IrAu2nMJ/avfUt+bUshnGTpYI7BZoLx2HWtsEjKHolo=;\n\tb=ST/M+GWmgkbaI8clLAsKscCpzhvY4FPGStj3xNOnyDJekmPwPDwFQaM2Iu2GG6aCQt\n\t73Ev7unGBSJd9B4kPmVhoga9Bk+4X9tdh5XS4eBUMhe/PzTlwVCNJHcdV9TBbLefCPe0\n\tqmBbne0kr/6bx8P2lteKhF1ya4Gm8ARNv5CaAAyiO7KK2WrHJS5J7499/rlvfOfBk0UK\n\tIhCL25sZuUV318xxuKvXAeiENgf+8RFKCGQi5geii4w4/lklVuS7Gt9MsBBF4wszOwEs\n\tGgBy4HiTnanYYlTRE6PNoHKjn8o4xsqFlMEimVVgiQ2zDLdUOp+sTylM40oZPULq/7U+\n\tHmSQ==","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=IrAu2nMJ/avfUt+bUshnGTpYI7BZoLx2HWtsEjKHolo=;\n\tb=FG4Q5XCYe7h+zrOErFnH9vQommTdow1uieeorE4gH4UMTKhXWDqUN37nWtatgv1KcP\n\t8okBGlZ3vi0/e41N4li3UzOsU/js18RTcM5MbSJpHoidt3kyhi1F96LiicYOnHvIINoM\n\t3JThVq/O0bviZcDIAgzUvDx1nPFm1vulyPRzYEBztCZjL2SCaLTXZSdCuu88lGqYAKaI\n\tlMGVKD77aKsvON5EB0zYOk0Dh4Z2mgcakINJ4aReomDL0+mQoOqN43Ncc6HwKuiT19f5\n\tlTZW2Vlm7mh8IIFzFnSD4L9gcmIemeY4QfOb7tmzY7STIpBuDYxYf9TBpO63ljSI+PaZ\n\t0PAA==","X-Gm-Message-State":"AHPjjUgxoNIWLOS6KS+FAI9luWG26zWd5rzxhhTZiafpJ4f0Kv0M2jLX\n\tDBLCv2BH7PSRC+n7","X-Google-Smtp-Source":"AOwi7QCY1yf2CqBXM9nDMMEqJOoezrOXBUwRLn7dspFq14e3urDe+UeEOvWyqwKAs3QDqY2dvy9Ayw==","X-Received":"by 10.202.78.205 with SMTP id c196mr3787323oib.183.1505597055397;\n\tSat, 16 Sep 2017 14:24:15 -0700 (PDT)","From":"Simon Glass <sjg@chromium.org>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Sat, 16 Sep 2017 15:23:25 -0600","Message-Id":"<20170916212331.170463-13-sjg@chromium.org>","X-Mailer":"git-send-email 2.14.1.690.gbb1197296e-goog","In-Reply-To":"<20170916212331.170463-1-sjg@chromium.org>","References":"<20170916212331.170463-1-sjg@chromium.org>","Cc":"Tom Rini <trini@konsulko.com>","Subject":"[U-Boot] [PATCH 12/13] 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\n test/py/tests/test_log.py | 106 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 106 insertions(+)\n create mode 100644 test/py/tests/test_log.py","diff":"diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py\nnew file mode 100644\nindex 0000000000..d5a01df357\n--- /dev/null\n+++ b/test/py/tests/test_log.py\n@@ -0,0 +1,106 @@\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_WARN, LOGL_INFO = (0, 3, 5)\n+\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_WARN)\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","12/13"]}