1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00
Files
libssh2/tests/runner.c
Viktor Szakats 2233bf95ed tests: retry '(-43): Failed getting banner' flaky failures
Example:
```
1: libssh2_session_handshake failed (-43): Failed getting banner
1: ---- sshd log ----
1: No matching private key for certificate: /etc/ssh/ssh_host_mldsa44-ed25519_key-cert.pub
1: debug1: Set /proc/self/oom_score_adj from 0 to -1000
1: debug2: fd 6 setting O_NONBLOCK
1: debug1: Bind to port 22 on 0.0.0.0.
1: Server listening on 0.0.0.0 port 22.
1: debug2: fd 7 setting O_NONBLOCK
1: debug1: Bind to port 22 on ::.
1: Server listening on :: port 22.
1: ------------------
1: Command: docker image pull ghcr.io/libssh2/ci_tests_openssh_server:8d1fde1834077fddb9f9
1: Command: docker image tag ghcr.io/libssh2/ci_tests_openssh_server:8d1fde1834077fddb9f9 libssh2/openssh_server
1: Command: docker run --rm -d -p 22 libssh2/openssh_server
1: Command: docker inspect --format "{{ (index (index .NetworkSettings.Ports \"22/tcp\") 0).HostIp }}" a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker inspect --format "{{ (index (index .NetworkSettings.Ports \"22/tcp\") 0).HostPort }}" a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker logs a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
1: Command: docker stop a1f1a209001852fa7e3aba87c0f1198661c4fe07c34ddcbf2e76e264ef64b7b8
 1/61 Test  #1: test_aa_warmup .......................................***Failed    6.08 sec
libssh2_session_handshake failed (-43): Failed getting banner
```
Ref: https://github.com/libssh2/libssh2/actions/runs/37613324059/job/112765610280?pr=2659#step:25:133

Ref: 5bfa574460 #2603

Closes #2662
2026-10-07 15:35:05 +02:00

66 lines
2.5 KiB
C

/* Copyright (C) Alexander Lamaison
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "runner.h"
int main(void)
{
int exit_code;
/* Retry tests to mitigate flaky failures */
int retries = 2, retry = 0;
do {
int skipped, rc;
LIBSSH2_SESSION *session = start_session_fixture(&skipped, &rc);
if(session)
exit_code = (test(session) == 0) ? 0 : 1;
else if(skipped) {
fprintf(stderr, "Test skipped.\n");
exit_code = 0;
}
else
exit_code = 1;
stop_session_fixture(exit_code);
/* Retry:
'libssh2_session_handshake failed (-43): Failed getting banner' */
if(exit_code == 0 || rc != LIBSSH2_ERROR_SOCKET_RECV ||
++retry > retries) {
break;
}
fprintf(stderr, "Test failed (%d). Retrying... %d / %d\n",
rc, retry, retries);
} while(1);
stop_session_fixture(exit_code);
return exit_code;
}