Skip to content

test/cmocka: Build the tests against cmocka 1.1 - #2201

Merged
zackees merged 2 commits into
obs-rust:masterfrom
vpacher:fix/2197-cmocka-1.1
Oct 24, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
vpacher:fix/2197-cmocka-1.1

Conversation

@vpacher

@vpacher vpacher commented Oct 24, 2026

Copy link
Copy Markdown
Member

Fixes #2197

What and why

Four tests in test/cmocka did not build with cmocka 1.1.7, the version in Debian 13 and Ubuntu 24.04/25.10. CI did not see this, because its Ubuntu 26.04 has cmocka 2.0.2. This PR does option A, as decided on #2197:

  • test_obs_ffmpeg_net_host.c includes <stdbool.h>. The cmocka 2.x cmocka.h includes it; the 1.1.7 cmocka.h does not.
  • New test/cmocka/cmocka-compat.h defines assert_int_in_range() with assert_in_range(), under #ifndef assert_int_in_range. With cmocka 2.x it does nothing. The 3 XComposite tests include it. All 5 ranges have a minimum of 0 or more, so the unsigned compare of 1.1 gives the same result.
  • find_package(CMocka 1.1 CONFIG REQUIRED). The config-version files of 1.1.7 and 2.0.2 both use AnyNewerVersion, so both accept the request.
  • New ci/test_cmocka_compat.py, so that this does not come back: it fails for each use of a cmocka 2.x-only name in test/cmocka (140 public names that the 2.0.2 cmocka.h has and the 1.1.7 cmocka.h does not), unless the file includes cmocka-compat.h and the header maps the name. It runs with the other ci/test_*.py files.

RED → GREEN

  • RED commit: faea4f1. ci/test_cmocka_compat.py: 1 of 2 fails, with the 5 assert_int_in_range() uses in the 3 XComposite tests. On Debian 13 (gcc 14.2, libcmocka-dev 1.1.7-3+b1), cmocka-tests with -k 0: 4 objects fail ('true' undeclared, and 3 × implicit declaration of assert_int_in_range).
  • GREEN: eb21f32. ci/test_cmocka_compat.py: 2 of 2 pass. On Debian 13, configure accepts cmocka 1.1.7, and all of cmocka-tests builds (0 failures). Under ctest and Xvfb, test_obs_ffmpeg_net_host 3/3, test_xcomposite_presence 4/4, test_xcomposite_search_backoff 4/4, test_xcomposite_window_events 1/1 and test_xcomposite_error_replies 2/2 pass. PR CI covers cmocka 2.x.
  • Real app: N/A (tests and CI only).

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: not applicable (no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port

Notes:

  • clang-format and gersemi (ci/local_gate.py --only clang-format --only gersemi) pass. The whole ci/test_*.py suite on macOS gives the same 47 failures and errors as master (environment), and no new ones.
  • Not checked statically: a C test that uses true/false must reach <stdbool.h> itself. A static include scan gave 22 false positives on master, so only a build against cmocka 1.1.7 shows this reliably. A Tier 2 build against 1.1.7 (for example in a debian:13 container) is the optional follow-up that bug: test/cmocka: 4 tests do not build with cmocka 1.1.7 (Debian 13, Ubuntu 24.04) #2197 names; it is not in this PR.

AI note: Claude Code (Claude Opus 5.5) wrote the code, the check, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

vpacher and others added 2 commits October 24, 2026 21:00
…t#2197)

Debian 13 and Ubuntu 24.04/25.10 ship cmocka 1.1.7. CI's Ubuntu 26.04
has 2.0.2, so a test that uses a name new in cmocka 2.0 builds in CI but
not on those systems. Three XComposite tests use assert_int_in_range(),
which cmocka 1.1.7 does not have.

The check fails for each use of a cmocka 2.x-only name in test/cmocka,
unless the file includes cmocka-compat.h and that header maps the name.
It fails now for the 5 assert_int_in_range() uses.

Refs obs-rust#2197

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four tests did not build with cmocka 1.1.7, the version in Debian 13 and
Ubuntu 24.04/25.10:

- test_obs_ffmpeg_net_host.c used true without <stdbool.h>. The cmocka
  2.x cmocka.h includes it; the 1.1.7 cmocka.h does not.
- The three XComposite tests used assert_int_in_range(), which is new in
  cmocka 2.0.

cmocka-compat.h defines assert_int_in_range() with assert_in_range() when
cmocka does not define it, so it does nothing with cmocka 2.x. All 5
ranges have a minimum of 0 or more, so the unsigned compare of 1.1 gives
the same result. find_package() now asks for cmocka 1.1 or newer (both
1.1.7 and 2.0.2 accept any newer version request).

ci/test_cmocka_compat.py passes.

Fixes obs-rust#2197

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher requested a review from zackees as a code owner October 24, 2026 19:11
@zackees
zackees added this pull request to the merge queue Oct 24, 2026
Merged via the queue into obs-rust:master with commit 23f1ec9 Oct 24, 2026
37 checks passed
@vpacher
vpacher deleted the fix/2197-cmocka-1.1 branch October 24, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: test/cmocka: 4 tests do not build with cmocka 1.1.7 (Debian 13, Ubuntu 24.04)

2 participants