From: Peter Zotov <whitequark@whitequark.org>
Date: Mon, 3 Nov 2014 09:50:53 +0000 (+0000)
Subject: [OCaml] Run tests twice, with ocamlc and ocamlopt (if available)
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=95a8dca3dbab8f099dceac31145e81c5839cace1;p=oota-llvm.git

[OCaml] Run tests twice, with ocamlc and ocamlopt (if available)

ocamlc and ocamlopt expose a distinct set of buildsystem bugs, e.g.
only ocamlc would detect -custom or -dllib-related bugs, and as all
buildbots will have ocamlopt, these bugs will stay hidden.

This change should add no more than 30 seconds of testing time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221137 91177308-0d34-0410-b5e6-96231b3b80d8
---

diff --git a/test/Bindings/OCaml/analysis.ml b/test/Bindings/OCaml/analysis.ml
index 68d5d65e122..e935ee83805 100644
--- a/test/Bindings/OCaml/analysis.ml
+++ b/test/Bindings/OCaml/analysis.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/analysis.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/bitreader.ml b/test/Bindings/OCaml/bitreader.ml
index 81db5431aef..57cfd043b2d 100644
--- a/test/Bindings/OCaml/bitreader.ml
+++ b/test/Bindings/OCaml/bitreader.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/bitreader.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitreader.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitreader.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitreader.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
diff --git a/test/Bindings/OCaml/bitwriter.ml b/test/Bindings/OCaml/bitwriter.ml
index 5d77b83bd6e..7c803f6d551 100644
--- a/test/Bindings/OCaml/bitwriter.ml
+++ b/test/Bindings/OCaml/bitwriter.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/bitwriter.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitwriter.ml -o %t
+ * RUN: %ocamlc -g -w -3 -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitwriter.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -w -3 -warn-error A -package llvm.bitreader -package llvm.bitwriter -linkpkg %T/bitwriter.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
diff --git a/test/Bindings/OCaml/core.ml b/test/Bindings/OCaml/core.ml
index 087f9d35b87..c08351ec234 100644
--- a/test/Bindings/OCaml/core.ml
+++ b/test/Bindings/OCaml/core.ml
@@ -1,5 +1,7 @@
-(* RUN: cp %s %T/vmcore.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.analysis -package llvm.bitwriter -linkpkg %T/vmcore.ml -o %t
+(* RUN: cp %s %T/core.ml
+ * RUN: %ocamlc -g -warn-error A -package llvm.analysis -package llvm.bitwriter -linkpkg %T/core.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.analysis -package llvm.bitwriter -linkpkg %T/core.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc > %t.ll
  * RUN: FileCheck %s < %t.ll
diff --git a/test/Bindings/OCaml/executionengine.ml b/test/Bindings/OCaml/executionengine.ml
index 9f1b74f8ee0..893f9888764 100644
--- a/test/Bindings/OCaml/executionengine.ml
+++ b/test/Bindings/OCaml/executionengine.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/executionengine.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.executionengine -linkpkg %T/executionengine.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.executionengine -linkpkg %T/executionengine.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.executionengine -linkpkg %T/executionengine.ml -o %t
  * RUN: %t
  * REQUIRES: native, object-emission
  * XFAIL: vg_leak
diff --git a/test/Bindings/OCaml/ext_exc.ml b/test/Bindings/OCaml/ext_exc.ml
index 7d40c2847a6..2b44803f517 100644
--- a/test/Bindings/OCaml/ext_exc.ml
+++ b/test/Bindings/OCaml/ext_exc.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/ext_exc.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.bitreader -linkpkg %T/ext_exc.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/ipo.ml b/test/Bindings/OCaml/ipo.ml
index e395424d334..fc728b92ff3 100644
--- a/test/Bindings/OCaml/ipo.ml
+++ b/test/Bindings/OCaml/ipo.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/ipo_opts.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.ipo -linkpkg %T/ipo_opts.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.ipo -linkpkg %T/ipo_opts.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.ipo -linkpkg %T/ipo_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/irreader.ml b/test/Bindings/OCaml/irreader.ml
index a64e01a4013..e1771e75dd4 100644
--- a/test/Bindings/OCaml/irreader.ml
+++ b/test/Bindings/OCaml/irreader.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/irreader.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.irreader -linkpkg %T/irreader.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.irreader -linkpkg %T/irreader.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.irreader -linkpkg %T/irreader.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/linker.ml b/test/Bindings/OCaml/linker.ml
index 6ec87bfc5c2..00064b0ba92 100644
--- a/test/Bindings/OCaml/linker.ml
+++ b/test/Bindings/OCaml/linker.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/linker.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.linker -linkpkg %T/linker.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.linker -linkpkg %T/linker.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.linker -linkpkg %T/linker.ml -o %t
  * RUN: %t
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/passmgr_builder.ml b/test/Bindings/OCaml/passmgr_builder.ml
index cc8e9fcb0d0..5dd9d4e00e8 100644
--- a/test/Bindings/OCaml/passmgr_builder.ml
+++ b/test/Bindings/OCaml/passmgr_builder.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/passmgr_builder.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.passmgr_builder -linkpkg %T/passmgr_builder.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.passmgr_builder -linkpkg %T/passmgr_builder.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.passmgr_builder -linkpkg %T/passmgr_builder.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/scalar_opts.ml b/test/Bindings/OCaml/scalar_opts.ml
index c3b4f6673ee..3017fb13112 100644
--- a/test/Bindings/OCaml/scalar_opts.ml
+++ b/test/Bindings/OCaml/scalar_opts.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/scalar_opts.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/target.ml b/test/Bindings/OCaml/target.ml
index e532ad55ebf..41faefa8ea6 100644
--- a/test/Bindings/OCaml/target.ml
+++ b/test/Bindings/OCaml/target.ml
@@ -1,5 +1,6 @@
 (* RUN: cp %s %T/target.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.target -package llvm.all_backends -linkpkg %T/target.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.target -package llvm.all_backends -linkpkg %T/target.ml -o %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.target -package llvm.all_backends -linkpkg %T/target.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
diff --git a/test/Bindings/OCaml/vectorize.ml b/test/Bindings/OCaml/vectorize.ml
index 536adac8c33..c5b03b52537 100644
--- a/test/Bindings/OCaml/vectorize.ml
+++ b/test/Bindings/OCaml/vectorize.ml
@@ -1,5 +1,7 @@
 (* RUN: cp %s %T/vectorize_opts.ml
- * RUN: %ocamlcomp -g -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t
+ * RUN: %ocamlc -g -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t
+ * RUN: %t %t.bc
+ * RUN: %ocamlopt -g -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t
  * RUN: %t %t.bc
  * XFAIL: vg_leak
  *)
diff --git a/test/lit.cfg b/test/lit.cfg
index 335b86dae7d..67c9bbae744 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -102,13 +102,22 @@ for options in ['ASAN_OPTIONS', 'UBSAN_OPTIONS']:
 
 # Set up OCAMLPATH to include newly built OCaml libraries.
 llvm_lib_dir = getattr(config, 'llvm_lib_dir', None)
-if llvm_lib_dir: # empty llvm_lib_dir is falsey, reads as None
-    llvm_ocaml_lib = os.path.join(llvm_lib_dir, 'ocaml')
-    if 'OCAMLPATH' in os.environ:
-        ocamlpath = os.path.pathsep.join((llvm_ocaml_lib, os.environ['OCAMLPATH']))
-        config.environment['OCAMLPATH'] = ocamlpath
-    else:
-        config.environment['OCAMLPATH'] = llvm_ocaml_lib
+if not llvm_lib_dir:
+    llvm_lib_dir = os.path.join(getattr(config, 'llvm_obj_root', None), 'lib')
+
+llvm_ocaml_lib = os.path.join(llvm_lib_dir, 'ocaml')
+if 'OCAMLPATH' in os.environ:
+    ocamlpath = os.path.pathsep.join((llvm_ocaml_lib, os.environ['OCAMLPATH']))
+    config.environment['OCAMLPATH'] = ocamlpath
+else:
+    config.environment['OCAMLPATH'] = llvm_ocaml_lib
+
+if 'CAML_LD_LIBRARY_PATH' in os.environ:
+    caml_ld_library_path = os.path.pathsep.join((llvm_ocaml_lib,
+                                os.environ['CAML_LD_LIBRARY_PATH']))
+    config.environment['CAML_LD_LIBRARY_PATH'] = caml_ld_library_path
+else:
+    config.environment['CAML_LD_LIBRARY_PATH'] = caml_ld_library_path
 
 # Set up OCAMLRUNPARAM to enable backtraces in OCaml tests.
 config.environment['OCAMLRUNPARAM'] = 'b'
@@ -188,12 +197,13 @@ config.substitutions.append( ('%python', config.python_executable) )
 
 # OCaml substitutions.
 # Support tests for both native and bytecode builds.
-if config.have_ocamlopt == '1':
-    config.substitutions.append( ('%ocamlcomp',
+config.substitutions.append( ('%ocamlc',
+    "%s ocamlc %s" % (config.ocamlfind_executable, config.ocaml_flags)) )
+if config.have_ocamlopt in ('1', 'TRUE'):
+    config.substitutions.append( ('%ocamlopt',
         "%s ocamlopt %s" % (config.ocamlfind_executable, config.ocaml_flags)) )
 else:
-    config.substitutions.append( ('%ocamlcomp',
-        "%s ocamlc %s" % (config.ocamlfind_executable, config.ocaml_flags)) )
+    config.substitutions.append( ('%ocamlopt', "true" ) )
 
 # For each occurrence of an llvm tool name as its own word, replace it
 # with the full path to the build directory holding that tool.  This