Skip to content

Commit

Permalink
Update cross build system for tests to work
Browse files Browse the repository at this point in the history
ts has been fixed to again work in a cross build environment.
See ts:help() and xcomp/README.md for details about how it works.
  • Loading branch information
garazdawi committed May 2, 2012
1 parent 5573888 commit b834e18
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 150 deletions.
20 changes: 18 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,14 @@ BOOTSTRAP_ONLY = @BOOTSTRAP_ONLY@
CROSS_COMPILING = @CROSS_COMPILING@
ifeq ($(CROSS_COMPILING),yes)
INSTALL_CROSS = -cross
TARGET_HOST=$(shell $(ERL_TOP)/erts/autoconf/config.guess)
else
ifneq ($(DESTDIR),)
INSTALL_CROSS = -cross
else
INSTALL_CROSS =
endif
TARGET_HOST=
endif

# A BSD compatible install program
Expand Down Expand Up @@ -228,10 +230,10 @@ BOOTSTRAP_ROOT = $(ERL_TOP)
LOCAL_PATH = $(ERL_TOP)/erts/bin/$(TARGET):$(ERL_TOP)/erts/bin
ifeq ($(TARGET),win32)
BOOT_PREFIX=$(WIN32_WRAPPER_PATH):$(BOOTSTRAP_ROOT)/bootstrap/bin:
TEST_PATH_PREFIX=$(WIN32_WRAPPER_PATH):$(ERL_TOP)/bin:
TEST_PATH_PREFIX=$(WIN32_WRAPPER_PATH):$(ERL_TOP)/bin/win32:
else
BOOT_PREFIX=$(BOOTSTRAP_ROOT)/bootstrap/bin:
TEST_PATH_PREFIX=$(ERL_TOP)/bin:
TEST_PATH_PREFIX=$(ERL_TOP)/bin/$(TARGET_HOST):
endif

