@@ -58,6 +58,7 @@ static X509 *x509_nonce = NULL;
5858static int threadcount ;
5959
6060size_t * counts ;
61+ size_t * founds ;
6162OSSL_TIME max_time ;
6263
6364static X509 *
@@ -148,6 +149,7 @@ do_x509storeissuer(size_t num)
148149 X509 * issuer = NULL ;
149150 OSSL_TIME time = ossl_time_now ();
150151 size_t count = 0 ;
152+ size_t found = 0 ;
151153
152154 if (ctx == NULL || !X509_STORE_CTX_init (ctx , store , x509_nonce , NULL )) {
153155 warnx ("Failed to initialise X509_STORE_CTX" );
@@ -156,16 +158,9 @@ do_x509storeissuer(size_t num)
156158 }
157159
158160 do {
159- /*
160- * We actually expect this to fail. We've not configured any
161- * certificates inside our store. We're just testing calling this
162- * against an empty store.
163- */
164161 if (X509_STORE_CTX_get1_issuer (& issuer , ctx , x509_nonce ) != 0 ) {
165- warnx ("Unexpected result from X509_STORE_CTX_get1_issuer" );
166- error = 1 ;
162+ found ++ ;
167163 X509_free (issuer );
168- goto err ;
169164 }
170165 issuer = NULL ;
171166 count ++ ;
@@ -177,6 +172,7 @@ do_x509storeissuer(size_t num)
177172 X509_STORE_CTX_free (ctx );
178173
179174 counts [num ] = count ;
175+ founds [num ] = found ;
180176}
181177
182178static void
@@ -256,6 +252,7 @@ main(int argc, char *argv[])
256252 int i ;
257253 OSSL_TIME duration ;
258254 size_t total_count = 0 ;
255+ size_t total_found = 0 ;
259256 double avcalltime ;
260257 char * cert = NULL ;
261258 int ret = EXIT_FAILURE ;
@@ -316,6 +313,10 @@ main(int argc, char *argv[])
316313 if (counts == NULL )
317314 errx (EXIT_FAILURE , "Failed to create counts array" );
318315
316+ founds = OPENSSL_malloc (sizeof (size_t ) * threadcount );
317+ if (founds == NULL )
318+ errx (EXIT_FAILURE , "Failed to create founds array" );
319+
319320 x509_nonce = make_nonce (& nonce_cfg );
320321 if (x509_nonce == NULL )
321322 errx (EXIT_FAILURE , "Unable to create the nonce X509 object" );
@@ -328,8 +329,10 @@ main(int argc, char *argv[])
328329 if (error )
329330 errx (EXIT_FAILURE , "Error during test" );
330331
331- for (i = 0 ; i < threadcount ; i ++ )
332+ for (i = 0 ; i < threadcount ; i ++ ) {
332333 total_count += counts [i ];
334+ total_found += founds [i ];
335+ }
333336
334337 avcalltime = (double )timeout_us * threadcount / total_count ;
335338
@@ -340,6 +343,12 @@ main(int argc, char *argv[])
340343 default :
341344 printf ("Average time per X509_STORE_CTX_get1_issuer() call: %lfus\n" ,
342345 avcalltime );
346+ if (verbosity >= VERBOSITY_VERBOSE ) {
347+ printf ("Successful X509_STORE_CTX_get1_issuer() calls: %zu of %zu"
348+ " (%lf%%)\n" ,
349+ total_found , total_count ,
350+ (double )total_found / total_count * 100.0 );
351+ }
343352 }
344353
345354 ret = EXIT_SUCCESS ;
@@ -349,6 +358,7 @@ main(int argc, char *argv[])
349358 X509_STORE_free (store );
350359 BIO_free (bio );
351360 OPENSSL_free (cert );
361+ OPENSSL_free (founds );
352362 OPENSSL_free (counts );
353363 return ret ;
354364}
0 commit comments