aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddie Hung <eddie@fpgeh.com>2020-05-14 15:30:08 -0700
committerGitHub <noreply@github.com>2020-05-14 15:30:08 -0700
commit07eecff9cca555086667666c4dbdb4c6a7133c67 (patch)
tree7dff8b2a9a5eb2797f8195000f473649d87240e2
parent7b3a4a1fff297481a463f27da250af8436041753 (diff)
parent425867d175f465a7568e146ef4d23bd975d9c55c (diff)
downloadyosys-07eecff9cca555086667666c4dbdb4c6a7133c67.tar.gz
yosys-07eecff9cca555086667666c4dbdb4c6a7133c67.tar.bz2
yosys-07eecff9cca555086667666c4dbdb4c6a7133c67.zip
Merge pull request #2055 from YosysHQ/eddie/logger_multiple
logger: fix for multiple calls with same pattern
-rw-r--r--passes/cmds/logger.cc43
1 files changed, 36 insertions, 7 deletions
diff --git a/passes/cmds/logger.cc b/passes/cmds/logger.cc
index 9a27952d4..50b89d92f 100644
--- a/passes/cmds/logger.cc
+++ b/passes/cmds/logger.cc
@@ -58,7 +58,8 @@ struct LoggerPass : public Pass {
log(" do not print warnings for the specified experimental feature\n");
log("\n");
log(" -expect <type> <regex> <expected_count>\n");
- log(" expect log,warning or error to appear. In case of error return code is 0.\n");
+ log(" expect log, warning or error to appear. matched errors will terminate\n");
+ log(" with exit code 0.\n");
log("\n");
log(" -expect-no-warnings\n");
log(" gives error in case there is at least one warning that is not expected.\n");
@@ -158,12 +159,40 @@ struct LoggerPass : public Pass {
log_cmd_error("Expected error message occurrences must be 1 !\n");
log("Added regex '%s' for warnings to expected %s list.\n", pattern.c_str(), type.c_str());
try {
- if (type=="error")
- log_expect_error.push_back(std::make_pair(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)));
- else if (type=="warning")
- log_expect_warning.push_back(std::make_pair(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)));
- else
- log_expect_log.push_back(std::make_pair(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count)));
+ if (type=="error") {
+ auto it = log_expect_error.begin();
+ auto ie = log_expect_error.end();
+ for (; it != ie; it++)
+ if (it->second.pattern == pattern) {
+ it->second.expected_count = count;
+ break;
+ }
+ if (it == ie)
+ log_expect_error.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count));
+ }
+ else if (type=="warning") {
+ auto it = log_expect_warning.begin();
+ auto ie = log_expect_warning.end();
+ for (; it != ie; it++)
+ if (it->second.pattern == pattern) {
+ it->second.expected_count = count;
+ break;
+ }
+ if (it == ie)
+ log_expect_warning.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count));
+ }
+ else if (type=="log") {
+ auto it = log_expect_log.begin();
+ auto ie = log_expect_log.end();
+ for (; it != ie; it++)
+ if (it->second.pattern == pattern) {
+ it->second.expected_count = count;
+ break;
+ }
+ if (it == ie)
+ log_expect_log.emplace_back(YS_REGEX_COMPILE(pattern), LogExpectedItem(pattern, count));
+ }
+ else log_abort();
}
catch (const YS_REGEX_NS::regex_error& e) {
log_cmd_error("Error in regex expression '%s' !\n", pattern.c_str());