gfx_thumbnail_status_atomic: make the documented STRESS_ITERS override usable

The file tells you the iteration count is "Overridable
(-DSTRESS_ITERS=...) for constrained environments", but the Makefile
gives you nowhere to put it.  The only lever is CFLAGS=, and a
command-line CFLAGS= replaces every += the Makefile does rather than
adding to it -- so following the advice silently drops -DHAVE_THREADS,
and the run reports

    [pass] STORE/LOAD round-trip on all four status values
    [skip] HAVE_THREADS not defined; static checks only
    ALL OK

exiting 0 with the entire stress section switched off.  The skip line
is there, to the test's credit, but "ALL OK" and a zero exit are what a
CI job looks at.

Add an EXTRA_CFLAGS hook and point the comment at it.  The measured
costs go in the comment too, since the reason to reach for the knob is
always the same:

    20000    2.9 s
    100000   14.4 s
    250000   36 s
    1000000  ~145 s   (the default)

all on a single core.

Found while running every sample in samples/ end to end after the
vulkan validation one turned out to be passing without reaching a
device.  That was a test that checked nothing; this is a documented
escape hatch that turns the test off if you use it as documented.  Same
family.
This commit is contained in:
LibretroAdmin authored and libretroadmin committed 2026-07-29 00:23:33 +02:00
1 parent e8c3497a2c
commit 247654dde6
2 files changed
+26 -4

No files matched your search

@@ -29,6 +29,17 @@ ifeq ($(HAVE_THREADS),1)
LDFLAGS += -lrt
endif
# Extra flags for the caller, e.g. the -DSTRESS_ITERS= override the
# test documents:
#
# make EXTRA_CFLAGS=-DSTRESS_ITERS=20000
#
# Passing those through CFLAGS= instead would clobber everything set
# above, -DHAVE_THREADS included, and the test would quietly report
# "[skip] HAVE_THREADS not defined; static checks only" while still
# exiting 0 -- a pass with the whole stress section switched off.
CFLAGS += $(EXTRA_CFLAGS)
OBJS := $(SOURCES:.c=.o)
ifneq ($(SANITIZER),)
@@ -214,10 +214,21 @@ typedef char _gfx_thumb_status_size_check[
* out a missing-barrier bug under TSan within a few seconds; on
* real weak-memory hardware (qemu-aarch64) it surfaces faster.
* Adjust upward if the bug becomes harder to reproduce.
* Overridable (-DSTRESS_ITERS=...) for constrained environments:
* the lock-step handshake costs scheduler timeslices per
* iteration on a single-CPU host, and TSan's happens-before
* detection does not depend on the count. */
* Overridable for constrained environments: the lock-step
* handshake costs scheduler timeslices per iteration on a
* single-CPU host, and TSan's happens-before detection does not
* depend on the count. Pass it through the Makefile's
* EXTRA_CFLAGS, not CFLAGS:
*
* make EXTRA_CFLAGS=-DSTRESS_ITERS=20000
*
* CFLAGS= on the command line replaces everything the Makefile
* sets, -DHAVE_THREADS included, and the run then reports
* "[skip] HAVE_THREADS not defined" and exits 0 with the whole
* stress section switched off.
*
* Measured on one core: 2.9 s at 20000, 14.4 s at 100000, 36 s
* at 250000, ~145 s at the default. */
#ifndef STRESS_ITERS
#define STRESS_ITERS 1000000
#endif