mirror of
https://github.com/libssh2/libssh2.git
synced 2025-12-24 19:37:49 +03:00
build: add autotools test_read support and more
Keep a single list for mac and crypt algos that we use in both CMake and autotools. Use the same test names across build tools. Use the TAP protocol to track individual tests run from a single shell script. Also: - enable the rest of our tests with autotools. - set `make check` verbose to see errors in case they happen. - silence stray 'command not found' error when running `mansyntax.sh` on Windows. GitHub Actions Windows docker tests disabled due to: ``` Command: docker build --quiet -t libssh2/openssh_server ../tests/openssh_server Error running command 'docker build --quiet -t libssh2/openssh_server ../tests/openssh_server' (exit 1): Sending build context to Docker daemon 22.02kB Step 1/42 : FROM debian:bullseye-slim bullseye-slim: Pulling from library/debian no matching manifest for windows/amd64 10.0.20348 in the manifest list entries Failed to build docker image ``` Closes #993
This commit is contained in:
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -68,7 +68,7 @@ jobs:
|
||||
autoreconf -fi
|
||||
./configure --enable-debug --enable-werror
|
||||
make -j3
|
||||
make check
|
||||
make check VERBOSE=1
|
||||
- name: Build with CMake
|
||||
timeout-minutes: 10
|
||||
if: ${{ matrix.b == 'cmake' }}
|
||||
@@ -108,4 +108,4 @@ jobs:
|
||||
autoreconf -fi
|
||||
./configure --enable-debug --enable-static --disable-shared --with-crypto=openssl
|
||||
make -j3
|
||||
make check
|
||||
make check VERBOSE=1
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -27,7 +27,8 @@ depcomp
|
||||
libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
ssh2_sample
|
||||
tap-driver.sh
|
||||
test-driver
|
||||
libssh2-*.tar.bz2
|
||||
libssh2-*.tar.gz
|
||||
libssh2-*.tar.xz
|
||||
|
||||
@@ -3,6 +3,7 @@ AC_INIT(libssh2, [-], libssh2-devel@lists.haxx.se)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src])
|
||||
AC_CONFIG_HEADERS([src/libssh2_config.h])
|
||||
AC_REQUIRE_AUX_FILE([tap-driver.sh])
|
||||
AM_MAINTAINER_MODE
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
@@ -371,6 +372,14 @@ fi
|
||||
AM_CONDITIONAL([HAVE_WINDRES],
|
||||
[test "x$have_windows_h" = "xyes" && test "x${enable_shared}" = "xyes" && test -n "${RC}"])
|
||||
|
||||
case "`uname`" in
|
||||
*_NT*) host_windows=yes
|
||||
;;
|
||||
*) host_windows=no
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL([HOST_WINDOWS], [test "x$host_windows" = "xyes"])
|
||||
|
||||
# Configure parameters
|
||||
LIBSSH2_CHECK_OPTION_WERROR
|
||||
|
||||
|
||||
@@ -109,38 +109,17 @@ foreach(test ${TESTS})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# MAC tests
|
||||
foreach(test
|
||||
hmac-md5
|
||||
hmac-md5-96
|
||||
hmac-sha1
|
||||
hmac-sha1-96
|
||||
hmac-sha2-256
|
||||
hmac-sha2-512
|
||||
hmac-sha1-etm@openssh.com
|
||||
hmac-sha2-256-etm@openssh.com
|
||||
hmac-sha2-512-etm@openssh.com
|
||||
)
|
||||
add_test(NAME test_${test} COMMAND "$<TARGET_FILE:test_read>")
|
||||
set_tests_properties(test_${test} PROPERTIES ENVIRONMENT "FIXTURE_TEST_MAC=${test}")
|
||||
endforeach()
|
||||
|
||||
# CRYPT tests
|
||||
foreach(test
|
||||
3des-cbc
|
||||
aes128-cbc
|
||||
aes128-ctr
|
||||
aes128-gcm@openssh.com
|
||||
aes192-cbc
|
||||
aes192-ctr
|
||||
aes256-cbc
|
||||
aes256-ctr
|
||||
aes256-gcm@openssh.com
|
||||
rijndael-cbc@lysator.liu.se
|
||||
)
|
||||
string(REGEX REPLACE "@.*" "" testfn "${test}")
|
||||
add_test(NAME test_${testfn} COMMAND "$<TARGET_FILE:test_read>")
|
||||
set_tests_properties(test_${testfn} PROPERTIES ENVIRONMENT "FIXTURE_TEST_CRYPT=${test}")
|
||||
# CRYPT/MAC algo tests
|
||||
file(READ "test_read_algos.txt" TESTS)
|
||||
string(REGEX REPLACE "\\\n" ";" TESTS ${TESTS})
|
||||
foreach(test ${TESTS})
|
||||
set(testname test_read-${test})
|
||||
add_test(NAME ${testname} COMMAND "$<TARGET_FILE:test_read>")
|
||||
if(test MATCHES "mac-")
|
||||
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "FIXTURE_TEST_MAC=${test}")
|
||||
else()
|
||||
set_tests_properties(${testname} PROPERTIES ENVIRONMENT "FIXTURE_TEST_CRYPT=${test}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_custom_target(coverage
|
||||
|
||||
@@ -6,6 +6,11 @@ ctests = test_simple$(EXEEXT)
|
||||
TESTS = $(ctests) mansyntax.sh
|
||||
check_PROGRAMS = $(ctests)
|
||||
|
||||
TEST_EXTENSIONS = .test
|
||||
# 'TEST' in 'TEST_LOG_DRIVER' is the test extension in uppercase.
|
||||
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/tap-driver.sh
|
||||
TESTS += test_read_algos.test
|
||||
|
||||
if SSHD
|
||||
TESTS += ssh2.sh
|
||||
check_PROGRAMS += test_ssh2
|
||||
@@ -36,8 +41,9 @@ INTEGRATION_TESTS = \
|
||||
test_read
|
||||
|
||||
# Integration tests using Docker
|
||||
# Enable this once the tests are working
|
||||
#TESTS += $(INTEGRATION_TESTS)
|
||||
if ! HOST_WINDOWS
|
||||
TESTS += $(INTEGRATION_TESTS)
|
||||
endif
|
||||
check_PROGRAMS += $(INTEGRATION_TESTS)
|
||||
librunner_la_SOURCES = \
|
||||
runner.c runner.h \
|
||||
@@ -97,27 +103,10 @@ EXTRA_DIST = \
|
||||
openssh_server/ssh_host_ecdsa_key \
|
||||
openssh_server/ssh_host_ed25519_key \
|
||||
openssh_server/ssh_host_rsa_key \
|
||||
test_read_algos.test \
|
||||
test_read_algos.txt \
|
||||
test_simple.c \
|
||||
sshdwrap \
|
||||
test_ssh2.c \
|
||||
ssh2.sh \
|
||||
sshd_fixture.sh.in \
|
||||
test_read_3des-cbc \
|
||||
test_read_aes128-cbc \
|
||||
test_read_aes128-ctr \
|
||||
test_read_aes128-gcm \
|
||||
test_read_aes192-cbc \
|
||||
test_read_aes192-ctr \
|
||||
test_read_aes256-cbc \
|
||||
test_read_aes256-ctr \
|
||||
test_read_aes256-gcm \
|
||||
test_read_hmac-md5 \
|
||||
test_read_hmac-md5-96 \
|
||||
test_read_hmac-sha1 \
|
||||
test_read_hmac-sha1-96 \
|
||||
test_read_hmac-sha2-256 \
|
||||
test_read_hmac-sha2-512 \
|
||||
test_read_rijndael-cbc \
|
||||
test_read_hmac-sha1-etm@openssh.com \
|
||||
test_read_hmac-sha2-256-etm@openssh.com \
|
||||
test_read_hmac-sha2-512-etm@openssh.com
|
||||
sshdwrap
|
||||
|
||||
@@ -20,7 +20,7 @@ ec=0
|
||||
# Only test if suitable man is available
|
||||
#
|
||||
if command -v grep >/dev/null 2>&1 && \
|
||||
man --help | grep -q warnings; then
|
||||
man --help 2>/dev/null | grep -q warnings; then
|
||||
|
||||
trap 'rm -f "$dstdir/man3"' EXIT
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=3des-cbc exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes128-cbc exec ./test_read
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes128-ctr exec ./test_read
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes128-gcm@openssh.com exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes192-cbc exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes192-ctr exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes256-cbc exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes256-ctr exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=aes256-gcm@openssh.com exec ./test_read
|
||||
36
tests/test_read_algos.test
Executable file
36
tests/test_read_algos.test
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# https://testanything.org/tap-specification.html
|
||||
|
||||
if [[ "$(uname)" = *'_NT'* ]]; then
|
||||
echo "1..0 # skip test_read tests due to docker issues"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
testbin='./test_read'
|
||||
|
||||
d="$(dirname "$0")"
|
||||
algos="$(cat "${d}/test_read_algos.txt")"
|
||||
|
||||
count=1
|
||||
total="$(echo "${algos}" | wc -l | tr -d ' ')"
|
||||
|
||||
echo "${count}..${total}"
|
||||
|
||||
while read -r test; do
|
||||
if [[ "${test}" = *'mac-'* ]]; then
|
||||
if FIXTURE_TEST_MAC="${test}" "${testbin}"; then
|
||||
res='ok'
|
||||
else
|
||||
res='not ok'
|
||||
fi
|
||||
else
|
||||
if FIXTURE_TEST_CRYPT="${test}" "${testbin}"; then
|
||||
res='ok'
|
||||
else
|
||||
res='not ok'
|
||||
fi
|
||||
fi
|
||||
echo "${res} ${count} - test_read-${test}"
|
||||
((count++))
|
||||
done <<< "${algos}"
|
||||
19
tests/test_read_algos.txt
Normal file
19
tests/test_read_algos.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
3des-cbc
|
||||
aes128-cbc
|
||||
aes128-ctr
|
||||
aes128-gcm@openssh.com
|
||||
aes192-cbc
|
||||
aes192-ctr
|
||||
aes256-cbc
|
||||
aes256-ctr
|
||||
aes256-gcm@openssh.com
|
||||
rijndael-cbc@lysator.liu.se
|
||||
hmac-md5
|
||||
hmac-md5-96
|
||||
hmac-sha1
|
||||
hmac-sha1-96
|
||||
hmac-sha1-etm@openssh.com
|
||||
hmac-sha2-256
|
||||
hmac-sha2-256-etm@openssh.com
|
||||
hmac-sha2-512
|
||||
hmac-sha2-512-etm@openssh.com
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-md5 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-md5-96 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-sha1 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-sha1-96 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-sha2-256 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_MAC=hmac-sha2-512 exec ./test_read
|
||||
@@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
FIXTURE_TEST_CRYPT=rijndael-cbc@lysator.liu.se exec ./test_read
|
||||
Reference in New Issue
Block a user