aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/test
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/syntax_tools/test
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/syntax_tools/test')
-rw-r--r--lib/syntax_tools/test/Makefile65
-rw-r--r--lib/syntax_tools/test/syntax_tools.dynspec5
-rw-r--r--lib/syntax_tools/test/syntax_tools_SUITE.erl82
3 files changed, 152 insertions, 0 deletions
diff --git a/lib/syntax_tools/test/Makefile b/lib/syntax_tools/test/Makefile
new file mode 100644
index 0000000000..621c76f5a5
--- /dev/null
+++ b/lib/syntax_tools/test/Makefile
@@ -0,0 +1,65 @@
+include $(ERL_TOP)/make/target.mk
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+
+MODULES= \
+ syntax_tools_SUITE
+
+ERL_FILES= $(MODULES:%=%.erl)
+
+TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+INSTALL_PROGS= $(TARGET_FILES)
+
+EMAKEFILE=Emakefile
+
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)/syntax_tools_test
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+
+ERL_MAKE_FLAGS +=
+ERL_COMPILE_FLAGS += -I$(ERL_TOP)/lib/test_server/include
+
+EBIN = .
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+make_emakefile:
+ $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) \
+ > $(EMAKEFILE)
+ $(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' \
+ >> $(EMAKEFILE)
+
+tests debug opt: make_emakefile
+ erl $(ERL_MAKE_FLAGS) -make
+
+clean:
+ rm -f $(EMAKEFILE)
+ rm -f $(TARGET_FILES) $(GEN_FILES)
+ rm -f core
+
+docs:
+
+# ----------------------------------------------------
+# Release Target
+# ----------------------------------------------------
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+release_spec: opt
+
+release_tests_spec: make_emakefile
+ $(INSTALL_DIR) $(RELSYSDIR)
+ $(INSTALL_DATA) $(EMAKEFILE) $(ERL_FILES) $(RELSYSDIR)
+ $(INSTALL_DATA) syntax_tools.dynspec $(RELSYSDIR)
+ chmod -f -R u+w $(RELSYSDIR)
+
+release_docs_spec:
diff --git a/lib/syntax_tools/test/syntax_tools.dynspec b/lib/syntax_tools/test/syntax_tools.dynspec
new file mode 100644
index 0000000000..981cb8175e
--- /dev/null
+++ b/lib/syntax_tools/test/syntax_tools.dynspec
@@ -0,0 +1,5 @@
+%% -*- erlang -*-
+%% You can test this file using this command.
+%% file:script("syntax_tools.dynspec", [{'Os',"Unix"}]).
+
+[].
diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl
new file mode 100644
index 0000000000..16f794683b
--- /dev/null
+++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl
@@ -0,0 +1,82 @@
+%% ``The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved via the world wide web at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
+%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
+%% AB. All Rights Reserved.''
+%%
+%% $Id$
+%%
+-module(syntax_tools_SUITE).
+
+-include("test_server.hrl").
+
+%% Test server specific exports
+-export([all/1]).
+
+%% Test cases
+-export([smoke_test/1]).
+
+all(suite) ->
+ [smoke_test].
+
+%% Read and parse all source in the OTP release.
+smoke_test(Config) when is_list(Config) ->
+ ?line Dog = ?t:timetrap(?t:minutes(12)),
+ ?line Wc = filename:join([code:lib_dir(),"*","src","*.erl"]),
+ ?line Fs = filelib:wildcard(Wc),
+ ?line io:format("~p files\n", [length(Fs)]),
+ ?line case p_run(fun smoke_test_file/1, Fs) of
+ 0 -> ok;
+ N -> ?line ?t:fail({N,errors})
+ end,
+ ?line ?t:timetrap_cancel(Dog).
+
+smoke_test_file(File) ->
+ case epp_dodger:parse_file(File) of
+ {ok,Forms} ->
+ [print_error_markers(F, File) || F <- Forms],
+ ok;
+ {error,Reason} ->
+ io:format("~s: ~p\n", [File,Reason]),
+ error
+ end.
+
+print_error_markers(F, File) ->
+ case erl_syntax:type(F) of
+ error_marker ->
+ {L,M,Info} = erl_syntax:error_marker_info(F),
+ io:format("~s:~p: ~s", [File,L,M:format_error(Info)]);
+ _ ->
+ ok
+ end.
+
+
+p_run(Test, List) ->
+ N = erlang:system_info(schedulers),
+ p_run_loop(Test, List, N, [], 0).
+
+p_run_loop(_, [], _, [], Errors) ->
+ Errors;
+p_run_loop(Test, [H|T], N, Refs, Errors) when length(Refs) < N ->
+ {_,Ref} = erlang:spawn_monitor(fun() -> exit(Test(H)) end),
+ p_run_loop(Test, T, N, [Ref|Refs], Errors);
+p_run_loop(Test, List, N, Refs0, Errors0) ->
+ receive
+ {'DOWN',Ref,process,_,Res} ->
+ Errors = case Res of
+ ok -> Errors0;
+ error -> Errors0+1
+ end,
+ Refs = Refs0 -- [Ref],
+ p_run_loop(Test, List, N, Refs, Errors)
+ end.
+