From 86f970056b55ab8c33ecb6d0ce13924e3331b79a Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 30 Jul 2013 14:53:00 +0200 Subject: Add smoke tests Smoke tests are meant to verify that a build of erlang has been successfull. --- lib/test_server/src/ts.erl | 26 ++++++++++++++++++++++++++ lib/test_server/src/ts_benchmark.erl | 7 +------ lib/test_server/src/ts_lib.erl | 12 +++++++++++- 3 files changed, 38 insertions(+), 7 deletions(-) (limited to 'lib/test_server/src') diff --git a/lib/test_server/src/ts.erl b/lib/test_server/src/ts.erl index 4e5dc1b759..8e71c69d35 100644 --- a/lib/test_server/src/ts.erl +++ b/lib/test_server/src/ts.erl @@ -28,6 +28,7 @@ tests/0, tests/1, install/0, install/1, bench/0, bench/1, bench/2, benchmarks/0, + smoke_test/0, smoke_test/1,smoke_test/2, smoke_tests/0, estone/0, estone/1, cross_cover_analyse/1, compile_testcases/0, compile_testcases/1, @@ -174,6 +175,13 @@ help(installed) -> " ts:bench(Spec) - Runs all benchmarks in the given spec file.\n" " The spec file is actually ../*_test/Spec_bench.spec\n\n" " ts:bench can take the same Options argument as ts:run.\n" + "Smoke test functions:\n" + " ts:smoke_tests() - Get all available families of smoke tests\n" + " ts:smoke_test() - Runs all smoke tests\n" + " ts:smoke_test(Spec)\n" + " - Runs all smoke tests in the given spec file.\n" + " The spec file is actually ../*_test/Spec_smoke.spec\n\n" + " ts:smoke_test can take the same Options argument as ts:run.\n" "\n" "Installation (already done):\n" ], @@ -258,6 +266,7 @@ run(List, Opts) when is_list(List), is_list(Opts) -> %% Runs one test spec with Options run(Testspec, Config) when is_atom(Testspec), is_list(Config) -> Options=check_test_get_opts(Testspec, Config), + IsSmoke=proplists:get_value(smoke,Config), File=atom_to_list(Testspec), WhatToDo = case Testspec of @@ -293,6 +302,8 @@ run(Testspec, Config) when is_atom(Testspec), is_list(Config) -> case WhatToDo of skip -> create_skip_spec(Testspec, tests(Testspec)); + test when IsSmoke -> + File++"_smoke.spec"; test -> File++".spec" end, @@ -507,7 +518,22 @@ bench(Specs, Opts) -> benchmarks() -> ts_benchmark:benchmarks(). +smoke_test() -> + smoke_test([]). +smoke_test(Opts) when is_list(Opts) -> + smoke_test(smoke_tests(),Opts); +smoke_test(Spec) -> + smoke_test([Spec],[]). + +smoke_test(Spec, Opts) when is_atom(Spec) -> + smoke_test([Spec],Opts); +smoke_test(Specs, Opts) -> + run(Specs, [{smoke,true}|Opts]). + +smoke_tests() -> + {ok, Cwd} = file:get_cwd(), + ts_lib:specialized_specs(Cwd,"smoke"). %% %% estone/0, estone/1 diff --git a/lib/test_server/src/ts_benchmark.erl b/lib/test_server/src/ts_benchmark.erl index 516d22fd2d..bd6abc3372 100644 --- a/lib/test_server/src/ts_benchmark.erl +++ b/lib/test_server/src/ts_benchmark.erl @@ -30,12 +30,7 @@ benchmarks() -> {ok, Cwd} = file:get_cwd(), - Benches = filelib:wildcard( - filename:join([Cwd,"..","*_test","*_bench.spec"])), - [begin - Base = filename:basename(N), - list_to_atom(string:substr(Base,1,string:rstr(Base,"_")-1)) - end || N <- Benches]. + ts_lib:specialized_specs(Cwd,"bench"). run(Specs, Opts, Vars) -> {ok, Cwd} = file:get_cwd(), diff --git a/lib/test_server/src/ts_lib.erl b/lib/test_server/src/ts_lib.erl index a00f607fc1..52bb346043 100644 --- a/lib/test_server/src/ts_lib.erl +++ b/lib/test_server/src/ts_lib.erl @@ -27,6 +27,7 @@ erlang_type/1, initial_capital/1, specs/1, suites/2, + specialized_specs/2, subst_file/3, subst/2, print_data/1, make_non_erlang/2, maybe_atom_to_list/1, progress/4, @@ -91,13 +92,22 @@ initial_capital([C|Rest]) when $a =< C, C =< $z -> initial_capital(String) -> String. +specialized_specs(Dir,PostFix) -> + Specs = filelib:wildcard(filename:join([filename:dirname(Dir), + "*_test", "*_"++PostFix++".spec"])), + sort_tests([begin + Base = filename:basename(Name), + list_to_atom(string:substr(Base,1,string:rstr(Base,"_")-1)) + end || Name <- Specs]). + specs(Dir) -> Specs = filelib:wildcard(filename:join([filename:dirname(Dir), "*_test", "*.{dyn,}spec"])), - % Filter away all spec which end with _bench.spec + % Filter away all spec which end with {_bench,_smoke}.spec NoBench = fun(SpecName) -> case lists:reverse(SpecName) of "ceps.hcneb_"++_ -> false; + "ceps.ekoms_"++_ -> false; _ -> true end end, -- cgit v1.2.3