diff --git a/plugins/python/regress/iohelpers.h b/plugins/python/regress/iohelpers.h index b2383af76..88879f7eb 100644 --- a/plugins/python/regress/iohelpers.h +++ b/plugins/python/regress/iohelpers.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/plugins/python/regress/testdata/check_example_debugging_c_calls@info.log b/plugins/python/regress/testdata/check_example_debugging_c_calls@info.log index 9fe592ca7..9691f7e18 100644 --- a/plugins/python/regress/testdata/check_example_debugging_c_calls@info.log +++ b/plugins/python/regress/testdata/check_example_debugging_c_calls@info.log @@ -2,9 +2,9 @@ __init__ @ SRC_DIR/example_debugging.py:58 calls C function: sudo.debug was called with arguments: (, 'My demo purpose plugin shows this ERROR level debug message') __init__ @ SRC_DIR/example_debugging.py:63 calls C function: sudo.debug was called with arguments: (, 'My demo purpose plugin shows this INFO level debug message') -handle @ /usr/lib/python3.7/logging/__init__.py:894 calls C function: +handle @ logging/__init__.py calls C function: LogHandler.emit was called with arguments: ( (NOTSET)>, ) -handle @ /usr/lib/python3.7/logging/__init__.py:894 calls C function: +handle @ logging/__init__.py calls C function: LogHandler.emit was called with arguments: ( (NOTSET)>, ) __init__ @ SRC_DIR/example_debugging.py:85 calls C function: sudo.options_as_dict was called with arguments: (('ModulePath=SRC_DIR/example_debugging.py', 'ClassName=DebugDemoPlugin'),) diff --git a/plugins/python/regress/testdata/check_example_debugging_plugin@info.log b/plugins/python/regress/testdata/check_example_debugging_plugin@info.log index 4055d64c5..ed72f35ff 100644 --- a/plugins/python/regress/testdata/check_example_debugging_plugin@info.log +++ b/plugins/python/regress/testdata/check_example_debugging_plugin@info.log @@ -2,7 +2,7 @@ __init__ @ SRC_DIR/example_debugging.py:58 debugs: My demo purpose plugin shows this ERROR level debug message __init__ @ SRC_DIR/example_debugging.py:63 debugs: My demo purpose plugin shows this INFO level debug message -handle @ /usr/lib/python3.7/logging/__init__.py:894 debugs: +handle @ logging/__init__.py debugs: Python log system shows this ERROR level debug message -handle @ /usr/lib/python3.7/logging/__init__.py:894 debugs: +handle @ logging/__init__.py debugs: Python log system shows this INFO level debug message diff --git a/plugins/python/regress/testhelpers.c b/plugins/python/regress/testhelpers.c index dd7f3bc97..a750151b8 100644 --- a/plugins/python/regress/testhelpers.c +++ b/plugins/python/regress/testhelpers.c @@ -191,10 +191,26 @@ verify_log_lines(const char *reference_path) char line[1024] = ""; char stored_str[MAX_OUTPUT] = ""; while(fgets(line, sizeof(line), file) != NULL) { - const char *line_data = strstr(line, "] "); // this skips the timestamp and pid at the beginning + char *line_data = strstr(line, "] "); // this skips the timestamp and pid at the beginning VERIFY_NOT_NULL(line_data); // malformed log line line_data += 2; + /* handle @ /usr/lib/python3.7/logging/__init__.py:894 ... */ + if (strncmp(line_data, "handle @ /", sizeof("handle @ /") - 1) == 0) { + /* Remove python path and line number */ + char *cp = line_data + sizeof("handle @ ") - 1; + char *ep = strstr(cp, "logging/"); + if (ep != NULL) { + memmove(cp, ep, strlen(ep) + 1); + if ((cp = strstr(cp, "py:")) != NULL) { + cp += 2; + for (ep = cp + 1; isdigit((unsigned char)*ep); ep++) + continue; + memmove(cp, ep, strlen(ep) + 1); + } + } + } + char *line_end = strstr(line_data, " object at "); // this skips checking the pointer hex if (line_end) sprintf(line_end, " object>\n");