Tests: Simplify t_runflag_logfile_open_bad.py (#7669)

Fixes #7667
This commit is contained in:
Tracy Narine 2026-05-28 12:43:07 -04:00 committed by GitHub
parent 70045433c9
commit f52fb1f1db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 16 deletions

View File

@ -1,2 +1,2 @@
%Error: Logfile obj_vlt/t_runflag_logfile_open_bad/logfile.log cannot be created
%Error: Logfile /does-not-exist/badfile.log cannot be created
Aborting...

View File

@ -7,29 +7,18 @@
# SPDX-FileCopyrightText: 2026 Wilson Snyder
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import os
import stat
import vltest_bootstrap
test.scenarios('vlt')
test.compile()
badfile = "/does-not-exist/badfile.log"
logfile = test.obj_dir + "/logfile.log"
capturefile = test.obj_dir + "/capture.log"
# Create the logfile
with open(logfile, 'w', encoding='utf8') as f:
f.write("Read-only logfile\n")
# Change permission to read only so execute() fail when creating the logfile
os.chmod(logfile, stat.S_IREAD)
log_flags = '+verilator+log+file+' + badfile
test.execute(all_run_flags=[log_flags, ">", logfile, "2>&1"], fails=True)
log_flags = '+verilator+log+file+' + logfile
test.execute(all_run_flags=[log_flags, ">", capturefile, "2>&1"], fails=True)
# Set read + write so test does not fail next time it is run
os.chmod(logfile, stat.S_IREAD | stat.S_IWRITE)
test.files_identical(capturefile, test.golden_filename)
test.files_identical(logfile, test.golden_filename)
test.passes()