2727#define RUN_TIME 5
2828#define NONCE_CFG "file:servercert.pem"
2929
30+ enum verbosity {
31+ VERBOSITY_TERSE ,
32+ VERBOSITY_DEFAULT ,
33+ VERBOSITY_VERBOSE ,
34+ VERBOSITY_DEBUG_STATS ,
35+ VERBOSITY_DEBUG ,
36+
37+ VERBOSITY_MAX__
38+ };
39+
3040enum nonce_type {
3141 NONCE_PATH ,
3242};
@@ -39,6 +49,7 @@ struct nonce_cfg {
3949};
4050
4151static int error = 0 ;
52+ static int verbosity = VERBOSITY_DEFAULT ;
4253static X509_STORE * store = NULL ;
4354static X509 * x509_nonce = NULL ;
4455
@@ -167,8 +178,9 @@ static void
167178usage (char * const argv [])
168179{
169180 fprintf (stderr ,
170- "Usage: %s [-t] [-n nonce_type:type_args] certsdir threadcount\n"
181+ "Usage: %s [-t] [-v] [- n nonce_type:type_args] certsdir threadcount\n"
171182 "\t-t\tTerse output\n"
183+ "\t-v\tVerbose output. Multiple usage increases verbosity.\n"
172184 "\t-n\tNonce configuration, supported options:\n"
173185 "\t\t\tfile:PATH - load nonce certificate from PATH;\n"
174186 "\t\t\tif PATH is relative, the provided certsdir's are searched.\n"
@@ -218,7 +230,6 @@ int main(int argc, char *argv[])
218230 OSSL_TIME duration ;
219231 size_t total_count = 0 ;
220232 double avcalltime ;
221- int terse = 0 ;
222233 char * cert = NULL ;
223234 int ret = EXIT_FAILURE ;
224235 BIO * bio = NULL ;
@@ -228,10 +239,18 @@ int main(int argc, char *argv[])
228239
229240 parse_nonce_cfg (NONCE_CFG , & nonce_cfg );
230241
231- while ((opt = getopt (argc , argv , "tn :" )) != -1 ) {
242+ while ((opt = getopt (argc , argv , "tvn :" )) != -1 ) {
232243 switch (opt ) {
233- case 't' :
234- terse = 1 ;
244+ case 't' : /* terse */
245+ verbosity = VERBOSITY_TERSE ;
246+ break ;
247+ case 'v' : /* verbose */
248+ if (verbosity < VERBOSITY_VERBOSE ) {
249+ verbosity = VERBOSITY_VERBOSE ;
250+ } else {
251+ if (verbosity < VERBOSITY_MAX__ - 1 )
252+ verbosity ++ ;
253+ }
235254 break ;
236255 case 'n' : /* nonce */
237256 parse_nonce_cfg (optarg , & nonce_cfg );
@@ -284,11 +303,14 @@ int main(int argc, char *argv[])
284303
285304 avcalltime = (double )RUN_TIME * 1e6 * threadcount / total_count ;
286305
287- if (terse )
306+ switch (verbosity ) {
307+ case VERBOSITY_TERSE :
288308 printf ("%lf\n" , avcalltime );
289- else
309+ break ;
310+ default :
290311 printf ("Average time per X509_STORE_CTX_get1_issuer() call: %lfus\n" ,
291312 avcalltime );
313+ }
292314
293315 ret = EXIT_SUCCESS ;
294316
0 commit comments