aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test/snmp_agent_test_lib.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2013-05-30 16:11:51 +0200
committerMicael Karlberg <[email protected]>2013-05-30 16:11:51 +0200
commit315838bc7cb7d9da936c10a3b6fc32c9ea92bca0 (patch)
treea3cdad462da47edaff2800c153d210885e2d00c9 /lib/snmp/test/snmp_agent_test_lib.erl
parentdc22c5fea0753ba7e066d26a9f3a4078af6cb2c5 (diff)
downloadotp-315838bc7cb7d9da936c10a3b6fc32c9ea92bca0.tar.gz
otp-315838bc7cb7d9da936c10a3b6fc32c9ea92bca0.tar.bz2
otp-315838bc7cb7d9da936c10a3b6fc32c9ea92bca0.zip
[snmp/agent] Changed the test suite expect function
There was an id as the first agument to each expect call. Ufortunatly, this id was often 1 and since the same test function(s) was called in many test cases, there was many "Expect 1", and therefor no way of knowing which expect actually was performed. The expect functions has been changed to instead take module and line number.
Diffstat (limited to 'lib/snmp/test/snmp_agent_test_lib.erl')
-rw-r--r--lib/snmp/test/snmp_agent_test_lib.erl41
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/snmp/test/snmp_agent_test_lib.erl b/lib/snmp/test/snmp_agent_test_lib.erl
index 2c24dd3712..11c05fc1db 100644
--- a/lib/snmp/test/snmp_agent_test_lib.erl
+++ b/lib/snmp/test/snmp_agent_test_lib.erl
@@ -58,7 +58,7 @@
init_all/1, finish_all/1,
init_case/1,
try_test/2, try_test/3, try_test/4,
- expect/2, expect/3, expect/4, expect/6,
+ expect/3, expect/4, expect/5, expect/7,
regs/0,
rpc/3
@@ -842,31 +842,33 @@ agent_info(Sup) ->
%% ---
+%% The first two arguments are simple to be able to find where in the
+%% (test) code this call is made.
-expect(Id, A) ->
- Fun = fun() -> do_expect(A) end,
- expect2(Id, Fun).
+expect(Mod, Line, What) ->
+ Fun = fun() -> do_expect(What) end,
+ expect2(Mod, Line, Fun).
-expect(Id, A, B) ->
- Fun = fun() -> do_expect(A, B) end,
- expect2(Id, Fun).
+expect(Mod, Line, What, ExpVBs) ->
+ Fun = fun() -> do_expect(What, ExpVBs) end,
+ expect2(Mod, Line, Fun).
-expect(Id, A, B, C) ->
- Fun = fun() -> do_expect(A, B, C) end,
- expect2(Id, Fun).
+expect(Mod, Line, Error, Index, ExpVBS) ->
+ Fun = fun() -> do_expect(Error, Index, ExpVBS) end,
+ expect2(Mod, Line, Fun).
-expect(Id, A, B, C, D, E) ->
- Fun = fun() -> do_expect(A, B, C, D, E) end,
- expect2(Id, Fun).
+expect(Mod, Line, Type, Enterp, Generic, Specific, ExpVBs) ->
+ Fun = fun() -> do_expect(Type, Enterp, Generic, Specific, ExpVBs) end,
+ expect2(Mod, Line, Fun).
-expect2(Id, F) ->
- io:format("EXPECT for ~w~n", [Id]),
+expect2(Mod, Line, F) ->
+ io:format("EXPECT for ~w:~w~n", [Mod, Line]),
case F() of
{error, Reason} ->
- io:format("EXPECT failed for ~w: ~n~p~n", [Id, Reason]),
- throw({error, {expect, Id, Reason}});
+ io:format("EXPECT failed at ~w:~w => ~n~p~n", [Mod, Line, Reason]),
+ throw({error, {expect, Mod, Line, Reason}});
Else ->
- io:format("EXPECT result for ~w: ~n~p~n", [Id, Else]),
+ io:format("EXPECT result for ~w:~w => ~n~p~n", [Mod, Line, Else]),
Else
end.
@@ -918,7 +920,8 @@ do_expect({timeout, To}) ->
end;
do_expect({Err, To})
- when is_atom(Err) andalso (is_integer(To) orelse (To =:= infinity)) ->
+ when (is_atom(Err) andalso
+ ((is_integer(To) andalso To > 0) orelse (To =:= infinity))) ->
io:format("EXPECT error ~w within ~w~n", [Err, To]),
do_expect({{error, Err}, To});