Simplify very simple test recipes further.
authorRichard Levitte <levitte@openssl.org>
Tue, 21 Apr 2015 17:29:01 +0000 (19:29 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 7 Sep 2015 14:10:58 +0000 (16:10 +0200)
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>
30 files changed:
test/recipes/05-test_bf.t
test/recipes/05-test_cast.t
test/recipes/05-test_des.t
test/recipes/05-test_hmac.t
test/recipes/05-test_idea.t
test/recipes/05-test_md2.t
test/recipes/05-test_md4.t
test/recipes/05-test_md5.t
test/recipes/05-test_mdc2.t
test/recipes/05-test_rand.t
test/recipes/05-test_rc2.t
test/recipes/05-test_rc4.t
test/recipes/05-test_rc5.t
test/recipes/05-test_rmd.t
test/recipes/05-test_sha1.t
test/recipes/05-test_sha256.t
test/recipes/05-test_sha512.t
test/recipes/05-test_wp.t
test/recipes/10-test_exp.t
test/recipes/15-test_dh.t
test/recipes/15-test_ecdh.t
test/recipes/15-test_ecdsa.t
test/recipes/90-test_constant_time.t
test/recipes/90-test_heartbeat.t
test/recipes/90-test_ige.t
test/recipes/90-test_jpake.t
test/recipes/90-test_p5_crpt2.t
test/recipes/90-test_srp.t
test/recipes/90-test_v3name.t
test/testlib/OpenSSL/Test/Simple.pm [new file with mode: 0644]

index 70e0d28bf191a527e39ce184aff834cc084bd6c7..4794bf0d842d2401bf28ab49d1578645cf90dbd6 100644 (file)
@@ -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");
index ffb5645af82d584116670c69937d957440d51885..621e1ae739aad969cd03f0158226e16758350b42 100644 (file)
@@ -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");
index 6c293e822dca0d5aa947a685c4e82dc2af25ef06..71de4b47a202491679680dc8cb5776b7954f5a2a 100644 (file)
@@ -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");
index 17fdf77aa8a3acc9be97c6477a3dfa73f18210b9..469d43f14d0369b32eaba705db78c18f442d73a0 100644 (file)
@@ -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");
index 923c1e1e168c9f9bb93f661e88cafc37c8adbc1c..c43ba5c1adc5226f81155472478cc791668eeb85 100644 (file)
@@ -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");
index 4b942aea56e3791e289672fbf21515608f6d01fc..2175c5f41c1a4669f1a7913a7e66449291c7fd47 100644 (file)
@@ -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");
index d5334e1d026e2cdb83e306b0fdb098b2883141be..2337223b47df54d07d9fd968a2b405eed9d82150 100644 (file)
@@ -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");
index 4ac49ffb0f6e7f5c02aedbbcbd105d0a7d5cc224..e9331e24c5f5084654b20f58493b5140a3816af4 100644 (file)
@@ -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");
index 4ba049aed0c99fee7f9f459648b6245d28c3cc91..23e904c292e369abf4ac0a82f6edc81d0fe43738 100644 (file)
@@ -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");
index 220ee86265920e2716b5b8a05e787e219b98d3ab..afa66a666ddacffc6613cde0a0a67b71994dee38 100644 (file)
@@ -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");
index 056067faedf92b2cc4cdc652f5b68ffa303121e2..423b3b7949b1798b98c36155faaec989d2ba4787 100644 (file)
@@ -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");
index a789fe0532d6cf857956c6f22c9baa9f1843350f..a16455fe1fc354b234247a7b068590da83a53441 100644 (file)
@@ -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");
index 6e90937cb4dd29ed622551578eb0650222245a54..4c5390a9c03f5083f8a1f5dd53121022d844c710 100644 (file)
@@ -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");
index 3915cd42f94a847ebde9fa3d5ea9ef643f1bc888..7ad91c4ae4e2432f61fc1176b3e45cb16dab557d 100644 (file)
@@ -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");
index 8f7d2fca9365dd0c4e2557285b3bd21619497564..9f8a570356228879903371ee0a438deb7ed9b3d9 100644 (file)
@@ -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");
index 65088324df2acd34eb68f096d3979ee0c21141ed..cb63aa82d980c791806aaffeae5a58f422024fcb 100644 (file)
@@ -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");
index 9c9bc18b4d857d10418b02181f541b36f60c9cf7..f353ac137321a05e36944c7218fc4c12c81f1f27 100644 (file)
@@ -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");
index 9645670a26d8c8a1e7906cdfcd4d4b8fd7ba6c30..c05be9c5e9e63e6cd8419c47e8660180c468172e 100644 (file)
@@ -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");
index e7bad93f8a467ef1a9615c0a5aed30489c3268f9..b8083e7ad5635c38455e47733d161a53b590732b 100644 (file)
@@ -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");
index 957df4a73914f5455761b739820b7e95f2e31b5f..35e9564438a1dbb6a7b44e4c6df4963f0ea88cac 100644 (file)
@@ -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");
index 4c0d97e729558b5424e13f0ec23e17004a39404e..7cdfea6f91de5409d1437e2bdc17afed711a3f13 100644 (file)
@@ -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");
index 2cd144b3053d2b920f0f47611e8f2e17a6a59cb3..aa4622f9d76a9860b5715b35d6a7a516b1ad5044 100644 (file)
@@ -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");
index 4bdd0a08d0e28058a690973d3652d3de47bf2599..cfdb578e64a4aa8ef61e08f875f6a4f162190b8b 100644 (file)
@@ -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");
index 5e226703a3841d0073a2cb3967fa8db0cd8868c1..660f630f9ecabcd63089f1c9b6f03ce3bf958892 100644 (file)
@@ -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");
index 6c991472c998c0713d95eae3900d152b98d7a34b..f00835008580c676bd53c69338a022fc3a9248b9 100644 (file)
@@ -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");
index 5b83df77077e446c40c1fe1b988a29797cfe863b..fa1292af7460d65db2fb9d42c6adfbac55020088 100644 (file)
@@ -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");
index e03c5b67bee16f3e916e1180194886b8461d816b..838e0d7e4dad67024a9f90b096cf7efe8d67eb6c 100644 (file)
@@ -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");
index 962402043c7c0723c7905b772c9a16700874b5cc..6be2c39ff1b3e26e364853d80dea5609db402d0f 100644 (file)
@@ -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");
index 17ac8b33841c244c8a4ea04984cfdb5db7e6ded7..2a8a47245919c68d7718d8d60cfbce00012a0008 100644 (file)
@@ -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 (file)
index 0000000..94f6cf9
--- /dev/null
@@ -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");
+    }
+}