Skip to content

Commit

Permalink
Fixed the test result output path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
paull authored and squirrelsc committed Jan 19, 2024
1 parent ec16e8a commit a33db4a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions microsoft/testsuites/kselftest/kselftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,29 +204,34 @@ def run_all(
) -> List[KselftestResult]:
# Executing kselftest as root may cause
# VM to hang

# get username
username = self.node.tools[Whoami].get_username()
result_directory = f"/home/{username}"
if os.path.exists(result_directory) is False:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(result_directory)

result_file_name = "kselftest-results.txt"
result_file = f"{result_directory}/{result_file_name}"
self.run(
" 2>&1 | tee kselftest-results.txt",
f" 2>&1 | tee {result_file}",
sudo=run_test_as_root,
force_run=True,
shell=True,
timeout=timeout,
)

# get username
username = self.node.tools[Whoami].get_username()

# Allow read permissions for "others" to remote copy the file
# kselftest-results.txt
chmod = self.node.tools[Chmod]
chmod.update_folder(f"/home/{username}/kselftest-results.txt", "644", sudo=True)
chmod.update_folder(result_file, "644", sudo=True)

# copy kselftest-results.txt from remote to local node for processing results
remote_copy = self.node.tools[RemoteCopy]
remote_copy.copy_to_local(
PurePosixPath(f"/home/{username}/kselftest-results.txt"), PurePath(log_path)
)
remote_copy.copy_to_local(PurePosixPath(result_file), PurePath(log_path))

local_kselftest_results_path = PurePath(log_path) / "kselftest-results.txt"
local_kselftest_results_path = PurePath(log_path) / result_file_name

# parse results from local_kselftest_results_path file
# read the file
Expand Down

0 comments on commit a33db4a

Please sign in to comment.