Skip to content

Commit 65111e9

Browse files
committed
functional test update
1 parent 8ab3f29 commit 65111e9

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/functional/test_plugin_configs.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,54 @@ def test_all_plugin_config_files_exist(plugin_config_files):
283283
config = json.load(f)
284284
assert "plugins" in config
285285
assert plugin_name in config["plugins"]
286+
287+
288+
def test_dmesg_plugin_collect_dmesg_log_false(run_cli_command, tmp_path):
289+
"""Test DmesgPlugin with collect_dmesg_log=false doesn't write dmesg.log."""
290+
config = {
291+
"name": "DmesgNoLogConfig",
292+
"desc": "DmesgPlugin config with collect_dmesg_log disabled",
293+
"global_args": {},
294+
"plugins": {"DmesgPlugin": {"collection_args": {"collect_dmesg_log": False}}},
295+
"result_collators": {},
296+
}
297+
config_file = tmp_path / "dmesg_no_log_config.json"
298+
config_file.write_text(json.dumps(config, indent=2))
299+
300+
log_path = str(tmp_path / "logs_dmesg_no_log")
301+
result = run_cli_command(
302+
["--log-path", log_path, "--plugin-configs", str(config_file)], check=False
303+
)
304+
305+
assert result.returncode in [0, 1, 2]
306+
307+
dmesg_plugin_dir = Path(log_path) / "dmesg_plugin" / "dmesg_collector"
308+
if dmesg_plugin_dir.exists():
309+
dmesg_log_files = list(dmesg_plugin_dir.glob("dmesg*.log"))
310+
assert (
311+
len(dmesg_log_files) == 0
312+
), f"Found dmesg log files when collect_dmesg_log=False: {dmesg_log_files}"
313+
314+
315+
def test_dmesg_plugin_collect_dmesg_log_true(run_cli_command, tmp_path):
316+
"""Test DmesgPlugin with collect_dmesg_log=true writes dmesg.log."""
317+
config = {
318+
"name": "DmesgWithLogConfig",
319+
"desc": "DmesgPlugin config with collect_dmesg_log enabled",
320+
"global_args": {},
321+
"plugins": {"DmesgPlugin": {"collection_args": {"collect_dmesg_log": True}}},
322+
"result_collators": {},
323+
}
324+
config_file = tmp_path / "dmesg_with_log_config.json"
325+
config_file.write_text(json.dumps(config, indent=2))
326+
327+
log_path = str(tmp_path / "logs_dmesg_with_log")
328+
result = run_cli_command(
329+
["--log-path", log_path, "--plugin-configs", str(config_file)], check=False
330+
)
331+
332+
if result.returncode in [0, 1]:
333+
dmesg_plugin_dir = Path(log_path) / "dmesg_plugin" / "dmesg_collector"
334+
if dmesg_plugin_dir.exists():
335+
dmesg_log_files = list(dmesg_plugin_dir.glob("dmesg*.log"))
336+
assert len(dmesg_log_files) > 0, "Expected dmesg.log file when collect_dmesg_log=True"

0 commit comments

Comments
 (0)