# ----------------------------------------------------------------------
Expand Down Expand Up @@ -651,6 +653,8 @@ tertiary_bootstrap_copy:
if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/wx/include ; fi
if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server ; fi
if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include ; fi
if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/common_test ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/common_test ; fi
if test ! -d $(BOOTSTRAP_ROOT)/bootstrap/lib/common_test/include ; then mkdir $(BOOTSTRAP_ROOT)/bootstrap/lib/common_test/include ; fi
for x in lib/ic/ebin/*.beam; do \
BN=`basename $$x`; \
TF=$(BOOTSTRAP_ROOT)/bootstrap/lib/ic/ebin/$$BN; \
Expand Down Expand Up @@ -728,6 +732,7 @@ tertiary_bootstrap_copy:
true; \
done

# copy test includes to be able to compile tests with bootstrap compiler
for x in lib/test_server/include/*.hrl; do \
BN=`basename $$x`; \
TF=$(BOOTSTRAP_ROOT)/bootstrap/lib/test_server/include/$$BN; \
Expand All @@ -738,6 +743,17 @@ tertiary_bootstrap_copy:
cp $$x $$TF; \
true; \
done

for x in lib/common_test/include/*.hrl; do \
BN=`basename $$x`; \
TF=$(BOOTSTRAP_ROOT)/bootstrap/lib/common_test/include/$$BN; \
test -f $$TF && \
test '!' -z "`find $$x -newer $$TF -print`" && \
cp $$x $$TF; \
test '!' -f $$TF && \
cp $$x $$TF; \
true; \
done
# cp lib/syntax_tools/ebin/*.beam $(BOOTSTRAP_ROOT)/bootstrap/lib/syntax_tools/ebin

.PHONY: check_recreate_primary_bootstrap recreate_primary_bootstrap
Expand Down
34 changes: 13 additions & 21 deletions lib/test_server/src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ AC_CHECK_HEADER(poll.h, AC_DEFINE(HAVE_POLL_H))
# for the system.

AC_MSG_CHECKING([system version (for dynamic loading)])
system=`uname -s`-`uname -r`
system=`./config.sub $host`
AC_MSG_RESULT($system)

# Step 2: check for existence of -ldl library. This is needed because
Expand All @@ -119,10 +119,9 @@ AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
# Step 3: set configuration options based on system name and version.

SHLIB_LDLIBS=

fullSrcDir=`cd $srcdir; pwd`
case $system in
Linux*)
*-linux-*)
SHLIB_CFLAGS="-fPIC"
SHLIB_SUFFIX=".so"
if test "$have_dl" = yes; then
Expand All @@ -136,7 +135,7 @@ case $system in
fi
SHLIB_EXTRACT_ALL=""
;;
NetBSD-*|FreeBSD-*|OpenBSD-*|DragonFly*)
*-netbsd*|*-freebsd*|*-openbsd*|*-dragonfly*)
# Not available on all versions: check for include file.
AC_CHECK_HEADER(dlfcn.h, [
SHLIB_CFLAGS="-fpic"
Expand All @@ -153,28 +152,21 @@ case $system in
])
SHLIB_EXTRACT_ALL=""
;;
SunOS-4*)
SHLIB_CFLAGS="-PIC"
SHLIB_LD="ld"
SHLIB_LDFLAGS="$LDFLAGS"
SHLIB_SUFFIX=".so"
SHLIB_EXTRACT_ALL=""
;;
SunOS-5*|UNIX_SV-4.2*)
*-solaris2*|*-sysv4*)
SHLIB_CFLAGS="-KPIC"
SHLIB_LD="/usr/ccs/bin/ld"
SHLIB_LDFLAGS="$LDFLAGS -G -z text"
SHLIB_SUFFIX=".so"
SHLIB_EXTRACT_ALL="-z allextract"
;;
Darwin*)
*darwin*)
SHLIB_CFLAGS="-fno-common"
SHLIB_LD="cc"
SHLIB_LDFLAGS="$LDFLAGS -bundle -flat_namespace -undefined suppress"
SHLIB_SUFFIX=".so"
SHLIB_EXTRACT_ALL=""
;;
OSF1*)
*osf1*)
SHLIB_CFLAGS="-fPIC"
SHLIB_LD="ld"
SHLIB_LDFLAGS="$LDFLAGS -shared"
Expand Down Expand Up @@ -206,19 +198,19 @@ esac

if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
case $system in
AIX-*)
*-aix)
;;
BSD/OS*)
*-bsd*)
;;
IRIX*)
*-irix)
;;
NetBSD-*|FreeBSD-*|OpenBSD-*)
*-netbsd|*-freebsd|*-openbsd)
;;
RISCos-*)
*-riscos)
;;
ULTRIX-4.*)
*ultrix4.*)
;;
Darwin*)
*darwin*)
;;
*)
SHLIB_CFLAGS="-fPIC"
Expand Down
73 changes: 41 additions & 32 deletions lib/test_server/src/ts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
-export([run/0, run/1, run/2, run/3, run/4,
clean/0, clean/1,
tests/0, tests/1,
install/0, install/1, install/2, index/0,
install/0, install/1, index/0,
estone/0, estone/1,
cross_cover_analyse/1,
compile_testcases/0, compile_testcases/1,
help/0]).
-export([i/0, l/1, r/0, r/1, r/2, r/3]).

Expand Down Expand Up @@ -88,35 +89,25 @@
-define(
install_help,
[
" ts:install() - Install TS for local target with no Options.\n"
" ts:install([Options])\n",
" - Install TS for local target with Options\n"
" ts:install({Architecture, Target_name})\n",
" - Install TS for a remote target architecture.\n",
" and target network name (e.g. {vxworks_cpu32, sauron}).\n",
" ts:install({Architecture, Target_name}, [Options])\n",
" - Install TS as above, and with Options.\n",
" ts:install() - Install TS with no Options.\n"
" ts:install([Options]) - Install TS with Options\n"
"\n",
"Installation options supported:\n",
" {longnames, true} - Use fully qualified hostnames\n",
" {hosts, [HostList]}\n"
" - Use theese hosts for distributed testing.\n"
" {verbose, Level} - Sets verbosity level for TS output (0,1,2), 0 is\n"
" quiet(default).\n"
" {slavetargets, SlaveTarges}\n"
" - Available hosts for starting slave nodes for\n"
" platforms which cannot have more than one erlang\n"
" node per host.\n"
" {crossroot, TargetErlRoot}\n"
" - Erlang root directory on target host\n"
" Mandatory for remote targets\n"
" {master, {MasterHost, MasterCookie}}\n"
" - Master host and cookie for targets which are\n"
" started as slave nodes.\n"
" erl_boot_server must be started on master before\n"
" test is run.\n"
" Optional, default is controller host and then\n"
" erl_boot_server is started autmatically\n"
" {crossroot, ErlTop}\n"
" - Erlang root directory on build host, ~n"
" normally same value as $ERL_TOP\n"
" {crossenv, [{Key,Val}]}\n"
" - Environmentals used by test configure on build host\n"
" {crossflags, FlagsString}\n"
" - Flags used by test configure on build host\n"
" {xcomp, XCompFile}\n"
" - The xcomp file to use for cross compiling the~n"
" testcases. Using this option will override any~n"
" cross* configurations given to ts. Note that you~n"
" have to have a correct ERL_TOP as well.~n"
]).

help() ->
Expand Down Expand Up @@ -183,26 +174,24 @@ help(installed) ->
" cover_details. Analyses modules specified in\n"
" cross.cover.\n"
" Level can be 'overview' or 'details'.\n",
" ts:compile_testcases()~n"
" ts:compile_testcases(Apps)~n"
" - Compile all testcases for usage in a cross ~n"
" compile environment."
" \n"
"Installation (already done):\n"
],
show_help([H,?install_help]).

show_help(H) ->
io:put_chars(lists:flatten(H)).
io:format(lists:flatten(H)).


%% Installs tests.
install() ->
ts_install:install(install_local,[]).
install({Architecture, Target_name}) ->
ts_install:install({ts_lib:maybe_atom_to_list(Architecture),
ts_lib:maybe_atom_to_list(Target_name)}, []);
install(Options) when is_list(Options) ->
ts_install:install(install_local,Options).
install({Architecture, Target_name}, Options) when is_list(Options)->
ts_install:install({ts_lib:maybe_atom_to_list(Architecture),
ts_lib:maybe_atom_to_list(Target_name)}, Options).

%% Updates the local index page.

Expand Down Expand Up @@ -728,3 +717,23 @@ cover_type(cover_details) -> details.
do_load(Mod) ->
code:purge(Mod),
code:load_file(Mod).


compile_testcases() ->
compile_datadirs("../*/*_data").

