-
Notifications
You must be signed in to change notification settings - Fork 1
Bug fix: allow user to pass dmesg.log for analysis #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
test/functional/test_run_plugins.py
Outdated
| collect_log_path = str(tmp_path / "collect_logs") | ||
| result = run_cli_command( | ||
| ["--log-path", collect_log_path, "run-plugins", "DmesgPlugin"], check=False | ||
| ) | ||
|
|
||
| output = result.stdout + result.stderr | ||
| assert result.returncode in [0, 1, 2] | ||
|
|
||
| dmesg_data_file = None | ||
| collect_path = Path(collect_log_path) | ||
|
|
||
| for log_dir in collect_path.glob("*"): | ||
| dmesg_plugin_dir = log_dir / "dmesg_plugin" / "dmesg_collector" | ||
| if dmesg_plugin_dir.exists(): | ||
| for dmesg_file in dmesg_plugin_dir.glob("dmesg*.log"): | ||
| dmesg_data_file = str(dmesg_file) | ||
| break | ||
|
|
||
| if not dmesg_data_file: | ||
| sample_dmesg_dir = tmp_path / "sample_data" | ||
| sample_dmesg_dir.mkdir(parents=True, exist_ok=True) | ||
| dmesg_data_file = str(sample_dmesg_dir / "dmesg.log") | ||
|
|
||
| sample_content = """[ 0.000000] Linux version 5.15.0-generic (buildd@lcy02-amd64-001) | ||
| [ 0.001000] Command line: BOOT_IMAGE=/boot/vmlinuz root=UUID=test ro quiet splash | ||
| [ 1.234567] pci 0000:00:01.0: BAR 0: failed to assign [mem size 0x01000000] | ||
| [ 2.345678] WARNING: CPU: 0 PID: 1 at drivers/test/test.c:123 test_function+0x123/0x456 | ||
| [ 3.456789] AMD-Vi: Event logged [IO_PAGE_FAULT device=00:14.0 domain=0x0000] | ||
| [ 4.567890] normal system message | ||
| [ 5.678901] ACPI Error: Method parse/execution failed | ||
| [ 10.123456] System is operational | ||
| """ | ||
| with open(dmesg_data_file, "w", encoding="utf-8") as f: | ||
| f.write(sample_content) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a sample dmesg file we should just create a file in the fixtures directory. It should also have iso timestamps like this:
| "2023-06-01T01:00:00,685236-05:00 test message1\n" |
test/functional/test_run_plugins.py
Outdated
| ) | ||
|
|
||
| output = result.stdout + result.stderr | ||
| assert result.returncode in [0, 1, 2], f"Unexpected return code: {result.returncode}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we checking for all these different return codes? The return code should be 1 if it was able to run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any of those indicates that it ran somehow, but yeah i can restrict it to 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry 0, if it ran successfully it should be 0
How to run:
This will analyze the dmesg.log specified by user and disable a new collection.