Repository: libssh2/libssh2 (c)

Issue:
`make check` fails with `--disable-static`
**Describe the bug**

`make check` fails with `--disable-static`.

**To Reproduce**

```
./configure --prefix=/usr --disable-static && make && make check
```

It produces:

```
/usr/bin/ld: test_auth_keyboard_info_request.o: in function `main':
test_auth_keyboard_info_request.c:(.text.startup+0xec): undefined reference to `userauth_keyboard_interactive_decode_info_request'
/usr/bin/ld: test_auth_keyboard_info_request.c:(.text.startup+0x201): undefined reference to `userauth_keyboard_interactive_decode_info_request'
collect2: error: ld returned 1 exit status
```

**Expected behavior**

Test succeeds.

**Version:**
 - OS and version: Linux (Linux From Scratch)
 - libssh2 version: 1.11.0
 - crypto backend and version: OpenSSL

**Additional context**

It looks like the reason is `userauth_keyboard_interactive_decode_info_request` not exported in the shared library because we are linking libssh2.so with `-export-symbols-regex '^libssh2_.*'`.



Discussion:
This function shouldn't be exported, but also should be available for use in unit tests. Hum.

Patch:
diff --git a/Makefile.mk b/Makefile.mk
--- a/Makefile.mk
+++ b/Makefile.mk
@@ -211,15 +211,16 @@ prebuild: $(OBJ_DIR) $(OBJ_DIR)/version.inc
 
 example: $(TARGETS_EXAMPLES)
 
-# Get DOCKER_TESTS, STANDALONE_TESTS, SSHD_TESTS, TESTS_WITH_LIB_STATIC,
+# Get DOCKER_TESTS, DOCKER_TESTS_STATIC, STANDALONE_TESTS, STANDALONE_TESTS_STATIC, SSHD_TESTS,
 # librunner_la_SOURCES defines
 include tests/Makefile.inc
+ifndef DYN
+DOCKER_TESTS += $(DOCKER_TESTS_STATIC)
+STANDALONE_TESTS += $(STANDALONE_TESTS_STATIC)
+endif
 TARGETS_RUNNER := $(TARGET)-runner.a
 TARGETS_RUNNER_OBJS := $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(filter %.c,$(librunner_la_SOURCES))))
 TARGETS_TESTS := $(patsubst %.c,%$(BIN_EXT),$(addprefix tests/,$(addsuffix .c,$(DOCKER_TESTS) $(STANDALONE_TESTS) $(SSHD_TESTS))))
-ifdef DYN
-TARGETS_TESTS := $(filter-out $(patsubst %.c,%$(BIN_EXT),$(addprefix tests/,$(addsuffix .c,$(TESTS_WITH_LIB_STATIC)))),$(TARGETS_TESTS))
-endif
 
 test: $(TARGETS_RUNNER) $(TARGETS_TESTS)
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -371,6 +371,8 @@ fi
 AM_CONDITIONAL([HAVE_WINDRES],
   [test "x$have_windows_h" = "xyes" && test "x${enable_shared}" = "xyes" && test -n "${RC}"])
 
+AM_CONDITIONAL([HAVE_LIB_STATIC], [test "x$enable_static" != "xno"])
+
 # Configure parameters
 LIBSSH2_CHECK_OPTION_WERROR
 


Test patch:
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -39,9 +39,11 @@ include(CopyRuntimeDependencies)
 list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
 
 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
-# Get 'DOCKER_TESTS', 'STANDALONE_TESTS', 'SSHD_TESTS', 'TESTS_WITH_LIB_STATIC',
+# Get 'DOCKER_TESTS', 'DOCKER_TESTS_STATIC', 'STANDALONE_TESTS', 'STANDALONE_TESTS_STATIC', 'SSHD_TESTS',
 # 'librunner_la_SOURCES' variables
 include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
+list(APPEND DOCKER_TESTS ${DOCKER_TESTS_STATIC})
+list(APPEND STANDALONE_TESTS ${STANDALONE_TESTS_STATIC})
 
 if(CMAKE_COMPILER_IS_GNUCC)
   find_program(GCOV_PATH gcov)
@@ -71,7 +73,7 @@ target_compile_definitions(runner PRIVATE "${CRYPTO_BACKEND_DEFINE}")
 target_include_directories(runner PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src ../include "${CRYPTO_BACKEND_INCLUDE_DIR}")
 
 foreach(test ${DOCKER_TESTS} ${STANDALONE_TESTS} ${SSHD_TESTS})
-  if(NOT ";${TESTS_WITH_LIB_STATIC};" MATCHES ";${test};")
+  if(NOT ";${DOCKER_TESTS_STATIC};${STANDALONE_TESTS_STATIC};" MATCHES ";${test};")
     set(LIB_FOR_TESTS ${LIB_SELECTED})
   elseif(TARGET ${LIB_STATIC})
     set(LIB_FOR_TESTS ${LIB_STATIC})
diff --git a/tests/Makefile.am b/tests/Makefile.am
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,10 +2,15 @@ SUBDIRS = ossfuzz
 
 AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)/include
 
-# Get DOCKER_TESTS, STANDALONE_TESTS, SSHD_TESTS, TESTS_WITH_LIB_STATIC,
+# Get DOCKER_TESTS, DOCKER_TESTS_STATIC, STANDALONE_TESTS, STANDALONE_TESTS_STATOC, SSHD_TESTS,
 # librunner_la_SOURCES defines and *_LDFLAGS for statically linked tests.
 include Makefile.inc
 
+if HAVE_LIB_STATIC
+DOCKER_TESTS += $(DOCKER_TESTS_STATIC)
+STANDALONE_TESTS += $(STANDALONE_TESTS_STATIC)
+endif
+
 # Some tests rely on the 'srcdir' env. Set by autotools automatically.
 TESTS_ENVIRONMENT =
 
diff --git a/tests/Makefile.inc b/tests/Makefile.inc
--- a/tests/Makefile.inc
+++ b/tests/Makefile.inc
@@ -7,7 +7,6 @@ DOCKER_TESTS = \
   test_aa_warmup \
   test_agent_forward_ok \
   test_auth_keyboard_fail \
-  test_auth_keyboard_info_request \
   test_auth_keyboard_ok \
   test_auth_password_fail_password \
   test_auth_password_fail_username \
@@ -23,12 +22,10 @@ DOCKER_TESTS = \
   test_auth_pubkey_ok_rsa_encrypted \
   test_auth_pubkey_ok_rsa_openssh \
   test_auth_pubkey_ok_rsa_signed \
-  test_hostkey \
   test_hostkey_hash \
   test_read
 
-STANDALONE_TESTS = \
-  test_simple
+STANDALONE_TESTS =
 
 SSHD_TESTS = \
   test_ssh2 \
@@ -36,13 +33,15 @@ SSHD_TESTS = \
 
 # Programs of the above that use internal libssh2 functions so they need
 # to be statically linked against libssh2
-TESTS_WITH_LIB_STATIC = \
+DOCKER_TESTS_STATIC = \
   test_auth_keyboard_info_request \
-  test_hostkey \
+  test_hostkey
+
+STANDALONE_TESTS_STATIC = \
   test_simple
 
 # Copy of the above for Makefile.am.
-# Is there a way to reuse the list above?
+# Is there a way to reuse the lists above?
 test_auth_keyboard_info_request_LDFLAGS = -static
 test_hostkey_LDFLAGS = -static
 test_simple_LDFLAGS = -static