Improve threading tests on Windows

The `CANKILL` testsuite variable is eliminated in favour of testing for
`TOOLCHAIN`.

tests/lib-threads/signal.ml can be executed under native Windows by
means of a wrapper program to send CTRL+C.

tests/lib-threads/signal2.ml is not possible under native Windows
because Thread.sigmask is not implemented, so the precheck is updated to
reflect this, rather than the lack of kill -INT.

tests/lib-threads/sockets.ml is re-enabled, since the two MPRs affecting
it have been fixed.
master
David Allsopp 2016-01-16 16:03:23 +00:00
parent e66d98e23e
commit b505fc699c
12 changed files with 51 additions and 47 deletions

View File

@ -189,5 +189,4 @@ OTOPDIR=$(WINTOPDIR)
CTOPDIR=$(TOPDIR)
CYGPATH=cygpath -m
DIFF=diff -q --strip-trailing-cr
CANKILL=false
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"

View File

@ -189,5 +189,4 @@ OTOPDIR=$(WINTOPDIR)
CTOPDIR=$(TOPDIR)
CYGPATH=cygpath -m
DIFF=diff -q --strip-trailing-cr
CANKILL=false
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"

View File

@ -191,7 +191,6 @@ OTOPDIR=$(WINTOPDIR)
CTOPDIR=$(WINTOPDIR)
CYGPATH=cygpath -m
DIFF=diff -q --strip-trailing-cr
CANKILL=false
FIND=/usr/bin/find
SORT=/usr/bin/sort
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"

View File

@ -195,7 +195,6 @@ OTOPDIR=$(WINTOPDIR)
CTOPDIR=$(WINTOPDIR)
CYGPATH=cygpath -m
DIFF=diff -q --strip-trailing-cr
CANKILL=false
FIND=/usr/bin/find
SORT=/usr/bin/sort
SET_LD_PATH=PATH="$(PATH):$(LD_PATH)"

View File

@ -20,7 +20,6 @@ OTOPDIR=$(TOPDIR)
CTOPDIR=$(TOPDIR)
CYGPATH=echo
DIFF=diff -q
CANKILL=true
SORT=sort
SET_LD_PATH=CAML_LD_LIBRARY_PATH="$(LD_PATH)"
@ -32,8 +31,6 @@ SET_LD_PATH=CAML_LD_LIBRARY_PATH="$(LD_PATH)"
# CYGPATH is the command that translates unix-style file names into
# whichever syntax is appropriate for arguments of OCaml programs.
# DIFF is a "diff -q" command that ignores trailing CRs under Windows.
# CANKILL is true if a script launched by Make can kill an OCaml process,
# and false for the mingw and MSVC ports.
# SORT is the Unix "sort" command. Usually a simple command, but may be an
# absolute name if the Windows "sort" command is in the PATH.
# SET_LD_PATH is a command prefix that sets the path for dynamic libraries
@ -84,7 +81,7 @@ defaultpromote:
done
defaultclean:
@rm -f *.cmo *.cmi *.cmx *.cma *.cmxa *.cmxs *.$(O) *.$(SO) *.$(A)
@rm -f *.cmo *.cmi *.cmx *.cma *.cmxa *.cmxs *.$(O) *.$(SO) *.$(A) *.exe
@for dsym in *.dSYM; do \
if [ -d $$dsym ]; then \
rm -fr $$dsym; \

View File

@ -43,7 +43,7 @@ run-all:
done;
@for file in *.ml; do \
if [ -f `basename $$file ml`precheck ]; then \
CANKILL=$(CANKILL) sh `basename $$file ml`precheck || continue; \
TOOLCHAIN=$(TOOLCHAIN) sh `basename $$file ml`precheck || continue; \
fi; \
printf " ... testing '$$file':"; \
$(MAKE) run-file DESC=ocamlc COMP='$(OCAMLC)' \

View File

@ -16,5 +16,15 @@ ADD_COMPFLAGS=-thread -I $(OTOPDIR)/otherlibs/systhreads \
-I $(OTOPDIR)/otherlibs/$(UNIXLIBVAR)unix
LD_PATH=$(TOPDIR)/otherlibs/systhreads:$(TOPDIR)/otherlibs/$(UNIXLIBVAR)unix
default:
@$(if $(filter msvc mingw,$(TOOLCHAIN)),$(MAKE) sigint.exe,true)
@$(SET_LD_PATH) $(MAKE) run-all
include $(BASEDIR)/makefiles/Makefile.several
include $(BASEDIR)/makefiles/Makefile.common
sigint.exe: sigint.$(O)
@$(CC) $(if $(filter msvc,$(CCOMPTYPE)),/Fe$@,-o $@) $^
%.obj: %.c
@$(CC) -c $*.c > /dev/null

View File

@ -0,0 +1,37 @@
#include <stdio.h>
#include <windows.h>
int main(int argc, char** argv)
{
DWORD pid;
HANDLE hProcess;
if (argc != 2) {
printf("Usage: %s pid\n", argv[0]);
return 1;
}
pid = atoi(argv[1]);
hProcess = OpenProcess(SYNCHRONIZE, FALSE, pid);
if (!hProcess) {
printf("Process %d not found!\n", pid);
return 1;
}
FreeConsole();
if (!AttachConsole(pid)) {
printf("Failed to attach to console of Process %d\n", pid);
CloseHandle(hProcess);
return 1;
}
SetConsoleCtrlHandler(NULL, TRUE);
GenerateConsoleCtrlEvent(0, 0);
WaitForSingleObject(hProcess, INFINITE);
CloseHandle(hProcess);
FreeConsole();
return 0;
}

View File

@ -1,13 +0,0 @@
#########################################################################
# #
# OCaml #
# #
# Damien Doligez, projet Gallium, INRIA Rocquencourt #
# #
# Copyright 2013 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. This file is distributed #
# under the terms of the Q Public License version 1.0. #
# #
#########################################################################
$CANKILL

View File

@ -13,4 +13,4 @@
$RUNTIME ./program >signal.result &
pid=$!
sleep 2
kill -INT $pid
test -e ./sigint.exe && ./sigint $pid || kill -INT $pid

View File

@ -10,4 +10,4 @@
# #
#########################################################################
$CANKILL
test "$TOOLCHAIN" != "msvc" -a "$TOOLCHAIN" != "mingw"

View File

@ -1,23 +0,0 @@
#########################################################################
# #
# OCaml #
# #
# Damien Doligez, projet Gallium, INRIA Rocquencourt #
# #
# Copyright 2013 Institut National de Recherche en Informatique et #
# en Automatique. All rights reserved. This file is distributed #
# under the terms of the Q Public License version 1.0. #
# #
#########################################################################
##########################################
##########################################
#### TEMPORARY ####
##########################################
##########################################
# disable this test on Windows non-cygwin ports until we decide
# how to fix PR#5325 and PR#5578
$CANKILL