cups icon indicating copy to clipboard operation
cups copied to clipboard

testEndMessage failures do not update testsPassed

Open Shubham-Padkonde opened this issue 1 month ago • 1 comments

testEndMessage(false, ...) in cups/test-internal.h prints FAIL but does not set testsPassed to false. Programs that return testsPassed ? 0 : 1 can therefore report failures and still exit successfully. testEnd(false) does update this shared status.

Minimal reproduction against master 2fde0aa06044a596c77919a166b020819d7168ae:

#include "test-internal.h"

int main(void)
{
  testBegin("intentional failure");
  testEndMessage(false, "this should fail the process");
  return testsPassed ? 0 : 1;
}

Compile with cc -I cups repro.c -o repro, then run ./repro. It prints FAIL (this should fail the process) but exits 0. The expected exit status is 1.

I encountered this while running cups/testjson: its external HTTPS check printed a certificate-validation failure but make -C cups test still succeeded. A three-line change to mirror testEnd makes both the minimal reproduction and that existing failure return 1.

Four local harness cases cover a passing message, a failing message, a failure followed by a passing message, and the existing non-message failure path. The middle two fail before the change; all four have the expected exit statuses afterward.

Shubham-Padkonde avatar Oct 26 '26 13:10 Shubham-Padkonde

Please don't file both an issue and a PR for the same problem...

michaelrsweet avatar Oct 26 '26 14:10 michaelrsweet