aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_config.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2010-06-04 15:34:42 +0200
committerRaimo Niskanen <[email protected]>2010-06-09 16:19:23 +0200
commit34cf18550ff792ed9da884b00a49d6accd1bd5f5 (patch)
treed81105e39baec08bba74932fc4490ad7e825acb7 /lib/common_test/src/ct_config.erl
parenta3af252253c1fbc642cf6229ff1e23f095b75b59 (diff)
downloadotp-34cf18550ff792ed9da884b00a49d6accd1bd5f5.tar.gz
otp-34cf18550ff792ed9da884b00a49d6accd1bd5f5.tar.bz2
otp-34cf18550ff792ed9da884b00a49d6accd1bd5f5.zip
Add support for dynamic timetrap handling
Diffstat (limited to 'lib/common_test/src/ct_config.erl')
-rw-r--r--lib/common_test/src/ct_config.erl35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/common_test/src/ct_config.erl b/lib/common_test/src/ct_config.erl
index a6ade3f66b..dc6fcc66e5 100644
--- a/lib/common_test/src/ct_config.erl
+++ b/lib/common_test/src/ct_config.erl
@@ -694,39 +694,48 @@ random_bytes_1(N, Acc) -> random_bytes_1(N-1, [random:uniform(255)|Acc]).
check_callback_load(Callback) ->
case code:is_loaded(Callback) of
{file, _Filename}->
- {ok, Callback};
+ check_exports(Callback);
false->
case code:load_file(Callback) of
{module, Callback}->
- {ok, Callback};
+ check_exports(Callback);
{error, Error}->
{error, Error}
end
end.
+check_exports(Callback) ->
+ Fs = Callback:module_info(exports),
+ case {lists:member({check_parameter,1},Fs),
+ lists:member({read_config,1},Fs)} of
+ {true, true} ->
+ {ok, Callback};
+ _ ->
+ {error, missing_callback_functions}
+ end.
+
check_config_files(Configs) ->
ConfigChecker = fun
({Callback, [F|_R]=Files}) ->
case check_callback_load(Callback) of
- {ok, Callback}->
- if
- is_integer(F) ->
+ {ok, Callback} ->
+ if is_integer(F) ->
Callback:check_parameter(Files);
- is_list(F) ->
+ is_list(F) ->
lists:map(fun(File) ->
- Callback:check_parameter(File)
- end,
- Files)
+ Callback:check_parameter(File)
+ end,
+ Files)
end;
- {error, _}->
- {error, {callback, Callback}}
+ {error, Why}->
+ {error, {callback, {Callback,Why}}}
end;
({Callback, []}) ->
case check_callback_load(Callback) of
{ok, Callback}->
Callback:check_parameter([]);
- {error, _}->
- {error, {callback, Callback}}
+ {error, Why}->
+ {error, {callback, {Callback,Why}}}
end
end,
lists:keysearch(error, 1, lists:flatten(lists:map(ConfigChecker, Configs))).