fix(lib): percent limits render as configured; xcelib_test counts every failure again

test_fmt_limit_units_percent_limit_ignores_units_mode failed on every
run: fmt_limit_units() widened the float limit value before scaling it,
so 0.8 printed as "80.000001%". The product is now taken in float and
widened after, which gives the configured 80.

The failure never counted: test_libxce_retry(), one group of test.c's
single runner, ran its own UNITY_BEGIN()/UNITY_END(), which reset Unity's
counters -- every failure in a group before it was dropped and
xcelib_test exited 0. With the pair removed the runner reports 695 tests;
this was the only hidden failure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-29 10:31:54 +00:00
parent b5712c053d
commit 9c51de88c6
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
2 changed files with 7 additions and 3 deletions

View file

@ -1847,9 +1847,11 @@ static void test_ff_call_is_single_shot_no_budget(void)
/* ── Suite entry point ──────────────────────────────────────────────── */
/* Runs inside test.c's single UNITY_BEGIN()/UNITY_END(). Its own pair
* reset Unity's counters, so every failure of a group run before this one
* was dropped from the final count and xcelib_test still exited 0. */
void test_libxce_retry(void)
{
UNITY_BEGIN();
RUN_TEST(test_retry_defaults_are_reachable);
RUN_TEST(test_fake_masters_hold_three_candidates);
RUN_TEST(test_master_cursor_advances_and_wraps);
@ -1906,5 +1908,4 @@ void test_libxce_retry(void)
RUN_TEST(test_ff_call_is_single_shot_no_budget);
RUN_TEST(test_decide_not_ready_backs_off_on_same_controller);
RUN_TEST(test_retry_next_not_ready_does_not_rotate);
UNITY_END();
}

View file

@ -231,8 +231,11 @@ int fmt_limit_units(char* buf, int len, xce_limit_t* limit,
}
if (limit->val.percent != 0) {
/* val is a float: widen after scaling. 0.8f widened first is
* 0.800000011920929, which printed as "80.000001%"; the float
* product rounds to the 80 that was configured. */
rc = snprintf(buf + pos, len - pos, "\n%s = %f%%\n",
limit->val.resname, (double)limit->val.val * 100.0);
limit->val.resname, (double)(limit->val.val * 100.0f));
} else {
bool is_swp = (limit->val.resname != NULL)
&& (strcmp(limit->val.resname, "swp") == 0);