Skip to content

build: set LIBSSH2_TESTS macro for all tests - #2417

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:b-tests-macro
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:b-tests-macro

Conversation

@vszakats

@vszakats vszakats commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

To apply to all test apps. Prior to this patch it was set for fixtures only.

Ref: #2408 (comment)

To apply to all test apps. Replacing the macro set for fixtures only.

Ref: libssh2#2408 (comment)
Copilot AI review requested due to automatic review settings July 23, 2026 20:39
@vszakats vszakats changed the title build: set LIBSSH2_TESTS macro for tests build: set LIBSSH2_TESTS macro for all tests Jul 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR moves the LIBSSH2_TESTS preprocessor macro from a single fixture header to the build system so it is applied consistently across test compilation units, aligning test builds across autotools and CMake.

Changes:

  • Remove the #define LIBSSH2_TESTS from tests/session_fixture.h.
  • Define LIBSSH2_TESTS globally for autotools-built tests via tests/Makefile.am.
  • Define LIBSSH2_TESTS for CMake-built tests via a directory-level compile definition in tests/CMakeLists.txt.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/session_fixture.h Stops defining LIBSSH2_TESTS in the fixture header so the macro is controlled by the build system.
tests/Makefile.am Adds -DLIBSSH2_TESTS to AM_CPPFLAGS so autotools-built tests all see the macro.
tests/CMakeLists.txt Adds a directory-level LIBSSH2_TESTS definition for CMake-built tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/CMakeLists.txt Resolved
Copilot AI review requested due to automatic review settings July 23, 2026 20:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@vszakats vszakats closed this in 76d30e5 Jul 23, 2026
@vszakats
vszakats deleted the b-tests-macro branch July 23, 2026 21:08
vszakats added a commit that referenced this pull request Jul 23, 2026
Fixing:
```
tests/test_simple.c:84:56: error: operand of ? changes signedness: 'int' to 'unsigned long' [clang-diagnostic-sign-conversion]
   84 |         gcry_mpi_t f = gcry_mpi_set_ui(NULL, fi >= 0 ? fi : -fi);
      |                        ~~~~~~~~~~~~~~~                 ^~
tests/test_simple.c:84:61: error: operand of ? changes signedness: 'int' to 'unsigned long' [clang-diagnostic-sign-conversion]
   84 |         gcry_mpi_t f = gcry_mpi_set_ui(NULL, fi >= 0 ? fi : -fi);
      |                        ~~~~~~~~~~~~~~~                      ^~~
tests/test_simple.c:85:46: error: implicit conversion changes signedness: 'int' to 'unsigned long' [clang-diagnostic-sign-conversion]
   85 |         gcry_mpi_t p = gcry_mpi_set_ui(NULL, atoi(tests[i].p));
      |                        ~~~~~~~~~~~~~~~       ^~~~~~~~~~~~~~~~
```
Ref: https://github.com/libssh2/libssh2/actions/runs/30043871895/job/89330114459#step:24:124

Also add intermediate current test holder var to keep code readable.

Follow-up to 76d30e5 #2417
Follow-up to fcf8307 #2239

Closes #2418
SebTardif added a commit to SebTardif/libssh2 that referenced this pull request Jul 23, 2026
- Parse buffer as const char * (fewer casts at call sites / tests)
- Check snprintf return before filling the long-name fixture
- Single-line memset for the basename fill
- Drop local LIBSSH2_TESTS define (build sets it for all tests after libssh2#2417)

Signed-off-by: Sebastien Tardif <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants