summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2017-11-15 18:14:25 +0100
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2017-11-23 17:04:57 +0100
commit50e62852f383784cab422d39359e5a4387423b36 (patch)
tree47f7e110bcb2091f1df4e438e1bb3f42090264e9
parentf0b9b8e9c40d97c99e1a031c4e220992fe33347f (diff)
downloadocaml-50e62852f383784cab422d39359e5a4387423b36.tar.gz
Migrate testsuite/tests/lib-unix/unix-execvpe
-rw-r--r--testsuite/tests/lib-unix/unix-execvpe/Makefile32
-rw-r--r--testsuite/tests/lib-unix/unix-execvpe/exec.ml8
-rwxr-xr-xtestsuite/tests/lib-unix/unix-execvpe/exec.run16
-rwxr-xr-xtestsuite/tests/lib-unix/unix-execvpe/has-execvpe11
-rw-r--r--testsuite/tests/lib-unix/unix-execvpe/ocamltests1
5 files changed, 31 insertions, 37 deletions
diff --git a/testsuite/tests/lib-unix/unix-execvpe/Makefile b/testsuite/tests/lib-unix/unix-execvpe/Makefile
deleted file mode 100644
index 91fbaa83c3..0000000000
--- a/testsuite/tests/lib-unix/unix-execvpe/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-BASEDIR=../../..
-LIBRARIES=unix
-ADD_COMPFLAGS=-I $(OTOPDIR)/otherlibs/$(UNIXLIBVAR)unix
-LD_PATH=$(TOPDIR)/otherlibs/$(UNIXLIBVAR)unix
-MAIN_MODULE=exec
-
-test:
- @if grep -q HAS_EXECVPE $(OTOPDIR)/byterun/caml/s.h; \
- then echo " ... testing => skipped (using the system-provided execvpe())"; \
- else $(MAKE) compile && $(SET_LD_PATH) $(MAKE) myrun; \
- fi
-
-myrun:
- @printf " ... testing with"
- @if $(NATIVECODE_ONLY); then : ; else \
- printf " ocamlc"; \
- ./exec.run "$(MYRUNTIME) ./program.byte$(EXE)" $(EXEC_ARGS) \
- >$(MAIN_MODULE).result \
- && $(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result \
- >/dev/null; \
- fi \
- && if $(BYTECODE_ONLY); then : ; else \
- printf " ocamlopt"; \
- ./exec.run ./program.native$(EXE) $(EXEC_ARGS) \
- > $(MAIN_MODULE).result \
- && $(DIFF) $(MAIN_MODULE).reference $(MAIN_MODULE).result \
- >/dev/null; \
- fi \
- && echo " => passed" || echo " => failed"
-
-include $(BASEDIR)/makefiles/Makefile.one
-include $(BASEDIR)/makefiles/Makefile.common
diff --git a/testsuite/tests/lib-unix/unix-execvpe/exec.ml b/testsuite/tests/lib-unix/unix-execvpe/exec.ml
index 8eb623201a..a374f9fcec 100644
--- a/testsuite/tests/lib-unix/unix-execvpe/exec.ml
+++ b/testsuite/tests/lib-unix/unix-execvpe/exec.ml
@@ -1,3 +1,11 @@
+(* TEST
+ include unix
+ script = "sh ${test_source_directory}/has-execvpe"
+ * script
+ ** bytecode
+ ** native
+*)
+
open Printf
let _ =
diff --git a/testsuite/tests/lib-unix/unix-execvpe/exec.run b/testsuite/tests/lib-unix/unix-execvpe/exec.run
index 86f8eb8608..d5408a0954 100755
--- a/testsuite/tests/lib-unix/unix-execvpe/exec.run
+++ b/testsuite/tests/lib-unix/unix-execvpe/exec.run
@@ -1,11 +1,16 @@
#!/bin/sh
-program=$1
-if test -z "$program"; then echo "Usage: exec.run <program>" 1&>2; exit 2; fi
+if test -z "$program"; then echo "Define the program env var" 1&>2; exit 2; fi
-exec 2>&1
+output=$program.output
+exec > ${output} 2>&1
-export PATH="/bin:/usr/bin:./subdir:"
+subdir=${test_source_directory}/subdir
+
+# Let ocamltest know where we write our output
+echo output=\"${output}\" > ${ocamltest_env}
+
+export PATH="/bin:/usr/bin:${subdir}:"
export BAR=bar
echo "## Test 1: a binary program in the path"
@@ -15,13 +20,14 @@ $program script1 2 3 4 || echo "script1 failed"
echo "## Test 3: a script without #! in the path"
$program script2 5 6 7 || echo "script2 failed"
echo "## Test 4: a script in the current directory"
+cd ${test_source_directory}
$program script3 8 9 || echo "script3 failed"
echo "## Test 5: a non-existent program"
$program nosuchprogram
echo "## Test 6: a non-executable program"
$program nonexec
-export PATH="/bin:/usr/bin:./subdir"
+export PATH="/bin:/usr/bin:${subdir}"
echo "## Test 7: a script in the current directory"
$program script3 9 && echo "script3 should have failed"
exit 0
diff --git a/testsuite/tests/lib-unix/unix-execvpe/has-execvpe b/testsuite/tests/lib-unix/unix-execvpe/has-execvpe
new file mode 100755
index 0000000000..18f3311f2a
--- /dev/null
+++ b/testsuite/tests/lib-unix/unix-execvpe/has-execvpe
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# This script is related to the 'exec.ml' test.
+# It tests whether the OS implements execvpe or not.
+# It makes sense to run the tests only if execvpe is nt implemented.
+# If it is implemented, the test is skipped.
+
+if grep -q HAS_EXECVPE ${ocamlsrcdir}/byterun/caml/s.h; then
+ exit ${TEST_SKIP};
+fi
+exit ${TEST_PASS}
diff --git a/testsuite/tests/lib-unix/unix-execvpe/ocamltests b/testsuite/tests/lib-unix/unix-execvpe/ocamltests
new file mode 100644
index 0000000000..5280ba4985
--- /dev/null
+++ b/testsuite/tests/lib-unix/unix-execvpe/ocamltests
@@ -0,0 +1 @@
+exec.ml