1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-07 08:02:56 +03:00

ci: reduce algo test runtime on AppVeyor

Make the block count customizable in `test_read` via environment
`FIXTURE_XFER_COUNT`.

Set the custom count lower than the default when running on AppVeyor.

The goal is to reduce CI roundtrip times.

Closes #995
This commit is contained in:
Viktor Szakats
2023-04-22 08:58:57 +00:00
parent bc4e619e76
commit fdf824d6f4
2 changed files with 34 additions and 23 deletions

View File

@@ -26,6 +26,7 @@
environment: environment:
CONFIGURATION: "Release" CONFIGURATION: "Release"
FIXTURE_XFER_COUNT: 35020
matrix: matrix:
- job_name: "VS2022, OpenSSL3, x64, Server 2019" - job_name: "VS2022, OpenSSL3, x64, Server 2019"
APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2022" APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2022"

View File

@@ -2,33 +2,32 @@
#include "runner.h" #include "runner.h"
#include <stdlib.h> /* for getenv() */
/* set in Dockerfile */ /* set in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_rsa"; static const char *KEY_FILE_PRIVATE = "key_rsa";
static const char *KEY_FILE_PUBLIC = "key_rsa.pub"; static const char *KEY_FILE_PUBLIC = "key_rsa.pub";
/* Size and number of blocks to transfer
* This needs to be large to increase the chance of timing effects causing
* different code paths to be hit in the unframing code, but not so long that
* the integration tests take too long. 5 seconds of run time is probably a
* reasonable compromise. The block size is an odd number to increase the
* chance that various internal buffer and block boundaries are overlapped. */
#define XFER_BS 997
#define XFER_COUNT 140080
#define STRINGIFY(x) STRINGIFY2(x)
#define STRINGIFY2(x) #x
/* command to transfer the desired amount of data */
#define REMOTE_COMMAND "dd if=/dev/zero bs=" STRINGIFY(XFER_BS) \
" count=" STRINGIFY(XFER_COUNT) " status=none"
int test(LIBSSH2_SESSION *session) int test(LIBSSH2_SESSION *session)
{ {
int rc; int rc;
long xfer_bytes = 0; unsigned long xfer_bytes = 0;
LIBSSH2_CHANNEL *channel; LIBSSH2_CHANNEL *channel;
/* Size and number of blocks to transfer
* This needs to be large to increase the chance of timing effects causing
* different code paths to be hit in the unframing code, but not so long
* that the integration tests take too long. 5 seconds of run time is
* probably a reasonable compromise. The block size is an odd number to
* increase the chance that various internal buffer and block boundaries
* are overlapped. */
const unsigned long xfer_bs = 997;
unsigned long xfer_count = 140080;
char remote_command[256];
const char *env;
const char *userauth_list = const char *userauth_list =
libssh2_userauth_list(session, USERNAME, libssh2_userauth_list(session, USERNAME,
(unsigned int)strlen(USERNAME)); (unsigned int)strlen(USERNAME));
@@ -60,8 +59,19 @@ int test(LIBSSH2_SESSION *session)
goto shutdown; goto shutdown;
} }
env = getenv("FIXTURE_XFER_COUNT");
if(env) {
xfer_count = (unsigned long)strtol(env, NULL, 0);
fprintf(stderr, "Custom xfer_count: %lu\n", xfer_count);
}
/* command to transfer the desired amount of data */
snprintf(remote_command, sizeof(remote_command),
"dd if=/dev/zero bs=%lu count=%lu status=none",
xfer_bs, xfer_count);
/* Send the command to transfer data */ /* Send the command to transfer data */
if(libssh2_channel_exec(channel, REMOTE_COMMAND)) { if(libssh2_channel_exec(channel, remote_command)) {
fprintf(stderr, "Unable to request command on channel\n"); fprintf(stderr, "Unable to request command on channel\n");
goto shutdown; goto shutdown;
} }
@@ -73,8 +83,8 @@ int test(LIBSSH2_SESSION *session)
if(err < 0) if(err < 0)
fprintf(stderr, "Unable to read response: %d\n", (int)err); fprintf(stderr, "Unable to read response: %d\n", (int)err);
else { else {
int i; unsigned int i;
for(i = 0; i < err; ++i) { for(i = 0; i < (unsigned long)err; ++i) {
if(buf[i]) { if(buf[i]) {
fprintf(stderr, "Bad data received\n"); fprintf(stderr, "Bad data received\n");
/* Test will fail below due to bad data length */ /* Test will fail below due to bad data length */
@@ -97,9 +107,9 @@ int test(LIBSSH2_SESSION *session)
shutdown: shutdown:
/* Test check */ /* Test check */
if(xfer_bytes != XFER_COUNT * XFER_BS) { if(xfer_bytes != xfer_count * xfer_bs) {
fprintf(stderr, "Not enough bytes received: %ld not %ld\n", fprintf(stderr, "Not enough bytes received: %lu not %lu\n",
xfer_bytes, (long)XFER_COUNT * XFER_BS); xfer_bytes, xfer_count * xfer_bs);
return 1; /* error */ return 1; /* error */
} }
return 0; return 0;