From f8618ce74695dee7d490966fcfc8b4c4933b13c3 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Thu, 24 Sep 2026 10:24:54 -0300 Subject: [PATCH] test(xcat-core): an assertion about /run could not tell who wrote there The error-command test ended with [ ! -e /run/testnode-logs.tar ] meant to show the archive had not gone to the default path. It cannot show that. The file may exist for reasons that have nothing to do with this test, in which case the assertion fails while nothing is wrong; and its absence would be equally true if the override had never worked at all. It answers a question about the host, not about the run. The positive assertion above it already carries the proof: the tar shadow writes a marker, and the test greps for that marker in the path it passed. The output being there is what shows the redirection went there. Removing it changes nothing about what the test catches. With the override taken out of the template, so the archive path is hard-coded again, the remaining assertion still fails. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- .../bats/ubuntu_subiquity_error_commands.bats | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xCAT-test/bats/ubuntu_subiquity_error_commands.bats b/xCAT-test/bats/ubuntu_subiquity_error_commands.bats index 677a7be3c..250f27833 100644 --- a/xCAT-test/bats/ubuntu_subiquity_error_commands.bats +++ b/xCAT-test/bats/ubuntu_subiquity_error_commands.bats @@ -43,7 +43,7 @@ error_commands() # Shadowing a command does not stop the shell opening the file the command redirects into: the # redirection is the shell's, and it happens whether or not tar runs. So the archive path is # taken from the environment too, and pointed inside the test's own directory. Without that, -# this test truncates /run/testnode-logs.tar on the host running it, and CI runs as root. +# this test would truncate /run/-logs.tar on the host running it, and CI runs as root. run_error_commands() { local script="${BATS_TEST_TMPDIR}/error-commands.sh" command @@ -83,12 +83,10 @@ run_error_commands() run run_error_commands [ "$status" -ne 124 ] - # The archive command redirects into the path it was given, so its output is the proof - # that the redirection went there and not to the default under /run. + # The archive command redirects into the path it was given, so its output IS the proof + # that the redirection went there and not to the default under /run. There is nothing to + # add by looking at the default path: whether /run/testnode-logs.tar exists says nothing + # about this test, because anything else may have created it, and its absence would be + # just as true had the override never worked. grep -q XCAT_LOGS_ARCHIVE "$ARCHIVE" - - # And the default path is untouched. This assertion is what an unprivileged run cannot - # make for itself -- there the write fails silently and "exit 0" hides it -- but CI runs - # as root, where the same redirection truncates the file. - [ ! -e /run/testnode-logs.tar ] }