Use regex to match __init__.py instead of hacking it in verify_log_lines()
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <ctype.h>
|
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@@ -2,9 +2,9 @@ __init__ @ SRC_DIR/example_debugging.py:58 calls C function:
|
|||||||
sudo.debug was called with arguments: (<DEBUG.ERROR: 2>, 'My demo purpose plugin shows this ERROR level debug message')
|
sudo.debug was called with arguments: (<DEBUG.ERROR: 2>, 'My demo purpose plugin shows this ERROR level debug message')
|
||||||
__init__ @ SRC_DIR/example_debugging.py:63 calls C function:
|
__init__ @ SRC_DIR/example_debugging.py:63 calls C function:
|
||||||
sudo.debug was called with arguments: (<DEBUG.INFO: 6>, 'My demo purpose plugin shows this INFO level debug message')
|
sudo.debug was called with arguments: (<DEBUG.INFO: 6>, 'My demo purpose plugin shows this INFO level debug message')
|
||||||
handle @ logging/__init__.py calls C function:
|
handle @ .*/logging/__init__.py:[0-9]* calls C function:
|
||||||
LogHandler.emit was called with arguments: (<sudo.LogHandler <stderr> (NOTSET)>, <LogRecord: root, 40, SRC_DIR/example_debugging.py, 72, "Python log system shows this ERROR level debug message">)
|
LogHandler.emit was called with arguments: (<sudo.LogHandler <stderr> (NOTSET)>, <LogRecord: root, 40, SRC_DIR/example_debugging.py, 72, "Python log system shows this ERROR level debug message">)
|
||||||
handle @ logging/__init__.py calls C function:
|
handle @ .*/logging/__init__.py:[0-9]* calls C function:
|
||||||
LogHandler.emit was called with arguments: (<sudo.LogHandler <stderr> (NOTSET)>, <LogRecord: root, 20, SRC_DIR/example_debugging.py, 73, "Python log system shows this INFO level debug message">)
|
LogHandler.emit was called with arguments: (<sudo.LogHandler <stderr> (NOTSET)>, <LogRecord: root, 20, SRC_DIR/example_debugging.py, 73, "Python log system shows this INFO level debug message">)
|
||||||
__init__ @ SRC_DIR/example_debugging.py:85 calls C function:
|
__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'),)
|
sudo.options_as_dict was called with arguments: (('ModulePath=SRC_DIR/example_debugging.py', 'ClassName=DebugDemoPlugin'),)
|
||||||
|
@@ -2,7 +2,7 @@ __init__ @ SRC_DIR/example_debugging.py:58 debugs:
|
|||||||
My demo purpose plugin shows this ERROR level debug message
|
My demo purpose plugin shows this ERROR level debug message
|
||||||
__init__ @ SRC_DIR/example_debugging.py:63 debugs:
|
__init__ @ SRC_DIR/example_debugging.py:63 debugs:
|
||||||
My demo purpose plugin shows this INFO level debug message
|
My demo purpose plugin shows this INFO level debug message
|
||||||
handle @ logging/__init__.py debugs:
|
handle @ .*/logging/__init__.py:[0-9]* debugs:
|
||||||
Python log system shows this ERROR level debug message
|
Python log system shows this ERROR level debug message
|
||||||
handle @ logging/__init__.py debugs:
|
handle @ .*/logging/__init__.py:[0-9]* debugs:
|
||||||
Python log system shows this INFO level debug message
|
Python log system shows this INFO level debug message
|
||||||
|
@@ -190,26 +190,10 @@ verify_log_lines(const char *reference_path)
|
|||||||
char line[1024] = "";
|
char line[1024] = "";
|
||||||
char stored_str[MAX_OUTPUT] = "";
|
char stored_str[MAX_OUTPUT] = "";
|
||||||
while(fgets(line, sizeof(line), file) != NULL) {
|
while(fgets(line, sizeof(line), file) != NULL) {
|
||||||
char *line_data = strstr(line, "] "); // this skips the timestamp and pid at the beginning
|
const char *line_data = strstr(line, "] "); // this skips the timestamp and pid at the beginning
|
||||||
VERIFY_NOT_NULL(line_data); // malformed log line
|
VERIFY_NOT_NULL(line_data); // malformed log line
|
||||||
line_data += 2;
|
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
|
char *line_end = strstr(line_data, " object at "); // this skips checking the pointer hex
|
||||||
if (line_end)
|
if (line_end)
|
||||||
snprintf(line_end, sizeof(line) - (line_end - line), " object>\n");
|
snprintf(line_end, sizeof(line) - (line_end - line), " object>\n");
|
||||||
|
Reference in New Issue
Block a user