25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Test suite cleanup.

* Split test cases in groups.
* Increase a loglevel of common_test framework.
This commit is contained in:
Evgeniy Khramtsov 2013-06-15 02:35:14 +10:00 committed by Alexey Shchepin
parent b50a4948ed
commit 7b96d8cc24
3 changed files with 43 additions and 47 deletions

View File

@ -251,7 +251,7 @@ dialyzer: plt
--get_warnings -o dialyzer.log ebin
test:
$(REBAR) skip_deps=true ct
$(REBAR) -v skip_deps=true ct
.PHONY: src doc edoc dialyzer Makefile TAGS clean clean-rel distclean rel plt \
install uninstall uninstall-binary uninstall-all translations deps test spec

View File

@ -43,24 +43,23 @@ init_per_suite(Config) ->
application:set_env(ejabberd, log_path, LogPath),
application:set_env(sasl, sasl_error_logger, {file, SASLPath}),
application:set_env(mnesia, dir, MnesiaDir),
ok = application:start(ejabberd),
[{server, <<"localhost">>},
{port, 5222},
{user, <<"test_suite">>},
{password, <<"pass">>},
{certfile, CertFile}
{certfile, CertFile},
{password, <<"password">>}
|Config].
end_per_suite(_Config) ->
ok.
init_per_group(_GroupName, Config) ->
Config.
init_per_group(GroupName, Config) ->
User = list_to_binary(atom_to_list(GroupName)),
set_opt(user, User, Config).
end_per_group(_GroupName, _Config) ->
ok.
init_per_testcase(start_ejabberd, Config) ->
Config;
init_per_testcase(TestCase, OrigConfig) ->
Resource = list_to_binary(atom_to_list(TestCase)),
Config = set_opt(resource, Resource, OrigConfig),
@ -83,6 +82,9 @@ init_per_testcase(TestCase, OrigConfig) ->
auth(connect(Config));
test_open_session ->
bind(auth(connect(Config)));
stop_ejabberd ->
Config1 = set_opt(user, <<"stop_ejabberd">>, Config),
open_session(bind(auth(register(connect(Config1)))));
_ ->
open_session(bind(auth(connect(Config))))
end.
@ -91,13 +93,8 @@ end_per_testcase(_TestCase, _Config) ->
ok.
groups() ->
[].
%%all() -> [start_ejabberd, test_zlib].
all() ->
[start_ejabberd,
test_connect,
[{single_user, [sequence],
[test_connect,
test_starttls,
test_zlib,
test_register,
@ -118,12 +115,10 @@ all() ->
privacy,
blocking,
vcard,
pubsub,
stop_ejabberd].
pubsub]}].
start_ejabberd(Config) ->
ok = application:start(ejabberd),
Config.
all() ->
[{group, single_user}, stop_ejabberd].
stop_ejabberd(Config) ->
ok = application:stop(ejabberd),
@ -175,7 +170,7 @@ disconnect(Config) ->
test_starttls(Config) ->
case ?config(starttls, Config) of
true ->
starttls(Config);
disconnect(starttls(Config));
_ ->
{skipped, 'starttls_not_available'}
end.
@ -187,14 +182,14 @@ starttls(Config) ->
?config(socket, Config),
[{certfile, ?config(certfile, Config)},
connect]),
disconnect(init_stream(set_opt(socket, TLSSocket, Config))).
init_stream(set_opt(socket, TLSSocket, Config)).
test_zlib(Config) ->
case ?config(compression, Config) of
[_|_] = Ms ->
case lists:member(<<"zlib">>, Ms) of
true ->
zlib(Config);
disconnect(zlib(Config));
false ->
{skipped, 'zlib_not_available'}
end;
@ -206,12 +201,12 @@ zlib(Config) ->
_ = send(Config, #compress{methods = [<<"zlib">>]}),
#compressed{} = recv(),
ZlibSocket = ejabberd_socket:compress(?config(socket, Config)),
disconnect(init_stream(set_opt(socket, ZlibSocket, Config))).
init_stream(set_opt(socket, ZlibSocket, Config)).
test_register(Config) ->
case ?config(register, Config) of
true ->
register(Config);
disconnect(register(Config));
_ ->
{skipped, 'registration_not_available'}
end.
@ -231,7 +226,7 @@ register(Config) ->
%% TODO: fix in ejabberd
%% #iq{type = result, id = I2, sub_els = []} = recv(),
#iq{type = result, id = I2, sub_els = [#register{}]} = recv(),
disconnect(Config).
Config.
test_auth(Config) ->
disconnect(auth(Config)).
@ -587,7 +582,7 @@ re_register(Config) ->
recv() ->
receive
{'$gen_event', {xmlstreamelement, El}} ->
ct:log("recv: ~p", [El]),
ct:pal("recv: ~p", [El]),
xmpp_codec:decode(fix_ns(El));
{'$gen_event', Event} ->
Event
@ -624,7 +619,7 @@ send(State, Pkt) ->
{undefined, Pkt}
end,
El = xmpp_codec:encode(NewPkt),
ct:log("sent: ~p", [El]),
ct:pal("sent: ~p", [El]),
ok = send_text(State, xml:element_to_binary(El)),
NewID.

View File

@ -39,6 +39,7 @@
{access, muc, [{allow, all}]}.
{access, pubsub_createnode, [{allow, local}]}.
{access, register, [{allow, all}]}.
{registration_timeout, infinity}.
{language, "en"}.
{modules,
[