Skip to content

Commit 65afd87

Browse files
committed
source: wire up the -V option to all tests
When a test program is called with "-V" option, it prints version information and exits. Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent 523c727 commit 65afd87

File tree

14 files changed

+92
-31
lines changed

14 files changed

+92
-31
lines changed

source/evp_fetch.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ int main(int argc, char *argv[])
298298
int opt;
299299

300300
#ifdef OPENSSL_DO_PQ
301-
while ((opt = getopt(argc, argv, "tq")) != -1) {
301+
while ((opt = getopt(argc, argv, "tqV")) != -1) {
302302
#else
303-
while ((opt = getopt(argc, argv, "t")) != -1) {
303+
while ((opt = getopt(argc, argv, "tV")) != -1) {
304304
#endif
305305
switch (opt) {
306306
case 't':
@@ -311,16 +311,20 @@ int main(int argc, char *argv[])
311311
pq = 1;
312312
break;
313313
#endif
314+
case 'V':
315+
perflib_print_version(basename(argv[0]));
316+
return EXIT_SUCCESS;
314317
default:
315318
#ifdef OPENSSL_DO_PQ
316-
printf("Usage: %s [-t] [-q] threadcount\n", basename(argv[0]));
319+
printf("Usage: %s [-t] [-q] [-V] threadcount\n", basename(argv[0]));
317320
#else
318-
printf("Usage: %s [-t] threadcount\n", basename(argv[0]));
321+
printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0]));
319322
#endif
320323
printf("-t - terse output\n");
321324
#ifdef OPENSSL_DO_PQ
322325
printf("-q - include post-quantum algorithms\n");
323326
#endif
327+
printf("-V - print version information and exit\n");
324328
return EXIT_FAILURE;
325329
}
326330
}

source/evp_hash.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <stdlib.h>
1919
#include <stdio.h>
2020
#ifndef _WIN32
21+
# include <libgen.h>
2122
# include <unistd.h>
2223
#else
2324
# include "perflib/getopt.h"
@@ -246,12 +247,13 @@ static void do_hash_evp_shared(size_t num)
246247

247248
static void print_help()
248249
{
249-
printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] thread-count\n");
250+
printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] [-V] thread-count\n");
250251
printf("-h - print this help output\n");
251252
printf("-t - terse output\n");
252253
printf("-o operation - mode of operation. One of [deprecated, evp_isolated, evp_shared] (default: evp_shared)\n");
253254
printf("-u update-times - times to update digest. 1 for one-shot (default: 1)\n");
254255
printf("-a algorithm - One of: [SHA1, SHA224, SHA256, SHA384, SHA512] (default: SHA1)\n");
256+
printf("-V - print version information and exit\n");
255257
printf("thread-count - number of threads\n");
256258
}
257259

@@ -263,7 +265,7 @@ int main(int argc, char *argv[])
263265
int terse = 0, operation = EVP_SHARED, hash_algorithm = SHA1_ALG;
264266
int j, opt, rc = EXIT_FAILURE;
265267

