Skip to content

tests: fix linking of ai unit tests - #21761

Open
da-phil wants to merge 2 commits into
darktable-org:masterfrom
da-phil:add_missing_ai_unittest_stubs
Open

tests: fix linking of ai unit tests#21761
da-phil wants to merge 2 commits into
darktable-org:masterfrom
da-phil:add_missing_ai_unittest_stubs

Conversation

@da-phil

@da-phil da-phil commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The ai unit tests have grown since a while, however five stubs in the AI backend had been missing for a successful unit test build (dt_conf_get_bool/get_int/key_exists, dt_control_log, dt_loc_get_user_cache_dir). This requires building darktable via -DBUILD_TESTING=ON -DUSE_AI=ON.
Also made dt_conf_get_string key-aware so ort_library_path isn't mistaken for a real path, and pinned the test's XDG_DATA_HOME and LD_LIBRARY_PATH so it doesn't depend on the developer's machine.

To prevent such a breakage I went ahead and added one Linux matrix entry in our gitlab ci pipenline with target "build", the branch of ci-script.sh that sets BUILD_TESTING=ON and calls ctest, which no matrix entry had ever selected.

See successful run in CI:

image

CC: @andriiryzhkov

Disclaimer: this work has been co-created with Claude.

da-phil added 2 commits August 8, 2026 14:40
dt_stubs.c had not kept up with the AI backend: add the missing
dt_conf_get_bool, dt_conf_get_int, dt_conf_key_exists, dt_control_log
and dt_loc_get_user_cache_dir stubs.

Make dt_conf_get_string key-aware -- returning "cpu" for every key made
_init_ort_api() treat plugins/ai/ort_library_path as a custom library
path and fail to load ONNX Runtime.

Give the test a fixed environment: an empty XDG_DATA_HOME so locally
installed models do not leak into the model discovery assertions, and
LD_LIBRARY_PATH for the bundled ORT, which is lazy-loaded by bare
filename.
Every matrix entry used the skiptest target, so BUILD_TESTING was never
configured and the unit tests were neither compiled nor run. Add one
Linux entry with target: build, which enables them and calls ctest.

cmocka is a hard requirement of BUILD_TESTING, so add libcmocka-dev to
the package list. The new entry shares distro, compiler and build type
with an existing one, hence the name suffix; it is undefined for the
other entries, so their job names are unchanged.
@da-phil

da-phil commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Turns out I need #21752 to be merged first, to make it possible to build cmocka unit tests with the recent version of cmocka which is part of the ubuntu 26.04 build environment.

/__w/darktable/darktable/src/src/tests/unittests/iop/test_filmicrgb.c: In function '__wrap_dt_iop_color_picker_reset':
/__w/darktable/darktable/src/src/tests/unittests/iop/test_filmicrgb.c:57:3: error: 'cmocka_macro' is deprecated: check_expected: use check_expected_int or check_expected_uint instead [-Werror=deprecated-declarations]
   57 |   check_expected(update);
      |   ^~~~~~~~~~~~~~

Will cherry-pick the fixing commit 721fbeb in the meantime.

EDIT: and removed it again.

@da-phil
da-phil marked this pull request as ready for review August 8, 2026 13:39
@da-phil
da-phil force-pushed the add_missing_ai_unittest_stubs branch from 5dc4307 to 93bd1e9 Compare August 8, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant