summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2015-04-21 19:29:01 +0200
committerRichard Levitte <levitte@openssl.org>2015-09-07 16:10:58 +0200
commit93de4f58ef8be2cb764343cb3102d41c81f11593 (patch)
tree24240fe186ce101496f758d80e22a7bb03879129
parentRemove test targets from Makefile, have it use run_tests.pl (diff)
downloadopenssl-93de4f58ef8be2cb764343cb3102d41c81f11593.tar.xz
openssl-93de4f58ef8be2cb764343cb3102d41c81f11593.zip
Simplify very simple test recipes further.
Very simple test recipes easily become tedious, so they might benefit from being made as simple as possible. Therefore, OpenSSL::Test::Simple is born. It currently provides but one function, simple_test(), which takes a minimum of two parameters (test name and program to run), with the optional third, being the algorithm to be checked for before running the test itself. All recipes with that simple thing to do have been rewritten to be as minimal as possible. Reviewed-by: Rich Salz <rsalz@openssl.org>
-rw-r--r--test/recipes/05-test_bf.t11
-rw-r--r--test/recipes/05-test_cast.t11
-rw-r--r--test/recipes/05-test_des.t11
-rw-r--r--test/recipes/05-test_hmac.t11
-rw-r--r--test/recipes/05-test_idea.t11
-rw-r--r--test/recipes/05-test_md2.t11
-rw-r--r--test/recipes/05-test_md4.t11
-rw-r--r--test/recipes/05-test_md5.t11
-rw-r--r--test/recipes/05-test_mdc2.t11
-rw-r--r--test/recipes/05-test_rand.t11
-rw-r--r--test/recipes/05-test_rc2.t11
-rw-r--r--test/recipes/05-test_rc4.t11
-rw-r--r--test/recipes/05-test_rc5.t11
-rw-r--r--test/recipes/05-test_rmd.t11
-rw-r--r--test/recipes/05-test_sha1.t11
-rw-r--r--test/recipes/05-test_sha256.t11
-rw-r--r--test/recipes/05-test_sha512.t11
-rw-r--r--test/recipes/05-test_wp.t11
-rw-r--r--test/recipes/10-test_exp.t11
-rw-r--r--test/recipes/15-test_dh.t11
-rw-r--r--test/recipes/15-test_ecdh.t11
-rw-r--r--test/recipes/15-test_ecdsa.t11
-rw-r--r--test/recipes/90-test_constant_time.t11
-rw-r--r--test/recipes/90-test_heartbeat.t11
-rw-r--r--test/recipes/90-test_ige.t11
-rw-r--r--test/recipes/90-test_jpake.t11
-rw-r--r--test/recipes/90-test_p5_crpt2.t11
-rw-r--r--test/recipes/90-test_srp.t11
-rw-r--r--test/recipes/90-test_v3name.t11
-rw-r--r--test/testlib/OpenSSL/Test/Simple.pm32
30 files changed, 90 insertions, 261 deletions
diff --git a/test/recipes/05-test_bf.t b/test/recipes/05-test_bf.t
index 70e0d28bf1..4794bf0d84 100644
--- a/test/recipes/05-test_bf.t
+++ b/test/recipes/05-test_bf.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_bf");
-
-plan tests => 1;
-ok(run(test(["bftest"])), "running bftest");
+simple_test("test_bf", "bftest", "bf");
diff --git a/test/recipes/05-test_cast.t b/test/recipes/05-test_cast.t
index ffb5645af8..621e1ae739 100644
--- a/test/recipes/05-test_cast.t
+++ b/test/recipes/05-test_cast.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_cast");
-
-plan tests => 1;
-ok(run(test(["casttest"])), "running casttest");
+simple_test("test_cast", "casttest", "cast");
diff --git a/test/recipes/05-test_des.t b/test/recipes/05-test_des.t
index 6c293e822d..71de4b47a2 100644
--- a/test/recipes/05-test_des.t
+++ b/test/recipes/05-test_des.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_des");
-
-plan tests => 1;
-ok(run(test(["destest"])), "running destest");
+simple_test("test_des", "destest", "des");
diff --git a/test/recipes/05-test_hmac.t b/test/recipes/05-test_hmac.t
index 17fdf77aa8..469d43f14d 100644
--- a/test/recipes/05-test_hmac.t
+++ b/test/recipes/05-test_hmac.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_hmac");
-
-plan tests => 1;
-ok(run(test(["hmactest"])), "running hmactest");
+simple_test("test_hmac", "hmactest", "hmac");
diff --git a/test/recipes/05-test_idea.t b/test/recipes/05-test_idea.t
index 923c1e1e16..c43ba5c1ad 100644
--- a/test/recipes/05-test_idea.t
+++ b/test/recipes/05-test_idea.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_idea");
-
-plan tests => 1;
-ok(run(test(["ideatest"])), "running ideatest");
+simple_test("test_idea", "ideatest", "idea");
diff --git a/test/recipes/05-test_md2.t b/test/recipes/05-test_md2.t
index 4b942aea56..2175c5f41c 100644
--- a/test/recipes/05-test_md2.t
+++ b/test/recipes/05-test_md2.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_md2");
-
-plan tests => 1;
-ok(run(test(["md2test"])), "running md2test");
+simple_test("test_md2", "md2test", "md2");
diff --git a/test/recipes/05-test_md4.t b/test/recipes/05-test_md4.t
index d5334e1d02..2337223b47 100644
--- a/test/recipes/05-test_md4.t
+++ b/test/recipes/05-test_md4.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_md4");
-
-plan tests => 1;
-ok(run(test(["md4test"])), "running md4test");
+simple_test("test_md4", "md4test", "md4");
diff --git a/test/recipes/05-test_md5.t b/test/recipes/05-test_md5.t
index 4ac49ffb0f..e9331e24c5 100644
--- a/test/recipes/05-test_md5.t
+++ b/test/recipes/05-test_md5.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_md5");
-
-plan tests => 1;
-ok(run(test(["md5test"])), "running md5test");
+simple_test("test_md5", "md5test", "md5");
diff --git a/test/recipes/05-test_mdc2.t b/test/recipes/05-test_mdc2.t
index 4ba049aed0..23e904c292 100644
--- a/test/recipes/05-test_mdc2.t
+++ b/test/recipes/05-test_mdc2.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_mdc2");
-
-plan tests => 1;
-ok(run(test(["mdc2test"])), "running mdc2test");
+simple_test("test_mdc2", "mdc2test", "mdc2");
diff --git a/test/recipes/05-test_rand.t b/test/recipes/05-test_rand.t
index 220ee86265..afa66a666d 100644
--- a/test/recipes/05-test_rand.t
+++ b/test/recipes/05-test_rand.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_rand");
-
-plan tests => 1;
-ok(run(test(["randtest"])), "running randtest");
+simple_test("test_rand", "randtest", "rand");
diff --git a/test/recipes/05-test_rc2.t b/test/recipes/05-test_rc2.t
index 056067faed..423b3b7949 100644
--- a/test/recipes/05-test_rc2.t
+++ b/test/recipes/05-test_rc2.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_rc2");
-
-plan tests => 1;
-ok(run(test(["rc2test"])), "running rc2test");
+simple_test("test_rc2", "rc2test", "rc2");
diff --git a/test/recipes/05-test_rc4.t b/test/recipes/05-test_rc4.t
index a789fe0532..a16455fe1f 100644
--- a/test/recipes/05-test_rc4.t
+++ b/test/recipes/05-test_rc4.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_rc4");
-
-plan tests => 1;
-ok(run(test(["rc4test"])), "running rc4test");
+simple_test("test_rc4", "rc4test", "rc4");
diff --git a/test/recipes/05-test_rc5.t b/test/recipes/05-test_rc5.t
index 6e90937cb4..4c5390a9c0 100644
--- a/test/recipes/05-test_rc5.t
+++ b/test/recipes/05-test_rc5.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_rc5");
-
-plan tests => 1;
-ok(run(test(["rc5test"])), "running rc5test");
+simple_test("test_rc5", "rc5test", "rc5");
diff --git a/test/recipes/05-test_rmd.t b/test/recipes/05-test_rmd.t
index 3915cd42f9..7ad91c4ae4 100644
--- a/test/recipes/05-test_rmd.t
+++ b/test/recipes/05-test_rmd.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_rmd");
-
-plan tests => 1;
-ok(run(test(["rmdtest"])), "running rmdtest");
+simple_test("test_rmd", "rmdtest", "rmd");
diff --git a/test/recipes/05-test_sha1.t b/test/recipes/05-test_sha1.t
index 8f7d2fca93..9f8a570356 100644
--- a/test/recipes/05-test_sha1.t
+++ b/test/recipes/05-test_sha1.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_sha1");
-
-plan tests => 1;
-ok(run(test(["sha1test"])), "running sha1test");
+simple_test("test_sha1", "sha1test", "sha1");
diff --git a/test/recipes/05-test_sha256.t b/test/recipes/05-test_sha256.t
index 65088324df..cb63aa82d9 100644
--- a/test/recipes/05-test_sha256.t
+++ b/test/recipes/05-test_sha256.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_sha256");
-
-plan tests => 1;
-ok(run(test(["sha256t"])), "running sha256t");
+simple_test("test_sha256", "sha256t", "sha256");
diff --git a/test/recipes/05-test_sha512.t b/test/recipes/05-test_sha512.t
index 9c9bc18b4d..f353ac1373 100644
--- a/test/recipes/05-test_sha512.t
+++ b/test/recipes/05-test_sha512.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_sha512");
-
-plan tests => 1;
-ok(run(test(["sha512t"])), "running sha512t");
+simple_test("test_sha512", "sha512t", "sha512");
diff --git a/test/recipes/05-test_wp.t b/test/recipes/05-test_wp.t
index 9645670a26..c05be9c5e9 100644
--- a/test/recipes/05-test_wp.t
+++ b/test/recipes/05-test_wp.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_wp");
-
-plan tests => 1;
-ok(run(test(["wp_test"])), "running wp_test");
+simple_test("test_wp", "wptest", "wp");
diff --git a/test/recipes/10-test_exp.t b/test/recipes/10-test_exp.t
index e7bad93f8a..b8083e7ad5 100644
--- a/test/recipes/10-test_exp.t
+++ b/test/recipes/10-test_exp.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_exp");
-
-plan tests => 1;
-ok(run(test(["exptest"])), "running exptest");
+simple_test("test_exp", "exptest");
diff --git a/test/recipes/15-test_dh.t b/test/recipes/15-test_dh.t
index 957df4a739..35e9564438 100644
--- a/test/recipes/15-test_dh.t
+++ b/test/recipes/15-test_dh.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_dh");
-
-plan tests => 1;
-ok(run(test(["dhtest"])), "running dhtest");
+simple_test("test_dh", "dhtest", "dh");
diff --git a/test/recipes/15-test_ecdh.t b/test/recipes/15-test_ecdh.t
index 4c0d97e729..7cdfea6f91 100644
--- a/test/recipes/15-test_ecdh.t
+++ b/test/recipes/15-test_ecdh.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_ecdh");
-
-plan tests => 1;
-ok(run(test(["ecdhtest"])), "running ecdhtest");
+simple_test("test_ecdh", "ecdhtest", "ecdh");
diff --git a/test/recipes/15-test_ecdsa.t b/test/recipes/15-test_ecdsa.t
index 2cd144b305..aa4622f9d7 100644
--- a/test/recipes/15-test_ecdsa.t
+++ b/test/recipes/15-test_ecdsa.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_ecdsa");
-
-plan tests => 1;
-ok(run(test(["ecdsatest"])), "running ecdsatest");
+simple_test("test_ecdsa", "ecdsatest", "ecdsa");
diff --git a/test/recipes/90-test_constant_time.t b/test/recipes/90-test_constant_time.t
index 4bdd0a08d0..cfdb578e64 100644
--- a/test/recipes/90-test_constant_time.t
+++ b/test/recipes/90-test_constant_time.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_constant_time");
-
-plan tests => 1;
-ok(run(test(["constant_time_test"])), "running constant_time_test");
+simple_test("test_constant_time", "constant_time_test");
diff --git a/test/recipes/90-test_heartbeat.t b/test/recipes/90-test_heartbeat.t
index 5e226703a3..660f630f9e 100644
--- a/test/recipes/90-test_heartbeat.t
+++ b/test/recipes/90-test_heartbeat.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_heartbeat");
-
-plan tests => 1;
-ok(run(test(["heartbeat_test"])), "running heartbeat_test");
+simple_test("test_heartbeat", "heartbeat_test");
diff --git a/test/recipes/90-test_ige.t b/test/recipes/90-test_ige.t
index 6c991472c9..f008350085 100644
--- a/test/recipes/90-test_ige.t
+++ b/test/recipes/90-test_ige.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_ige");
-
-plan tests => 1;
-ok(run(test(["igetest"])), "running igetest");
+simple_test("test_ige", "igetest");
diff --git a/test/recipes/90-test_jpake.t b/test/recipes/90-test_jpake.t
index 5b83df7707..fa1292af74 100644
--- a/test/recipes/90-test_jpake.t
+++ b/test/recipes/90-test_jpake.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_jpake");
-
-plan tests => 1;
-ok(run(test(["jpaketest"])), "running jpaketest");
+simple_test("test_jpake", "jpaketest");
diff --git a/test/recipes/90-test_p5_crpt2.t b/test/recipes/90-test_p5_crpt2.t
index e03c5b67be..838e0d7e4d 100644
--- a/test/recipes/90-test_p5_crpt2.t
+++ b/test/recipes/90-test_p5_crpt2.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_p5_crpt2");
-
-plan tests => 1;
-ok(run(test(["p5_crpt2_test"])), "running p5_crpt2_test");
+simple_test("test_p5_crpt2", "p5_crpt2_test");
diff --git a/test/recipes/90-test_srp.t b/test/recipes/90-test_srp.t
index 962402043c..6be2c39ff1 100644
--- a/test/recipes/90-test_srp.t
+++ b/test/recipes/90-test_srp.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_srp");
-
-plan tests => 1;
-ok(run(test(["srptest"])), "running srptest");
+simple_test("test_srp", "srptest");
diff --git a/test/recipes/90-test_v3name.t b/test/recipes/90-test_v3name.t
index 17ac8b3384..2a8a472459 100644
--- a/test/recipes/90-test_v3name.t
+++ b/test/recipes/90-test_v3name.t
@@ -1,12 +1,5 @@
#! /usr/bin/perl
-use strict;
-use warnings;
+use OpenSSL::Test::Simple;
-use Test::More;
-use OpenSSL::Test;
-
-setup("test_v3name");
-
-plan tests => 1;
-ok(run(test(["v3nametest"])), "running v3nametest");
+simple_test("test_v3name", "v3nametest");
diff --git a/test/testlib/OpenSSL/Test/Simple.pm b/test/testlib/OpenSSL/Test/Simple.pm
new file mode 100644
index 0000000000..94f6cf935b
--- /dev/null
+++ b/test/testlib/OpenSSL/Test/Simple.pm
@@ -0,0 +1,32 @@
+package OpenSSL::Test::Simple;
+
+use strict;
+use warnings;
+
+use Exporter;
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+$VERSION = "0.1";
+@ISA = qw(Exporter);
+@EXPORT = qw(simple_test);
+
+
+use Test::More;
+use OpenSSL::Test;
+
+# args:
+# name (used with setup())
+# algorithm (used to check if it's at all supported)
+# name of binary (the program that does the actual test)
+sub simple_test {
+ my ($name, $prgr, $algo, @rest) = @_;
+
+ setup($name);
+
+ plan tests => 1;
+ SKIP: {
+ skip "$algo is not supported by this OpenSSL build, skipping this test...", 1
+ if $algo && run(app(["openssl", "no-$algo"]));
+
+ ok(run(test([$prgr])), "running $prgr");
+ }
+}