Skip to content

Commit a65d43b

Browse files
LiliDengsquirrelsc
authored andcommitted
Fix verify_bash_history_is_empty when .bash_history doesn't exist.
1 parent ec92914 commit a65d43b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

microsoft/testsuites/core/azure_image_standard.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,11 @@ def verify_serial_console_is_enabled(self, node: Node) -> None:
582582
use_new_environment=True,
583583
)
584584
def verify_bash_history_is_empty(self, node: Node) -> None:
585-
cat = node.tools[Cat]
586-
path_bash_history = node.get_pure_path("/root/.bash_history")
587-
if path_bash_history:
588-
bash_history = cat.read(str(path_bash_history), sudo=True)
585+
path_bash_history = "/root/.bash_history"
586+
cmd_result = node.execute(f"ls -lt {path_bash_history}", sudo=True, shell=True)
587+
if 0 == cmd_result.exit_code:
588+
cat = node.tools[Cat]
589+
bash_history = cat.read(path_bash_history, sudo=True)
589590
assert_that(bash_history).described_as(
590591
"/root/.bash_history is not empty, this image is not prepared well."
591592
).is_empty()

0 commit comments

Comments
 (0)