testsuite/in_prefix/README.md
This directory performs tests on the compiler after it has been installed to the
prefix given to configure. The test requires at least the Unix library to have
been compiled, and only works if bindir and libdir share a common root directory
(e.g. /usr/bin and /usr/lib/ocaml share a common root of /usr, but /bin and
/lib/ocaml do not share a common root directory). The test needs to be able to
rename this common root directory by adding a suffix ".new". For this reason,
the test intentionally uses a non-standard Makefile filename and a specific
target giving make -f Makefile.test -C testsuite/in_prefix test-in-prefix. The
test should always restore the common root directory to its original name.
At its most basic level, the test validates the install target of the build
system. For this reason, the test driver takes the expected configuration of the
compiler as command line parameters, rather than probing it (for example
--with-ocamlopt is passed, rather than relying on the detection of the
ocamlopt binary).
The test battery consists of five individual tests:
Dynlink (skipped for --disable-native-compiler)--disable-native-toplevel)CAML_LD_LIBRARY_PATH and ld.conf by ocamlrun and ocamlc-vnumprint_endline Config.standard_library
application with the fourteen compilation mechanisms (tests requiring the
shared runtime are skipped for --disable-shared or on Windows, where it is
isn't available and native mode tests are skipped for
--disable-native-compiler):
-custom running on the static/shared runtime-output-complete-exe on the static/shared
runtime-output-obj linked with the
static/shared runtime-output-complete-obj linked with the
static/shared runtimeHaving executed this battery on the configured prefix, the test then renames the
common root directory, appending the suffix .new. The programs compiled in the
fifth test are re-run and then the entire battery is executed a second time.
During this second execution, the test harness does whatever is physically possible to allow these tests to proceed:
CAML_LD_LIBRARY_PATH and OCAMLLIB are manipulated to
allow the compiler to operate (unless the compiler has been configured with
--with-relative-libdir)ocamlrun are
explicitly passed to ocamlrun. The harness always verifies that this step is
required by first executing the binary and ensuring that it fails and then
passing it directly to ocamlrun.In these descriptions, the Shims section describes the adjustments necessary for the second phase of testing after the common root directory has been renamed.
ocaml / ocamlnatVerifies that all the .cma files built from otherlibs/ (dynlink,
runtime_events, str, threads and unix) can be loaded in the two toplevels.
This test is skipped on builds which don't support shared libraries.
Exercises:
CAML_LD_LIBRARY_PATH and ld.conf logic (locating C stubs)CAMLextern header attribute for Windows (RELOC_REL32, etc.)Shims:
ocamlrun,
so must be explicitly invoked via ocamlrun, unless the compiler is
configured with --enable-runtime-searchOCAMLLIB to be set, unless the compiler was configured with
--with-relative-libdirDynlinkAs for the toplevel test, but using the Dynlink library.
Shims:
ocamlc contains the absolute location of
ocamlrun, so must be explicitly invoked via ocamlrun (if the native
compiler is available, then both ocamlc and ocamlopt will be native
executables), unless the compiler is configured with --enable-runtime-searchOCAMLLIB to be set, unless the comnpiler was configured with
--with-relative-libdirocamlc contains the absolute location of
ocamlrun, so must be explicitly invoked via ocamlrun, unless the
compiler is configured with --enable-runtime-search-target-vnumThis test looks for filenames matching flexlink* and ocaml* in bindir. For
each name matched, if the file ends with the bytecode magic number, then that
program is executed with -vnum.
Additionally, for native Windows, executables are additionally called with -M
as an argument, both with and without the .exe. This exercises a known bug in
the hand-off between the executable launcher (stdlib/header.c) and ocamlrun
where, for example, ocamlc.byte when resolved in PATH just runs as though it
were ocamlrun. The test works on the basis that -M is only a valid argument
for ocamlrun (returning the magic number).
Exercises:
ocamlc for computing the "shebang"
headerocamlrunShims:
ocamlrun and will fail to execute, unless the compiler
was configured with --enable-runtime-searchocamldebug and ocamldoc) are compiled with
-custom and do succeedocamlrun. The reason for this is that some of
the binaries (in particular, ocamlmktop) invoke another executable (in
ocamlmktop's case, ocamlc) which will itself fail if ocamlc is a
bytecode executableThis battery of tests exercises each of the compilation mechanisms available in
OCaml with a simple test program linked with the ocamlcommon library which
displays the location of the Standard Library (as determined by
Config.standard_library) and checks whether that directory exists.
Each of the executables is additionally called with a variety of Sys.argv.(0)
values testing:
Sys.argv.(0) which won't resolve in
`PATH)./prog). is not in PATH (i.e. prog). in PATH (i.e. PATH=".:$PATH" prog)$PWD/prog)Exercises:
ocamlc ("tendered bytecode") and ocamlopt
(static executables)-custom and -output-complete-exe modes of ocamlc with both the default
static runtime and the shared runtime (libcamlrun_shared/libasmrun_shared)-output-obj and -output-complete-obj
with both the static and shared runtimesSys.argv.(0) and Sys.executable_nameShims:
Dynlink test, on bytecode-only builds the compiler must be
explicitly invoked via ocamlrun, unless the compiler was configured with
--enable-runtime-searchocamlc by default contains the absolute location
of ocamlrun and so has to be run explicitly via ocamlrun, unless the
compiler was configured with --enable-runtime-search-target