Blob Blame History Raw
From 89a1e4be8bccf793478fc07aac7003121de73dc3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Mon, 27 Apr 2015 16:01:52 +0200
Subject: [PATCH] Skip prime-field tests if OpenSSL does not suppport EC2M
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

prime-field.t exhibits many function calls with arguments that are not
support by OpenSSL if it was built without EC2M support.

It's easier to skip all the tests instead of skipping almost all of
them. This patch does that if <openssl/opensslconf.h> defines
OPENSSL_NO_EC2M.

Signed-off-by: Petr Písař <ppisar@redhat.com>

diff --git a/Makefile.PL b/Makefile.PL
index edacc74..4290278 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -10,6 +10,9 @@ WriteMakefile(
     NAME              => 'Crypt::OpenSSL::EC',
     VERSION_FROM      => 'lib/Crypt/OpenSSL/EC.pm',
     PREREQ_PM         => { 'Crypt::OpenSSL::Bignum' => 0.04,
+                           'ExtUtils::CBuilder' => 0,
+                           'File::Spec' => 0,
+                           'File::Temp' => 0,
                           }, 
     ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
       (ABSTRACT_FROM  => 'lib/Crypt/OpenSSL/EC.pm', # retrieve abstract from module
diff --git a/t/prime-field.t b/t/prime-field.t
index 0a9a2d9..033c0bf 100644
--- a/t/prime-field.t
+++ b/t/prime-field.t
@@ -7,7 +7,34 @@ use Crypt::OpenSSL::Bignum::CTX;
 
 BEGIN { use_ok('Crypt::OpenSSL::EC') };
 
-&prime_field_tests();
+
+# Check OpenSSL supports EC2M
+my $no_ec2m = 1;
+{
+    use File::Spec;
+    use File::Temp;
+    use ExtUtils::CBuilder;
+    my $dir = File::Temp::tempdir(CLEANUP => 1);
+    my $file = File::Spec->catfile($dir, 'test.c');
+    open my $fh, '>', $file or die;
+    print $fh <<TEST;
+#include <openssl/opensslconf.h>
+#ifdef OPENSSL_NO_EC2M
+#error EC2M disabled
+#endif
+TEST
+    close $fh or die;
+    my $object;
+    eval { $object = ExtUtils::CBuilder->new->compile(source => $file) };
+    if (defined $object) {
+        $no_ec2m = 0;
+    }
+}
+
+SKIP: {
+    skip('OpenSSL does not support EC2M', 262) if $no_ec2m;
+    &prime_field_tests();
+};
 
 sub prime_field_tests()
 {
-- 
2.1.0