From cd10966e072b3a8180c46dd4cb9ac923dd16732a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Fri, 11 Jul 2014 00:18:34 +0000 Subject: [PATCH] Make the performance tests conditional on a run-time environment variable rather than a build-time option. --- configure.ac | 8 -------- t/Makefile.am | 4 ---- t/t_md2.c | 20 +++++++++----------- t/t_md4.c | 21 ++++++++++----------- t/t_md5.c | 20 +++++++++----------- t/t_sha1.c | 20 +++++++++----------- t/t_sha256.c | 21 +++++++++------------ t/t_sha384.c | 21 ++++++++++----------- t/t_sha512.c | 20 +++++++++----------- 9 files changed, 65 insertions(+), 90 deletions(-) diff --git a/configure.ac b/configure.ac index 3a4aea2..6438710 100644 --- a/configure.ac +++ b/configure.ac @@ -23,14 +23,6 @@ LT_INIT() # other programs AC_PROG_INSTALL -# Include benchmarks in unit tests -AC_ARG_WITH([benchmarks], - AC_HELP_STRING([--with-benchmarks], - [include benchmarks in unit tests]), - [], - [with_benchmarks=no]) -AM_CONDITIONAL([WITH_BENCHMARKS], [test x"$with_benchmarks" = x"yes"]) - # OpenSSL versions of the unit tests for comparison AC_ARG_WITH([openssl], AC_HELP_STRING([--with-openssl], diff --git a/t/Makefile.am b/t/Makefile.am index 48cd87b..d9622b3 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -2,10 +2,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -if WITH_BENCHMARKS -AM_CPPFLAGS += -DBENCHMARKS -endif - noinst_HEADERS = t.h # Common support code diff --git a/t/t_md2.c b/t/t_md2.c index adceb13..609cfff 100644 --- a/t/t_md2.c +++ b/t/t_md2.c @@ -177,7 +177,6 @@ t_md2_short_updates(char **desc CRYB_UNUSED, void *arg) #endif -#ifdef BENCHMARKS /* * Performance test: measure the time spent computing the MD2 sum of a * message of the specified length. @@ -208,7 +207,6 @@ t_md2_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -240,15 +238,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_md2_short_updates, &t_md2_vectors[6], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_md2_perf, &one, - "performance test (1 byte)"); - t_add_test(t_md2_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_md2_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_md2_perf, &one, + "performance test (1 byte)"); + t_add_test(t_md2_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_md2_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_md4.c b/t/t_md4.c index a42a672..f163726 100644 --- a/t/t_md4.c +++ b/t/t_md4.c @@ -192,7 +192,7 @@ t_md4_short_updates(char **desc CRYB_UNUSED, void *arg) } #endif -#ifdef BENCHMARKS + /* * Performance test: measure the time spent computing the MD4 sum of a * message of the specified length. @@ -223,7 +223,6 @@ t_md4_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -255,15 +254,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_md4_short_updates, &t_md4_vectors[6], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_md4_perf, &one, - "performance test (1 byte)"); - t_add_test(t_md4_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_md4_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_md4_perf, &one, + "performance test (1 byte)"); + t_add_test(t_md4_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_md4_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_md5.c b/t/t_md5.c index 9c9732b..0a8b570 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -193,7 +193,6 @@ t_md5_short_updates(char **desc CRYB_UNUSED, void *arg) #endif -#ifdef BENCHMARKS /* * Performance test: measure the time spent computing the MD5 sum of a * message of the specified length. @@ -224,7 +223,6 @@ t_md5_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -256,15 +254,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_md5_short_updates, &t_md5_vectors[6], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_md5_perf, &one, - "performance test (1 byte)"); - t_add_test(t_md5_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_md5_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_md5_perf, &one, + "performance test (1 byte)"); + t_add_test(t_md5_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_md5_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_sha1.c b/t/t_sha1.c index 2612807..2457f92 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -189,7 +189,6 @@ t_sha1_short_updates(char **desc CRYB_UNUSED, void *arg) } #endif -#ifdef BENCHMARKS /* * Performance test: measure the time spent computing the SHA1 sum of a * message of the specified length. @@ -220,7 +219,6 @@ t_sha1_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -252,15 +250,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_sha1_short_updates, &t_sha1_vectors[4], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_sha1_perf, &one, - "performance test (1 byte)"); - t_add_test(t_sha1_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_sha1_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_sha1_perf, &one, + "performance test (1 byte)"); + t_add_test(t_sha1_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_sha1_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_sha256.c b/t/t_sha256.c index 7e82c0f..898b557 100644 --- a/t/t_sha256.c +++ b/t/t_sha256.c @@ -194,8 +194,6 @@ t_sha256_short_updates(char **desc CRYB_UNUSED, void *arg) } #endif - -#ifdef BENCHMARKS /* * Performance test: measure the time spent computing the SHA256 sum of a * message of the specified length. @@ -226,7 +224,6 @@ t_sha256_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -258,15 +255,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_sha256_short_updates, &t_sha256_vectors[4], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_sha256_perf, &one, - "performance test (1 byte)"); - t_add_test(t_sha256_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_sha256_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_sha256_perf, &one, + "performance test (1 byte)"); + t_add_test(t_sha256_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_sha256_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_sha384.c b/t/t_sha384.c index 840677e..b175cc9 100644 --- a/t/t_sha384.c +++ b/t/t_sha384.c @@ -205,7 +205,7 @@ t_sha384_short_updates(char **desc CRYB_UNUSED, void *arg) } #endif -#ifdef BENCHMARKS + /* * Performance test: measure the time spent computing the SHA384 sum of a * message of the specified length. @@ -236,7 +236,6 @@ t_sha384_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -268,15 +267,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_sha384_short_updates, &t_sha384_vectors[4], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_sha384_perf, &one, - "performance test (1 byte)"); - t_add_test(t_sha384_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_sha384_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_sha384_perf, &one, + "performance test (1 byte)"); + t_add_test(t_sha384_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_sha384_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); } diff --git a/t/t_sha512.c b/t/t_sha512.c index 8df17b0..cb01ceb 100644 --- a/t/t_sha512.c +++ b/t/t_sha512.c @@ -216,7 +216,6 @@ t_sha512_short_updates(char **desc CRYB_UNUSED, void *arg) #endif -#ifdef BENCHMARKS /* * Performance test: measure the time spent computing the SHA512 sum of a * message of the specified length. @@ -247,7 +246,6 @@ t_sha512_perf(char **desc, void *arg) *desc = comment; return (1); } -#endif /*************************************************************************** @@ -279,15 +277,15 @@ t_prepare(int argc, char *argv[]) t_add_test(t_sha512_short_updates, &t_sha512_vectors[4], "multiple short updates"); #endif -#ifdef BENCHMARKS - static size_t one = 1, thousand = 1000, million = 1000000; - t_add_test(t_sha512_perf, &one, - "performance test (1 byte)"); - t_add_test(t_sha512_perf, &thousand, - "performance test (1,000 bytes)"); - t_add_test(t_sha512_perf, &million, - "performance test (1,000,000 bytes)"); -#endif + if (getenv("CRYB_PERFTEST")) { + static size_t one = 1, thousand = 1000, million = 1000000; + t_add_test(t_sha512_perf, &one, + "performance test (1 byte)"); + t_add_test(t_sha512_perf, &thousand, + "performance test (1,000 bytes)"); + t_add_test(t_sha512_perf, &million, + "performance test (1,000,000 bytes)"); + } return (0); }