Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/814555/?format=api
{ "id": 814555, "url": "http://patchwork.ozlabs.org/api/patches/814555/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-10-sjg@chromium.org/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "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-10-sjg@chromium.org>", "list_archive_url": null, "date": "2017-09-16T21:23:22", "name": "[U-Boot,09/13] log: Add a test command", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "90f6c172e940a511bfced048dba39511adca15ce", "submitter": { "id": 6170, "url": "http://patchwork.ozlabs.org/api/people/6170/?format=api", "name": "Simon Glass", "email": "sjg@chromium.org" }, "delegate": { "id": 3184, "url": "http://patchwork.ozlabs.org/api/users/3184/?format=api", "username": "sjg", "first_name": "Simon", "last_name": "Glass", "email": "sjg@chromium.org" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170916212331.170463-10-sjg@chromium.org/mbox/", "series": [ { "id": 3473, "url": "http://patchwork.ozlabs.org/api/series/3473/?format=api", "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/814555/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814555/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=\"Ez2pgnvg\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xvljv2s1lz9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 17 Sep 2017 07:28:03 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 130DCC21DDE; Sat, 16 Sep 2017 21:25:23 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 18287C21E10;\n\tSat, 16 Sep 2017 21:24:24 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 6DD7DC21E0E; Sat, 16 Sep 2017 21:24:15 +0000 (UTC)", "from mail-oi0-f44.google.com (mail-oi0-f44.google.com\n\t[209.85.218.44])\n\tby lists.denx.de (Postfix) with ESMTPS id 65566C21DD9\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 21:24:12 +0000 (UTC)", "by mail-oi0-f44.google.com with SMTP id w65so2364488oia.7\n\tfor <u-boot@lists.denx.de>; Sat, 16 Sep 2017 14:24:12 -0700 (PDT)", "from kiwi.bld.corp.google.com ([100.101.164.89])\n\tby smtp.gmail.com with ESMTPSA id\n\tr10sm3929969oib.23.2017.09.16.14.24.10\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 16 Sep 2017 14:24:10 -0700 (PDT)", "by kiwi.bld.corp.google.com (Postfix, from userid 121222)\n\tid 5B995140DF1; Sat, 16 Sep 2017 15:24:09 -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_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=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=P249bTci9aGo/OkqXb1uHWIExFkb699NDaXrfIbjgV4=;\n\tb=Ez2pgnvgmWeUeBjmqMxzdQXi7A26/WKLib+SAo98L4WeCSQvWmhRzFrAvsMxnY0sDW\n\tl7Lx1pOllz3ESJebKCXZgvFSMfxipuMq6ZitCqARqMEcOjIQ7JqcwEuYDHTqQGkUL8r9\n\tYNY+EB+B03XpMkzFJNbJHIv5lNB3+kkh51wW5AOdt/mj5JX1CT3uKNspRg/X9Yz3QkqN\n\t8+e+tsekUJvTDLPY0esCjn8UNHFmD6k7YRFQpSj3N9Gp+X3GaTD5R/PvxT/w9kZsLLI+\n\tZ4jKjcIBrtlTYp6YLrh/xWNqRtmnTrysXXK4oNwNMvk33KybgFKTQFiFseosrDYeRpQG\n\t8OJQ==", "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=P249bTci9aGo/OkqXb1uHWIExFkb699NDaXrfIbjgV4=;\n\tb=WWVFjeMwXFAPbGm2bOsS8PcfTy94PMVmQhtil5FZs/4fya7NYHF/Ql0/RBHpz3rcc8\n\t3NyyBhWiHyp6YFt7Wrm8f+Ywa2lfIoSBKffpYiVspc7nVXrQSWsmw8MYe1awmHAzfsuO\n\tSzCcY64mmScmgoASFEh3uLNjq4cOCu7MdU2No7HYMiChUkmq+9RAQIHzmxtdxRYxZpnj\n\t8QpaiXWn+ojafS7DobMaGHPXZBfogHDgeiSS9JdkAh3e5i8p4iaMdgKeJa2mIsvZkWq6\n\tdMYk3ar1CjkcO0WKvWpWqp4TE804d+pOOIBDkMYKtuyxOK64/Il7C59gz/9UDvN2IG5H\n\tUsug==", "X-Gm-Message-State": "AHPjjUgdpubzEfpgL63DkhkP81wgl5fRxQUWz9el5e2Ww7y381CRwkGs\n\tNaNokMp/hg1Nln42", "X-Google-Smtp-Source": "AOwi7QByZIAWxprcYHwAjYfd2Xm58+zezXsrZUjCK2aGp1CBttWgmg0dlC4VpiOkhq0a8AOIg19xfQ==", "X-Received": "by 10.202.83.23 with SMTP id h23mr28195530oib.226.1505597050891; \n\tSat, 16 Sep 2017 14:24:10 -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:22 -0600", "Message-Id": "<20170916212331.170463-10-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>,\n\tMaxime Ripard <maxime.ripard@free-electrons.com>,\n\tJagan Teki <jagan@openedev.com>", "Subject": "[U-Boot] [PATCH 09/13] log: Add a test command", "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 command which exercises the logging system.\n\nSigned-off-by: Simon Glass <sjg@chromium.org>\n---\n\n cmd/Kconfig | 3 +-\n cmd/log.c | 6 ++\n common/Kconfig | 10 +++\n include/log.h | 3 +\n test/Makefile | 1 +\n test/log/Makefile | 7 ++\n test/log/log_test.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n 7 files changed, 233 insertions(+), 1 deletion(-)\n create mode 100644 test/log/Makefile\n create mode 100644 test/log/log_test.c", "diff": "diff --git a/cmd/Kconfig b/cmd/Kconfig\nindex 702d4f251f..9d52e4fecc 100644\n--- a/cmd/Kconfig\n+++ b/cmd/Kconfig\n@@ -1483,7 +1483,8 @@ config CMD_LOG\n \thelp\n \t This provides access to logging features. It allows the output of\n \t log data to be controlled to a limited extent (setting up the default\n-\t maximum log level for emitting of records).\n+\t maximum log level for emitting of records). It also provides access\n+\t to a command used for testing the log system.\n \n config CMD_TRACE\n \tbool \"trace - Support tracing of function calls and timing\"\ndiff --git a/cmd/log.c b/cmd/log.c\nindex 44e04ab16a..1fc49c4cf2 100644\n--- a/cmd/log.c\n+++ b/cmd/log.c\n@@ -23,6 +23,9 @@ static int do_log_level(cmd_tbl_t *cmdtp, int flag, int argc,\n \n static cmd_tbl_t log_sub[] = {\n \tU_BOOT_CMD_MKENT(level, CONFIG_SYS_MAXARGS, 1, do_log_level, \"\", \"\"),\n+#ifdef CONFIG_LOG_TEST\n+\tU_BOOT_CMD_MKENT(test, 2, 1, do_log_level, \"\", \"\"),\n+#endif\n };\n \n static int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])\n@@ -46,6 +49,9 @@ static int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])\n #ifdef CONFIG_SYS_LONGHELP\n static char log_help_text[] =\n \t\"level - get/set log level\\n\"\n+#ifdef CONFIG_LOG_TEST\n+\t\"test - run log tests\\n\"\n+#endif\n \t;\n #endif\n \ndiff --git a/common/Kconfig b/common/Kconfig\nindex ba4578e870..57ce2cbe9a 100644\n--- a/common/Kconfig\n+++ b/common/Kconfig\n@@ -458,6 +458,16 @@ config LOG_SPL_CONSOLE\n \t log message is shown - other details like level, category, file and\n \t line number are omitted.\n \n+config LOG_TEST\n+\tbool \"Provide a test for logging\"\n+\tdepends on LOG\n+\tdefault y if SANDBOX\n+\thelp\n+\t This enables a 'log test' command to test logging. It is normally\n+\t executed from a pytest and simply outputs logging information\n+\t in various different ways to test that the logging system works\n+\t correctly with varoius settings.\n+\n endmenu\n \n config DTB_RESELECT\ndiff --git a/include/log.h b/include/log.h\nindex fb6a196202..f03ed94128 100644\n--- a/include/log.h\n+++ b/include/log.h\n@@ -263,6 +263,9 @@ struct log_filter {\n #define LOG_DRIVER(_name) \\\n \tll_entry_declare(struct log_driver, _name, log_driver)\n \n+/* Handle the 'log test' command */\n+int do_log_test(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);\n+\n /**\n * log_add_filter() - Add a new filter to a log device\n *\ndiff --git a/test/Makefile b/test/Makefile\nindex 6305afb211..40f2244b79 100644\n--- a/test/Makefile\n+++ b/test/Makefile\n@@ -10,3 +10,4 @@ obj-$(CONFIG_SANDBOX) += command_ut.o\n obj-$(CONFIG_SANDBOX) += compression.o\n obj-$(CONFIG_SANDBOX) += print_ut.o\n obj-$(CONFIG_UT_TIME) += time_ut.o\n+obj-$(CONFIG_$(SPL_)LOG) += log/\ndiff --git a/test/log/Makefile b/test/log/Makefile\nnew file mode 100644\nindex 0000000000..b0da8dee28\n--- /dev/null\n+++ b/test/log/Makefile\n@@ -0,0 +1,7 @@\n+#\n+# Copyright (c) 2017 Google, Inc\n+#\n+# SPDX-License-Identifier:\tGPL-2.0+\n+#\n+\n+obj-$(CONFIG_LOG_TEST) += log_test.o\ndiff --git a/test/log/log_test.c b/test/log/log_test.c\nnew file mode 100644\nindex 0000000000..c3d076491f\n--- /dev/null\n+++ b/test/log/log_test.c\n@@ -0,0 +1,204 @@\n+/*\n+ * Logging support test program\n+ *\n+ * Copyright (c) 2017 Google, Inc\n+ * Written by Simon Glass <sjg@chromium.org>\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#include <common.h>\n+\n+/* emit some sample log records in different ways, for testing */\n+static int log_run(enum log_category_t cat, const char *file)\n+{\n+\tint i;\n+\n+\tdebug(\"debug\\n\");\n+\terror(\"error\\n\");\n+\tfor (i = LOGL_FIRST; i < LOGL_COUNT; i++) {\n+\t\tlog(cat, i, \"log %d\\n\", i);\n+\t\t_log(cat, i, file, 100 + i, \"func\", \"_log %d\\n\", i);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int log_test(int testnum)\n+{\n+\tint ret;\n+\n+\tprintf(\"test %d\\n\", testnum);\n+\tswitch (testnum) {\n+\tcase 0: {\n+\t\t/* Check a category filter using the first category */\n+\t\tenum log_category_t cat_list[] = {\n+\t\t\tUCLASS_MMC, UCLASS_SPI, LOGC_NONE, LOGC_END\n+\t\t};\n+\n+\t\tret = log_add_filter(\"console\", cat_list, LOGL_MAX, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_MMC, \"file\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 1: {\n+\t\t/* Check a category filter using the second category */\n+\t\tenum log_category_t cat_list[] = {\n+\t\t\tUCLASS_MMC, UCLASS_SPI, LOGC_END\n+\t\t};\n+\n+\t\tret = log_add_filter(\"console\", cat_list, LOGL_MAX, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 2: {\n+\t\t/* Check a category filter that should block log entries */\n+\t\tenum log_category_t cat_list[] = {\n+\t\t\tUCLASS_MMC, LOGC_NONE, LOGC_END\n+\t\t};\n+\n+\t\tret = log_add_filter(\"console\", cat_list, LOGL_MAX, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 3: {\n+\t\t/* Check a passing file filter */\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, \"file\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 4: {\n+\t\t/* Check a failing file filter */\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, \"file\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file2\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 5: {\n+\t\t/* Check a passing file filter (second in list) */\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, \"file,file2\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file2\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 6: {\n+\t\t/* Check a passing file filter (also passing error()) */\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX,\n+\t\t\t\t \"file,file2,log/log_test.c\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file2\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 7: {\n+\t\t/* Check a log level filter */\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_WARN, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tlog_run(UCLASS_SPI, \"file\");\n+\t\tret = log_remove_filter(\"console\", ret);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 8: {\n+\t\t/* Check two filters, one of which passes everything */\n+\t\tint filt1, filt2;\n+\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_WARN, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tfilt1 = ret;\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, NULL);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tfilt2 = ret;\n+\t\tlog_run(UCLASS_SPI, \"file\");\n+\t\tret = log_remove_filter(\"console\", filt1);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tret = log_remove_filter(\"console\", filt2);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\tcase 9: {\n+\t\t/* Check three filters, which together pass everything */\n+\t\tint filt1, filt2, filt3;\n+\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, \"file)\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tfilt1 = ret;\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX, \"file2\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tfilt2 = ret;\n+\t\tret = log_add_filter(\"console\", NULL, LOGL_MAX,\n+\t\t\t\t \"log/log_test.c\");\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tfilt3 = ret;\n+\t\tlog_run(UCLASS_SPI, \"file2\");\n+\t\tret = log_remove_filter(\"console\", filt1);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tret = log_remove_filter(\"console\", filt2);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tret = log_remove_filter(\"console\", filt3);\n+\t\tif (ret < 0)\n+\t\t\treturn ret;\n+\t\tbreak;\n+\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+#ifdef CONFIG_LOG_TEST\n+int do_log_test(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])\n+{\n+\tint testnum = 0;\n+\tint ret;\n+\n+\tif (argc > 1)\n+\t\ttestnum = simple_strtoul(argv[1], NULL, 10);\n+\n+\tret = log_test(testnum);\n+\tif (ret)\n+\t\tprintf(\"Test failure (err=%d)\\n\", ret);\n+\n+\treturn ret ? CMD_RET_FAILURE : 0;\n+}\n+#endif\n", "prefixes": [ "U-Boot", "09/13" ] }