diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-03-16 19:02:13 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-03-16 19:44:58 +0100 |
commit | 86743354292ef497401303b6e8566b6f3f738b96 (patch) | |
tree | b2d7afd395447ce8568b6ba991b53fa8d626328c /lib | |
parent | e7473f6810b249d1115361f005fb8b44fe59f474 (diff) | |
download | otp-86743354292ef497401303b6e8566b6f3f738b96.tar.gz otp-86743354292ef497401303b6e8566b6f3f738b96.tar.bz2 otp-86743354292ef497401303b6e8566b6f3f738b96.zip |
Modernize test suites
Diffstat (limited to 'lib')
-rw-r--r-- | lib/percept/test/egd_SUITE.erl | 336 | ||||
-rw-r--r-- | lib/percept/test/ipc_tree.erl | 2 | ||||
-rw-r--r-- | lib/percept/test/percept_SUITE.erl | 114 | ||||
-rw-r--r-- | lib/percept/test/percept_db_SUITE.erl | 36 |
4 files changed, 191 insertions, 297 deletions
diff --git a/lib/percept/test/egd_SUITE.erl b/lib/percept/test/egd_SUITE.erl index 0b1149e1f1..6df7ed74c0 100644 --- a/lib/percept/test/egd_SUITE.erl +++ b/lib/percept/test/egd_SUITE.erl @@ -22,195 +22,160 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). +-export([all/0, suite/0]). -export([init_per_suite/1, end_per_suite/1]). -export([init_per_testcase/2, end_per_testcase/2]). %% Test cases --export([ - image_create_and_destroy/1, - image_shape/1, - image_primitives/1, - image_colors/1, - image_font/1, - image_png_compliant/1 - ]). - -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(1)). +-export([image_create_and_destroy/1, + image_shape/1, + image_primitives/1, + image_colors/1, + image_font/1, + image_png_compliant/1]). -init_per_suite(Config) when is_list(Config) -> - rand:seed(exsplus), - Config. - -end_per_suite(Config) when is_list(Config) -> - Config. - -init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{max_size, 800}, {watchdog,Dog} | Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), - ok. - -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap, {minutes, 1}}]. all() -> [image_create_and_destroy, image_shape, image_primitives, image_colors, image_font, image_png_compliant]. -groups() -> - []. -init_per_group(_GroupName, Config) -> +init_per_suite(Config) when is_list(Config) -> + rand:seed(exsplus), Config. -end_per_group(_GroupName, Config) -> +end_per_suite(Config) when is_list(Config) -> Config. +init_per_testcase(_Case, Config) -> + [{max_size, 800}|Config]. + +end_per_testcase(_Case, _Config) -> + ok. %%---------------------------------------------------------------------- %% Tests %%---------------------------------------------------------------------- -image_create_and_destroy(suite) -> - []; -image_create_and_destroy(doc) -> - ["Image creation and destroy test."]; +%% Image creation and destroy test. image_create_and_destroy(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), - ?line Image = egd:create(W, H), - ?line ok = egd:destroy(Image), + {W,H} = get_size(proplists:get_value(max_size, Config)), + Image = egd:create(W, H), + ok = egd:destroy(Image), ok. -image_colors(suite) -> - []; -image_colors(doc) -> - ["Image color test."]; +%% Image color test. image_colors(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), - ?line Image = egd:create(W, H), + {W,H} = get_size(proplists:get_value(max_size, Config)), + Image = egd:create(W, H), put(image_size, {W,H}), RGB = get_rgb(), - ?line Black = egd:color({0,0,0}), - ?line Red = egd:color({255,0,0}), - ?line Green = egd:color({0,255,0}), - ?line Blue = egd:color({0,0,255}), - ?line Random = egd:color(Image, RGB), - - ?line ok = egd:line(Image, get_point(), get_point(), Random), - ?line ok = egd:line(Image, get_point(), get_point(), Red), - ?line ok = egd:line(Image, get_point(), get_point(), Green), - ?line ok = egd:line(Image, get_point(), get_point(), Black), - ?line ok = egd:line(Image, get_point(), get_point(), Blue), + Black = egd:color({0,0,0}), + Red = egd:color({255,0,0}), + Green = egd:color({0,255,0}), + Blue = egd:color({0,0,255}), + Random = egd:color(Image, RGB), + + ok = egd:line(Image, get_point(), get_point(), Random), + ok = egd:line(Image, get_point(), get_point(), Red), + ok = egd:line(Image, get_point(), get_point(), Green), + ok = egd:line(Image, get_point(), get_point(), Black), + ok = egd:line(Image, get_point(), get_point(), Blue), HtmlDefaultNames = [black,silver,gray,white,maroon,red, - purple,fuchia,green,lime,olive,yellow,navy,blue,teal, - aqua], - - lists:foreach(fun - (ColorName) -> - ?line Color = egd:color(ColorName), - ?line ok = egd:line(Image, get_point(), get_point(), Color) - end, HtmlDefaultNames), - - ?line <<_/binary>> = egd:render(Image), - ?line ok = egd:destroy(Image), + purple,fuchia,green,lime,olive,yellow,navy,blue,teal, + aqua], + + lists:foreach(fun (ColorName) -> + Color = egd:color(ColorName), + ok = egd:line(Image, get_point(), get_point(), Color) + end, HtmlDefaultNames), + + <<_/binary>> = egd:render(Image), + ok = egd:destroy(Image), erase(image_size), ok. -image_shape(suite) -> - []; -image_shape(doc) -> - ["Image shape api test."]; +%% Image shape API test. image_shape(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), + {W,H} = get_size(proplists:get_value(max_size, Config)), put(image_size, {W,H}), - ?line Im = egd:create(W, H), - - ?line Fgc = egd:color({255,0,0}), - - ?line ok = egd:line(Im, get_point(), get_point(), Fgc), - ?line ok = egd:rectangle(Im, get_point(), get_point(), Fgc), - ?line ok = egd:filledEllipse(Im, get_point(), get_point(), Fgc), - ?line ok = egd:arc(Im, get_point(), get_point(), Fgc), - ?line ok = egd:arc(Im, get_point(), get_point(), 100, Fgc), - + Im = egd:create(W, H), + + Fgc = egd:color({255,0,0}), + + ok = egd:line(Im, get_point(), get_point(), Fgc), + ok = egd:rectangle(Im, get_point(), get_point(), Fgc), + ok = egd:filledEllipse(Im, get_point(), get_point(), Fgc), + ok = egd:arc(Im, get_point(), get_point(), Fgc), + ok = egd:arc(Im, get_point(), get_point(), 100, Fgc), + Pt1 = get_point(), Pt2 = get_point(), - ?line ok = egd:filledRectangle(Im, Pt1, Pt2, Fgc), + ok = egd:filledRectangle(Im, Pt1, Pt2, Fgc), - ?line Bitmap = egd:render(Im, raw_bitmap), + Bitmap = egd:render(Im, raw_bitmap), - ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc), - ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc), + ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc), + ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc), - ?line <<_/binary>> = egd:render(Im, raw_bitmap, [{render_engine, alpha}]), + <<_/binary>> = egd:render(Im, raw_bitmap, [{render_engine, alpha}]), - ?line ok = egd:destroy(Im), + ok = egd:destroy(Im), erase(image_size), ok. -image_primitives(suite) -> - []; -image_primitives(doc) -> - ["Image shape api test."]; +%% Image shape API test. image_primitives(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), + {W,H} = get_size(proplists:get_value(max_size, Config)), put(image_size, {W,H}), - ?line Im0 = egd_primitives:create(W, H), - ?line Fgc = egd:color({25,25,255}), - ?line Bgc = egd:color({0,250,25}), + Im0 = egd_primitives:create(W, H), + Fgc = egd:color({25,25,255}), + Bgc = egd:color({0,250,25}), - ?line Im1 = lists:foldl(fun - ({Function, Arguments}, Im) -> - ?line erlang:apply(egd_primitives, Function, [Im|Arguments]) - end, Im0, - [{Fs, [get_point(), get_point(), Bgc]} || Fs <- [line, rectangle, filledEllipse, arc]] ++ - [{pixel, [get_point(), Bgc]}, - {filledTriangle, [get_point(), get_point(), get_point(), Bgc]}]), + Im1 = lists:foldl(fun ({Function, Arguments}, Im) -> + erlang:apply(egd_primitives, Function, [Im|Arguments]) + end, Im0, + [{Fs, [get_point(), get_point(), Bgc]} || Fs <- [line, rectangle, filledEllipse, arc]] ++ + [{pixel, [get_point(), Bgc]}, + {filledTriangle, [get_point(), get_point(), get_point(), Bgc]}]), Pt1 = get_point(), Pt2 = get_point(), - ?line Im2 = egd_primitives:filledRectangle(Im1, Pt1, Pt2, Fgc), + Im2 = egd_primitives:filledRectangle(Im1, Pt1, Pt2, Fgc), - ?line Bitmap = egd_render:binary(Im2, opaque), + Bitmap = egd_render:binary(Im2, opaque), - ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc), - ?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc), + ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc), + ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc), - ?line <<_/binary>> = egd_render:binary(Im2, alpha), + <<_/binary>> = egd_render:binary(Im2, alpha), erase(image_size), ok. - - - -image_font(suite) -> - []; -image_font(doc) -> - ["Image font test."]; +%% Image font test. image_font(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), + {W,H} = get_size(proplists:get_value(max_size, Config)), put(image_size, {W,H}), - ?line Im = egd:create(W, H), - ?line Fgc = egd:color({0,130,0}), - - ?line Filename = filename:join([code:priv_dir(percept),"fonts","6x11_latin1.wingsfont"]), - ?line Font = egd_font:load(Filename), - + Im = egd:create(W, H), + Fgc = egd:color({0,130,0}), + + Filename = filename:join([code:priv_dir(percept),"fonts","6x11_latin1.wingsfont"]), + Font = egd_font:load(Filename), + % simple text - ?line ok = egd:text(Im, get_point(), Font, "Hello World", Fgc), - ?line <<_/binary>> = egd:render(Im, png), - + ok = egd:text(Im, get_point(), Font, "Hello World", Fgc), + <<_/binary>> = egd:render(Im, png), + GlyphStr1 = " !\"#$%&'()*+,-./", % Codes 32 -> 47 NumericStr = "0123456789", % Codes 48 -> 57 GlyphStr2 = ":;<=>?@", % Codes 58 -> 64 @@ -219,62 +184,59 @@ image_font(Config) when is_list(Config) -> AlphaSmStr = "abcdefghijklmnopqrstuvwxyz", % Codes 97 -> 122 GlyphStr4 = "{|}~", % Codes 123 -> 126 - ?line ok = egd:text(Im, get_point(), Font, GlyphStr1, Fgc), - ?line <<_/binary>> = egd:render(Im, png), + ok = egd:text(Im, get_point(), Font, GlyphStr1, Fgc), + <<_/binary>> = egd:render(Im, png), + + ok = egd:text(Im, get_point(), Font, NumericStr, Fgc), + <<_/binary>> = egd:render(Im, png), + + ok = egd:text(Im, get_point(), Font, GlyphStr2, Fgc), + <<_/binary>> = egd:render(Im, png), + + ok = egd:text(Im, get_point(), Font, AlphaBigStr, Fgc), + <<_/binary>> = egd:render(Im, png), - ?line ok = egd:text(Im, get_point(), Font, NumericStr, Fgc), - ?line <<_/binary>> = egd:render(Im, png), - - ?line ok = egd:text(Im, get_point(), Font, GlyphStr2, Fgc), - ?line <<_/binary>> = egd:render(Im, png), + ok = egd:text(Im, get_point(), Font, GlyphStr3, Fgc), + <<_/binary>> = egd:render(Im, png), - ?line ok = egd:text(Im, get_point(), Font, AlphaBigStr, Fgc), - ?line <<_/binary>> = egd:render(Im, png), - - ?line ok = egd:text(Im, get_point(), Font, GlyphStr3, Fgc), - ?line <<_/binary>> = egd:render(Im, png), + ok = egd:text(Im, get_point(), Font, AlphaSmStr, Fgc), + <<_/binary>> = egd:render(Im, png), - ?line ok = egd:text(Im, get_point(), Font, AlphaSmStr, Fgc), - ?line <<_/binary>> = egd:render(Im, png), - - ?line ok = egd:text(Im, get_point(), Font, GlyphStr4, Fgc), - ?line <<_/binary>> = egd:render(Im, png), + ok = egd:text(Im, get_point(), Font, GlyphStr4, Fgc), + <<_/binary>> = egd:render(Im, png), - ?line ok = egd:destroy(Im), + ok = egd:destroy(Im), erase(image_size), ok. -image_png_compliant(suite) -> - []; -image_png_compliant(doc) -> - ["Image png compliant test."]; +%% Image png compliant test. image_png_compliant(Config) when is_list(Config) -> - {W,H} = get_size(?config(max_size, Config)), + {W,H} = get_size(proplists:get_value(max_size, Config)), put(image_size, {W,H}), - ?line Im = egd:create(W, H), - ?line Fgc = egd:color({0,0,0}), - ?line ok = egd:filledRectangle(Im, get_point(), get_point(), Fgc), - - ?line Bin = egd:render(Im, png), - ?line true = binary_is_png_compliant(Bin), - - ?line ok = egd:destroy(Im), + Im = egd:create(W, H), + Fgc = egd:color({0,0,0}), + ok = egd:filledRectangle(Im, get_point(), get_point(), Fgc), + + Bin = egd:render(Im, png), + true = binary_is_png_compliant(Bin), + + ok = egd:destroy(Im), erase(image_size), ok. %%---------------------------------------------------------------------- %% Auxiliary tests %%---------------------------------------------------------------------- - + bitmap_point_has_color(Bitmap, {W,_}, {X,Y}, C) -> {CR,CG,CB,_} = egd_primitives:rgb_float2byte(C), N = W*Y*3 + X*3, << _:N/binary, R,G,B, _/binary>> = Bitmap, case {R,G,B} of - {CR,CG,CB} -> ok; - Other -> - io:format("bitmap_point_has_color: error color was ~p, should be ~p~n", [Other, {CR,CG,CB}]), - {error, {Other,{CR,CG,CB}}} + {CR,CG,CB} -> ok; + Other -> + io:format("bitmap_point_has_color: error color was ~p, should be ~p~n", [Other, {CR,CG,CB}]), + {error, {Other,{CR,CG,CB}}} end. %% jfif header by specification @@ -283,35 +245,35 @@ bitmap_point_has_color(Bitmap, {W,_}, {X,Y}, C) -> %% 2 bytes, version, (major, minor) %% 1 byte , units %% However, JFIF seems to start at 6 (7 with 1-index)? - + binary_is_jfif_compliant(JpegBin) -> - ?line {Bin, _} = split_binary(JpegBin, 11), + {Bin, _} = split_binary(JpegBin, 11), List = binary_to_list(Bin), case lists:sublist(List, 7, 4) of - "JFIF" -> true; - Other -> - io:format("img -> ~p~n", [Other]), - false + "JFIF" -> true; + Other -> + io:format("img -> ~p~n", [Other]), + false end. binary_is_gif_compliant(GifBin) -> - ?line {Bin, _} = split_binary(GifBin, 10), + {Bin, _} = split_binary(GifBin, 10), List = binary_to_list(Bin), case lists:sublist(List, 1,5) of - "GIF87" -> true; - Other -> - io:format("img -> ~p~n", [Other]), - false + "GIF87" -> true; + Other -> + io:format("img -> ~p~n", [Other]), + false end. binary_is_png_compliant(PngBin) -> - ?line {Bin, _} = split_binary(PngBin, 10), + {Bin, _} = split_binary(PngBin, 10), List = binary_to_list(Bin), case lists:sublist(List, 2,3) of - "PNG" -> true; - Other -> - io:format("img -> ~p~n", [Other]), - false + "PNG" -> true; + Other -> + io:format("img -> ~p~n", [Other]), + false end. %%---------------------------------------------------------------------- @@ -320,20 +282,20 @@ binary_is_png_compliant(PngBin) -> get_rgb() -> - R = random(255), - G = random(255), - B = random(255), - {R,G,B}. + R = random(255), + G = random(255), + B = random(255), + {R,G,B}. get_angle() -> - random(359). + random(359). get_point() -> get_point(get(image_size)). get_point({W,H}) -> - X = random(W - 1), - Y = random(H - 1), - {X,Y}. + X = random(W - 1), + Y = random(H - 1), + {X,Y}. get_size(Max) -> W = trunc(random(Max/2) + Max/2 + 1), @@ -344,7 +306,7 @@ get_size(Max) -> get_points(N) -> get_points(N, []). get_points(0, Out) -> - Out; + Out; get_points(N, Out) -> get_points(N - 1, [get_point() | Out]). diff --git a/lib/percept/test/ipc_tree.erl b/lib/percept/test/ipc_tree.erl index ff1c8d49c1..29da20e83f 100644 --- a/lib/percept/test/ipc_tree.erl +++ b/lib/percept/test/ipc_tree.erl @@ -46,4 +46,4 @@ gather([]) -> ok; gather([_|Pids]) -> receive _ -> gather(Pids) end. workload(0) -> ok; -workload(N) -> math:sin(2), workload(N - 1). +workload(N) -> _ = math:sin(2), workload(N - 1). diff --git a/lib/percept/test/percept_SUITE.erl b/lib/percept/test/percept_SUITE.erl index afb8bbdd5b..141035c631 100644 --- a/lib/percept/test/percept_SUITE.erl +++ b/lib/percept/test/percept_SUITE.erl @@ -22,51 +22,23 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2]). --export([init_per_suite/1, end_per_suite/1]). --export([init_per_testcase/2, end_per_testcase/2]). +-export([all/0, suite/0]). %% Test cases --export([ - app/1, - appup/1, - profile/1, - analyze/1, - analyze_dist/1, - webserver/1 - ]). - -%% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(2)). - -init_per_suite(Config) when is_list(Config) -> - Config. - -end_per_suite(Config) when is_list(Config) -> - Config. - -init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{max_size, 300}, {watchdog,Dog} | Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), - ok. +-export([app/1, + appup/1, + profile/1, + analyze/1, + analyze_dist/1, + webserver/1]). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap, {minutes, 2}}]. all() -> - [app, appup, webserver, profile, analyze, analyze_dist]. - -groups() -> - []. - -init_per_group(_GroupName, Config) -> - Config. - -end_per_group(_GroupName, Config) -> - Config. + [app, appup, webserver, profile, + analyze, analyze_dist]. %%---------------------------------------------------------------------- @@ -75,68 +47,56 @@ end_per_group(_GroupName, Config) -> %% Test that the percept app file is ok app(Config) when is_list(Config) -> - ok = ?t:app_test(percept). + ok = test_server:app_test(percept). %% Test that the percept appup file is ok appup(Config) when is_list(Config) -> - ok = ?t:appup_test(percept). + ok = test_server:appup_test(percept). -webserver(suite) -> - []; -webserver(doc) -> - ["Percept webserver test."]; +%% Percept webserver test. webserver(Config) when is_list(Config) -> % Explicit start inets? - ?line {started, _, Port} = percept:start_webserver(), - ?line ok = percept:stop_webserver(Port), - ?line {started, _, _} = percept:start_webserver(), - ?line ok = percept:stop_webserver(), - ?line {started, _, NewPort} = percept:start_webserver(), - ?line ok = percept:stop_webserver(NewPort), - ?line application:stop(inets), + {started, _, Port} = percept:start_webserver(), + ok = percept:stop_webserver(Port), + {started, _, _} = percept:start_webserver(), + ok = percept:stop_webserver(), + {started, _, NewPort} = percept:start_webserver(), + ok = percept:stop_webserver(NewPort), + application:stop(inets), ok. -profile(suite) -> - []; -profile(doc) -> - ["Percept profile test."]; +%% Percept profile test. profile(Config) when is_list(Config) -> - Path = ?config(data_dir, Config), + Path = proplists:get_value(data_dir, Config), File = filename:join([Path,"profile_test.dat"]), - ?line {ok, _} = percept:profile(File, [procs]), + {ok, _} = percept:profile(File, [procs]), ipc_tree:go(7), - ?line ok = percept:stop_profile(), + ok = percept:stop_profile(), ok. -analyze(suite) -> - []; -analyze(doc) -> - ["Percept analyze test."]; +%% Percept analyze test. analyze(Config) when is_list(Config) -> Begin = processes(), - Path = ?config(data_dir, Config), + Path = proplists:get_value(data_dir, Config), File = filename:join([Path,"profile_test.dat"]), T0 = erlang:monotonic_time(milli_seconds), - ?line ok = percept:analyze(File), + ok = percept:analyze(File), T1 = erlang:monotonic_time(milli_seconds), io:format("percept:analyze/1 took ~w ms.~n", [T1 - T0]), - ?line {stopped, _} = percept_db:stop(), + {stopped, _} = percept_db:stop(), print_remainers(remainers(Begin, processes())), ok. -analyze_dist(suite) -> - []; -analyze_dist(doc) -> - ["Percept analyze distribution test."]; +%% Percept analyze distribution test. analyze_dist(Config) when is_list(Config) -> Begin = processes(), - Path = ?config(data_dir, Config), + Path = proplists:get_value(data_dir, Config), File = filename:join([Path,"ipc-dist.dat"]), T0 = erlang:monotonic_time(milli_seconds), - ?line ok = percept:analyze(File), + ok = percept:analyze(File), T1 = erlang:monotonic_time(milli_seconds), io:format("percept:analyze/1 took ~w ms.~n", [T1 - T0]), - ?line {stopped, _} = percept_db:stop(), + {stopped, _} = percept_db:stop(), print_remainers(remainers(Begin, processes())), ok. @@ -164,9 +124,3 @@ remainers(Begin, [Pid|End], Out) -> true -> remainers(Begin, End, Out); false -> remainers(Begin, End, [Pid|Out]) end. - - - - - - diff --git a/lib/percept/test/percept_db_SUITE.erl b/lib/percept/test/percept_db_SUITE.erl index 5b878e8462..c1d711060c 100644 --- a/lib/percept/test/percept_db_SUITE.erl +++ b/lib/percept/test/percept_db_SUITE.erl @@ -22,54 +22,32 @@ -include_lib("common_test/include/ct.hrl"). %% Test server specific exports --export([all/1]). --export([init_per_suite/1, end_per_suite/1]). --export([init_per_testcase/2, end_per_testcase/2]). +-export([all/0, suite/0]). %% Test cases --export([ - start/1 - ]). +-export([start/1]). %% Default timetrap timeout (set in init_per_testcase) --define(default_timeout, ?t:minutes(2)). -define(restarts, 10). -define(alive_timeout, 500). -init_per_suite(Config) when is_list(Config) -> - Config. +suite() -> + [{timetrap, {minutes, 2}}]. -end_per_suite(Config) when is_list(Config) -> - Config. - -init_per_testcase(_Case, Config) -> - Dog = ?t:timetrap(?default_timeout), - [{max_size, 300}, {watchdog,Dog} | Config]. - -end_per_testcase(_Case, Config) -> - Dog = ?config(watchdog, Config), - ?t:timetrap_cancel(Dog), - ok. - -all(suite) -> - % Test cases +all() -> [start]. %%---------------------------------------------------------------------- %% Tests %%---------------------------------------------------------------------- -start(suite) -> - []; -start(doc) -> - ["Percept_db start and restart test."]; +%% Percept_db start and restart test. start(Config) when is_list(Config) -> ok = restart(?restarts), {stopped, _DB} = percept_db:stop(), ok. -restart(0)-> - ok; +restart(0)-> ok; restart(N)-> {_, DB} = percept_db:start(), timer:sleep(?alive_timeout), |