Skip to content

Commit 95dad55

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 95dad55

File tree

14 files changed

+94
-31
lines changed

14 files changed

+94
-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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
#include <stdlib.h>
1919
#include <stdio.h>
2020
#ifndef _WIN32
21+
# include <libgen.h>
2122
# include <unistd.h>
2223
#else
24+
# include "perflib/basename.h"
2325
# include "perflib/getopt.h"
2426
#endif /* _WIN32 */
2527

@@ -246,12 +248,13 @@ static void do_hash_evp_shared(size_t num)
246248

247249
static void print_help()
248250
{
249-
printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] thread-count\n");
251+
printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] [-V] thread-count\n");
250252
printf("-h - print this help output\n");
251253
printf("-t - terse output\n");
252254
printf("-o operation - mode of operation. One of [deprecated, evp_isolated, evp_shared] (default: evp_shared)\n");
253255
printf("-u update-times - times to update digest. 1 for one-shot (default: 1)\n");
254256
printf("-a algorithm - One of: [SHA1, SHA224, SHA256, SHA384, SHA512] (default: SHA1)\n");
257+
printf("-V - print version information and exit\n");
255258
printf("thread-count - number of threads\n");
256259
}
257260

@@ -263,7 +266,7 @@ int main(int argc, char *argv[])
263266
int terse = 0, operation = EVP_SHARED, hash_algorithm = SHA1_ALG;
264267
int j, opt, rc = EXIT_FAILURE;
265268

266-
while ((opt = getopt(argc, argv, "hto:u:a:")) != -1) {
269+
while ((opt = getopt(argc, argv, "hto:u:a:V")) != -1) {
267270
switch (opt) {
268271
case 't':
269272
terse = 1;
@@ -305,6 +308,10 @@ int main(int argc, char *argv[])
305308
goto out;
306309
}
307310
break;
311+
case 'V':
312+
perflib_print_version(basename(argv[0]));
313+
rc = EXIT_SUCCESS;
314+
goto out;
308315
case 'h':
309316
default:
310317
print_help();

source/evp_setpeer.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
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>
18+
# include "perflib/basename.h"
1719
# include "perflib/getopt.h"
1820
#endif /* _WIN32 */
1921
#include <openssl/evp.h>
@@ -114,7 +116,7 @@ static void usage(char * const argv[])
114116
{
115117
const char **key_name = sample_names;
116118

117-
fprintf(stderr, "%s -k key_name [-t] threadcount\n", argv[0]);
119+
fprintf(stderr, "%s -k key_name [-t] [-V] threadcount\n", argv[0]);
118120
fprintf(stderr, "-t - terse output\n");
119121
fprintf(stderr, "-k - one of these options: %s", *key_name);
120122

@@ -125,6 +127,8 @@ static void usage(char * const argv[])
125127
else
126128
fprintf(stderr, ", %s", *key_name);
127129
} while (*key_name != NULL);
130+
131+
fprintf(stderr, "-V - print version information and exit\n");
128132
}
129133

130134
int main(int argc, char *argv[])
@@ -138,14 +142,17 @@ int main(int argc, char *argv[])
138142
char *key = NULL;
139143
int key_id, key_id_min, key_id_max, k;
140144

141-
while ((opt = getopt(argc, argv, "k:t")) != -1) {
145+
while ((opt = getopt(argc, argv, "k:tV")) != -1) {
142146
switch (opt) {
143147
case 't':
144148
terse = 1;
145149
break;
146150
case 'k':
147151
key = optarg;
148152
break;
153+
case 'V':
154+
perflib_print_version(basename(argv[0]));
155+
return EXIT_SUCCESS;
149156
default:
150157
usage(argv);
151158
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)