compile_testcases(App) when is_atom(App) ->
compile_testcases([App]);
compile_testcases([App | T]) ->
compile_datadirs(io_lib:format("../~s_test/*_data", [App])),
compile_testcases(T);
compile_testcases([]) ->
ok.

compile_datadirs(DataDirs) ->
{ok,Variables} = file:consult("variables"),

lists:foreach(fun(Dir) ->
ts_lib:make_non_erlang(Dir, Variables)
end,
filelib:wildcard(DataDirs)).
1 change: 1 addition & 0 deletions lib/test_server/src/ts.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
-define(run_summary, "suite.summary").
-define(cover_total,"total_cover.log").
-define(variables, "variables").
-define(cross_variables, "variables-cross").
-define(LF, [10]). % Newline in VxWorks script
-define(CHAR_PER_LINE, 60). % Characters per VxWorks script building line
-define(CROSS_COOKIE, "cross"). % cookie used when cross platform testing
Expand Down
24 changes: 8 additions & 16 deletions lib/test_server/src/ts_erl_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ erl_interface(Vars,OsType) ->
_ ->
"" % VxWorks
end,
CrossCompile = case OsType of
vxworks -> "true";
_ -> "false"
end,
[{erl_interface_libpath, filename:nativename(LibPath)},
{erl_interface_sock_libs, sock_libraries(OsType)},
{erl_interface_lib, Lib},
Expand All @@ -232,8 +228,8 @@ erl_interface(Vars,OsType) ->
{erl_interface_eilib_drv, Lib1Drv},
{erl_interface_threadlib, ThreadLib},
{erl_interface_include, filename:nativename(Incl)},
{erl_interface_mk_include, filename:nativename(MkIncl)},
{erl_interface_cross_compile, CrossCompile} | Vars].
{erl_interface_mk_include, filename:nativename(MkIncl)}
| Vars].

ic(Vars, OsType) ->
{ClassPath, LibPath, Incl} =
Expand Down Expand Up @@ -276,8 +272,6 @@ lib_dir(Vars, Lib) ->
case {get_var(crossroot, Vars), LibLibDir} of
{{error, _}, _} -> %no crossroot
LibLibDir;
{_, {error, _}} -> %no lib
LibLibDir;
{CrossRoot, _} ->
%% XXX: Ugly. So ugly I won't comment it
%% /Patrik
Expand All @@ -299,18 +293,16 @@ lib_dir(Vars, Lib) ->
end.

erl_root(Vars) ->
Root = code:root_dir(),
case ts_lib:erlang_type() of
Root = case get_var(crossroot,Vars) of
{error, notfound} -> code:root_dir();
CrossRoot -> CrossRoot
end,
case ts_lib:erlang_type(Root) of
{srctree, _Version} ->
Target = get_var(target, Vars),
{srctree, Root, Target};
{_, _Version} ->
case get_var(crossroot,Vars) of
{error, notfound} ->
{installed, Root};
CrossRoot ->
{installed, CrossRoot}
end
{installed, Root}
end.


Expand Down
Loading

0 comments on commit b834e18

Please sign in to comment.