0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

mac build: improve unittest stability

mbedTLS commit 8873bcc4def433aa0edfbe260083f32f04aa097e

Timing self test: increased duration

Increase the duration of the self test, otherwise it tends to fail on
a busy machine even with the recently upped tolerance. But run the
loop only once, it's enough for a simple smoke test.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
This commit is contained in:
Lev Stipakov 2018-03-09 13:09:35 +02:00 committed by Antonio Quartulli
parent 758ae98c67
commit 3d6fd62cb1
No known key found for this signature in database
GPG Key ID: 07A53C580EF2CD74

View File

@ -0,0 +1,60 @@
From 8873bcc4def433aa0edfbe260083f32f04aa097e Mon Sep 17 00:00:00 2001
From: Gilles Peskine <Gilles.Peskine@arm.com>
Date: Fri, 27 Oct 2017 18:42:32 +0200
Subject: [PATCH] Timing self test: increased duration
Increase the duration of the self test, otherwise it tends to fail on
a busy machine even with the recently upped tolerance. But run the
loop only once, it's enough for a simple smoke test.
---
library/timing.c | 30 ++++++++++++------------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/library/timing.c b/library/timing.c
index 115204dc..f0d1a784 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -444,28 +444,22 @@ int mbedtls_timing_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( " TIMING test #2 (set/get_delay ): " );
- for( a = 200; a <= 400; a += 200 )
{
- for( b = 200; b <= 400; b += 200 )
- {
- mbedtls_timing_set_delay( &ctx, a, a + b );
-
- busy_msleep( a - a / 4 );
- if( mbedtls_timing_get_delay( &ctx ) != 0 )
- FAIL;
+ a = 800;
+ b = 400;
+ mbedtls_timing_set_delay( &ctx, a, a + b ); /* T = 0 */
- busy_msleep( a / 2 );
- if( mbedtls_timing_get_delay( &ctx ) != 1 )
- FAIL;
+ busy_msleep( a - a / 4 ); /* T = a - a/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 0 )
+ FAIL;
- busy_msleep( b - a / 4 - b / 4 );
- if( mbedtls_timing_get_delay( &ctx ) != 1 )
- FAIL;
+ busy_msleep( a / 4 + b / 4 ); /* T = a + b/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 1 )
+ FAIL;
- busy_msleep( b / 2 );
- if( mbedtls_timing_get_delay( &ctx ) != 2 )
- FAIL;
- }
+ busy_msleep( b ); /* T = a + b + b/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 2 )
+ FAIL;
}
mbedtls_timing_set_delay( &ctx, 0, 0 );
--
2.16.2.windows.1