From 8dd67f63209637e345a4aabf6341db288ea61f05 Mon Sep 17 00:00:00 2001 From: Yoshihiro Misawa Date: Mon, 21 Sep 2026 09:11:12 +0900 Subject: [PATCH] fix: export lifecycle status in shared libraries --- .github/workflows/native-dev.yml | 9 +++++++++ src/symbols.cmake | 1 + test/CMakeLists.txt | 7 +++++++ test/LIFECYCLE.ja.md | 3 +++ 4 files changed, 20 insertions(+) diff --git a/.github/workflows/native-dev.yml b/.github/workflows/native-dev.yml index fbdb1fa..e5ef7bd 100644 --- a/.github/workflows/native-dev.yml +++ b/.github/workflows/native-dev.yml @@ -63,6 +63,15 @@ jobs: run: ctest --preset cxx20 -R '^cxx20-library-features$' -V - name: Install smoke test run: cmake --install build/${{ matrix.preset }} --prefix build/install + - name: Configure shared-library lifecycle test + if: matrix.preset == 'release' + run: cmake -S . -B build/shared-lifecycle -DBUILD_SHARED_LIBS=ON -DBUILD_BINARY=OFF -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release + - name: Build shared-library lifecycle test + if: matrix.preset == 'release' + run: cmake --build build/shared-lifecycle --config Release --target uchardet-lifecycle --parallel 2 + - name: Test shared-library lifecycle + if: matrix.preset == 'release' + run: ctest --test-dir build/shared-lifecycle -C Release -R '^native-lifecycle$' --output-on-failure --no-tests=error diagnostics: runs-on: ubuntu-24.04 diff --git a/src/symbols.cmake b/src/symbols.cmake index 995012b..af5d53b 100644 --- a/src/symbols.cmake +++ b/src/symbols.cmake @@ -5,6 +5,7 @@ set( uchardet_handle_data uchardet_data_end uchardet_reset + uchardet_is_done uchardet_get_charset uchardet_get_n_candidates uchardet_get_encoding diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4394d91..605b3de 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,6 +24,13 @@ set_target_properties( add_executable(uchardet-lifecycle uchardet-lifecycle.cpp) target_link_libraries(uchardet-lifecycle ${UCHARDET_LIBRARY}) +if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(TARGET uchardet-lifecycle POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + VERBATIM) +endif() add_test(NAME native-lifecycle COMMAND uchardet-lifecycle) set_tests_properties(native-lifecycle PROPERTIES TIMEOUT 10) diff --git a/test/LIFECYCLE.ja.md b/test/LIFECYCLE.ja.md index df0e174..9aaad5a 100644 --- a/test/LIFECYCLE.ja.md +++ b/test/LIFECYCLE.ja.md @@ -23,6 +23,9 @@ ctest --test-dir /disk/lifecycle-build -R '^native-lifecycle$' --output-on-failu ``` CTest timeoutは10秒。標準engineや公開APIを変更しない。 +CIではstatic presetに加え、Linux/macOS/WindowsのRelease shared libraryにも +同じtestをリンクして実行する。既存の公開関数`uchardet_is_done`がGNU/Darwinの +export一覧から漏れていた問題を修正し、shared構成のリンク回帰も検出する。 error/OOM注入、arbitrary-byte fuzz、大入力、並列利用、language weightの全契約は未対象。 nativeの繰返しfinalizeやfinalize後feedについては、Python wrapperが呼出しを抑止する 挙動とnative C APIの保証を混同せず、今回のtestで保証を追加しない。