Generate simple build test files
authorRichard Levitte <levitte@openssl.org>
Fri, 3 Jun 2016 13:02:10 +0000 (15:02 +0200)
committerRichard Levitte <levitte@openssl.org>
Fri, 3 Jun 2016 23:22:08 +0000 (01:22 +0200)
Generate small test programs to check that external programs can be
built with our stuff at a very basic level.

For now, they check that each of our header files can be included
individually without compile failure.

Reviewed-by: Rich Salz <rsalz@openssl.org>
test/build.info
test/generate_buildtest.pl [new file with mode: 0644]

index 84c881e..95afbe3 100644 (file)
@@ -1,4 +1,4 @@
-{- use File::Spec::Functions qw/catdir rel2abs/; -}
+{- use File::Spec::Functions qw/catdir catfile rel2abs abs2rel updir/; -}
 IF[{- !$disabled{tests} -}]
   PROGRAMS=\
           aborttest \
@@ -254,4 +254,30 @@ IF[{- !$disabled{tests} -}]
   SOURCE[bioprinttest]=bioprinttest.c
   INCLUDE[bioprinttest]={- rel2abs(catdir($builddir,"../include")) -} ../include
   DEPEND[bioprinttest]=../libcrypto
+  {-
+   use File::Basename;
+   use if $^O ne "VMS", 'File::Glob' => qw/glob/;
+
+   my $includes = join(" ",
+                       rel2abs(catdir($builddir,"../include")), "../include");
+   my @nogo_headers = ( "asn1_mac.h",
+                        "__decc_include_prologue.h",
+                        "__decc_include_epilogue.h" );
+   my @headerfiles = glob catfile($sourcedir,
+                                  updir(), "include", "openssl", "*.h");
+
+   foreach my $headerfile (@headerfiles) {
+       my $name = basename($headerfile, ".h");
+       next if $disabled{$name};
+       next if grep { $_ eq lc("$name.h") } @nogo_headers;
+       $OUT .= <<"_____";
+
+  PROGRAMS=buildtest_$name
+  GENERATE[buildtest_$name.c]=generate_buildtest.pl $name
+  SOURCE[buildtest_$name]=buildtest_$name.c
+  INCLUDE[buildtest_$name]=$includes
+  DEPEND[buildtest_$name]=../libssl ../libcrypto
+_____
+   }
+  -}
 ENDIF
diff --git a/test/generate_buildtest.pl b/test/generate_buildtest.pl
new file mode 100644 (file)
index 0000000..7921021
--- /dev/null
@@ -0,0 +1,27 @@
+#! /usr/bin/env perl
+# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+use strict;
+use warnings;
+
+# First argument is name;
+my $name = shift @ARGV;
+# All other arguments are ignored for now
+
+print <<"_____";
+/*
+ * Generated with test/generate_buildtest.pl, to check that such a simple
+ * program builds.
+ */
+#include <openssl/$name.h>
+
+int main()
+{
+    return 0;
+}
+_____