266-
while ((opt = getopt(argc, argv, "hto:u:a:")) != -1) {
268+
while ((opt = getopt(argc, argv, "hto:u:a:V")) != -1) {
267269
switch (opt) {
268270
case 't':
269271
terse = 1;
@@ -305,6 +307,10 @@ int main(int argc, char *argv[])
305307
goto out;
306308
}
307309
break;
310+
case 'V':
311+
perflib_print_version(basename(argv[0]));
312+
rc = EXIT_SUCCESS;
313+
goto out;
308314
case 'h':
309315
default:
310316
print_help();

source/evp_setpeer.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <stdio.h>
1212
#include <string.h>
1313
#ifndef _WIN32
14+
# include <libgen.h>
1415
# include <unistd.h>
1516
#else
1617
# include <windows.h>
@@ -114,7 +115,7 @@ static void usage(char * const argv[])
114115
{
115116
const char **key_name = sample_names;
116117

117-
fprintf(stderr, "%s -k key_name [-t] threadcount\n", argv[0]);
118+
fprintf(stderr, "%s -k key_name [-t] [-V] threadcount\n", argv[0]);
118119
fprintf(stderr, "-t - terse output\n");
119120
fprintf(stderr, "-k - one of these options: %s", *key_name);
120121

@@ -125,6 +126,8 @@ static void usage(char * const argv[])
125126
else
126127
fprintf(stderr, ", %s", *key_name);
127128
} while (*key_name != NULL);
129+
130+
fprintf(stderr, "-V - print version information and exit\n");
128131
}
129132

130133
int main(int argc, char *argv[])
@@ -138,14 +141,17 @@ int main(int argc, char *argv[])
138141
char *key = NULL;
139142
int key_id, key_id_min, key_id_max, k;
140143

141-
while ((opt = getopt(argc, argv, "k:t")) != -1) {
144+
while ((opt = getopt(argc, argv, "k:tV")) != -1) {
142145
switch (opt) {
143146
case 't':
144147
terse = 1;
145148
break;
146149
case 'k':
147150
key = optarg;
148151
break;
152+
case 'V':
153+
perflib_print_version(basename(argv[0]));
154+
return EXIT_SUCCESS;
149155
default:
150156
usage(argv);
151157
return EXIT_FAILURE;

source/handshake.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ void usage(const char *progname)
338338
printf("-o - set ossl_lib_ctx pool size\n");
339339
#endif
340340
printf("-S [n] - use secure memory\n");
341+
printf("-V - print version information and exit\n");
341342
}
342343

343344
int main(int argc, char * const argv[])
@@ -355,9 +356,9 @@ int main(int argc, char * const argv[])
355356

356357
while ((opt = getopt(argc, argv,
357358
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
358-
"tspPo:lS:"
359+
"tspPo:lS:V"
359360
#else
360-
"tsS:"
361+
"tsS:V"
361362
#endif
362363
)) != -1) {
363364
switch (opt) {
@@ -421,6 +422,9 @@ int main(int argc, char * const argv[])
421422
}
422423
break;
423424
}
425+
case 'V':
426+
perflib_print_version(basename(argv[0]));
427+
return EXIT_SUCCESS;
424428
default:
425429
usage(basename(argv[0]));
426430
return EXIT_FAILURE;

source/newrawkey.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ int main(int argc, char *argv[])
395395
int rc = EXIT_FAILURE;
396396
int opt;
397397

398-
while ((opt = getopt(argc, argv, "ta:")) != -1) {
398+
while ((opt = getopt(argc, argv, "ta:V")) != -1) {
399399
switch (opt) {
400400
case 't':
401401
terse = 1;
@@ -420,11 +420,15 @@ int main(int argc, char *argv[])
420420
return EXIT_FAILURE;
421421
}
422422
break;
423+
case 'V':
424+
perflib_print_version(basename(argv[0]));
425+
return EXIT_SUCCESS;
423426
default:
424-
printf("Usage: %s [-t] [-a algorithm] threadcount\n", basename(argv[0]));
427+
printf("Usage: %s [-t] [-a algorithm] [-V] threadcount\n", basename(argv[0]));
425428
printf("-t - terse output\n");
426429
printf("-a algorithm - specify the algorithm to test (default: x25519)\n");
427430
printf(" Supported algorithms: x25519, ml-kem-512, ml-kem-768, ml-kem-1024\n");
431+
printf("-V - print version information and exit\n");
428432
return EXIT_FAILURE;
429433
}
430434
}

source/pkeyread.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <stdio.h>
1313
#include <string.h>
1414
#ifndef _WIN32
15+
# include <libgen.h>
1516
# include <unistd.h>
1617
#else
1718
# include <windows.h>
@@ -272,10 +273,11 @@ static void usage(char * const argv[])
272273
const char **key_name = sample_names;
273274
const char **format_name = format_names;
274275

275-
fprintf(stderr, "%s -k key_name -f format_name [-t] [-v] [-T time] threadcount\n"
276+
fprintf(stderr, "%s -k key_name -f format_name [-t] [-v] [-T time] [-V] threadcount\n"
276277
"\t-t terse output\n"
277278
"\t-v verbose output, includes min, max, stddev, and median times\n"
278-
"\t-T timeout for each test run in seconds, can be fractional"
279+
"\t-T timeout for each test run in seconds, can be fractional\n"
280+
"\t-V print version information and exit\n"
279281
"\twhere key_name is one of these: ", argv[0]);
280282
fprintf(stderr, "%s", *key_name);
281283
do {
@@ -313,7 +315,7 @@ int main(int argc, char * const argv[])
313315
key_id = SAMPLE_INVALID;
314316
format_id = FORMAT_INVALID;
315317

316-
while ((ch = getopt(argc, argv, "T:k:f:tv")) != -1) {
318+
while ((ch = getopt(argc, argv, "T:k:f:tviV")) != -1) {
317319
switch (ch) {
318320
case 'T': {
319321
double timeout_s;
@@ -342,6 +344,9 @@ int main(int argc, char * const argv[])
342344
case 'v':
343345
verbosity = VERBOSITY_VERBOSE;
344346
break;
347+
case 'V':
348+
perflib_print_version(basename(argv[0]));
349+
return EXIT_SUCCESS;
345350
}
346351
}
347352

source/providerdoall.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ int main(int argc, char *argv[])
6868
int ret = EXIT_FAILURE;
6969
int opt;
7070

71-
while ((opt = getopt(argc, argv, "t")) != -1) {
71+
while ((opt = getopt(argc, argv, "tV")) != -1) {
7272
switch (opt) {
7373
case 't':
7474
terse = 1;
7575
break;
76+
case 'V':
77+
perflib_print_version(basename(argv[0]));
78+
return EXIT_SUCCESS;
7679
default:
77-
printf("Usage: %s [-t] threadcount\n", basename(argv[0]));
80+
printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0]));
7881
printf("-t - terse output\n");
82+
printf("-V - print version information and exit\n");
7983
return EXIT_FAILURE;
8084
}
8185
}

source/randbytes.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,18 @@ int main(int argc, char *argv[])
5858
size_t i;
5959
int opt;
6060

61-
while ((opt = getopt(argc, argv, "t")) != -1) {
61+
while ((opt = getopt(argc, argv, "tV")) != -1) {
6262
switch (opt) {
6363
case 't':
6464
terse = 1;
6565
break;
66+
case 'V':
67+
perflib_print_version(basename(argv[0]));
68+
return EXIT_SUCCESS;
6669
default:
67-
printf("Usage: %s [-t] threadcount\n", basename(argv[0]));
70+
printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0]));
6871
printf("-t - terse output\n");
72+
printf("-V - print version information and exit\n");
6973
return EXIT_FAILURE;
7074
}
7175
}

source/rsasign.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,18 @@ int main(int argc, char *argv[])
8282
int i;
8383
int opt;
8484

85-
while ((opt = getopt(argc, argv, "t")) != -1) {
85+
while ((opt = getopt(argc, argv, "tV")) != -1) {
8686
switch (opt) {
8787
case 't':
8888
terse = 1;
8989
break;
90+
case 'V':
91+
perflib_print_version(basename(argv[0]));
92+
return EXIT_SUCCESS;
9093
default:
91-
printf("Usage: %s [-t] threadcount\n", basename(argv[0]));
94+
printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0]));
9295
printf("-t - terse output\n");
96+
printf("-V - print version information and exit\n");
9397
return EXIT_FAILURE;
9498
}
9599
}

source/rwlocks.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ int main(int argc, char *argv[])
110110
int opt;
111111
int writer_threads;
112112

113-
while ((opt = getopt(argc, argv, "t")) != -1) {
113+
while ((opt = getopt(argc, argv, "tV")) != -1) {
114114
switch (opt) {
115115
case 't':
116116
terse = 1;
117117
break;
118+
case 'V':
119+
perflib_print_version(basename(argv[0]));
120+
return EXIT_SUCCESS;
118121
default:
119-
printf("Usage: %s [-t] threadcount\n", basename(argv[0]));
122+
printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0]));
120123
printf("-t - terse output\n");
124+
printf("-V - print version information and exit\n");
121125
return EXIT_FAILURE;
122126
}
123127
}

0 commit comments

Comments
 (0)