From cfe297ce81d7fee179316880d7605b9271715a80 Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 15 Mar 2012 16:31:48 +0000 Subject: Simple test for multi call - and reverse the lists so they come out the same order they went in. --- src/rabbit_misc.erl | 2 +- src/rabbit_tests.erl | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index 3f3aeb62..ddf7f574 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -896,7 +896,7 @@ start_multi_call(Pid, Req) when is_pid(Pid) -> {Mref, Pid}. receive_multi_call([], Good, Bad) -> - {Good, Bad}; + {lists:reverse(Good), lists:reverse(Bad)}; receive_multi_call([{Mref, Pid} | MonitorPids], Good, Bad) -> receive {Mref, Reply} -> diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index f7e3baa7..85fe5426 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -35,6 +35,7 @@ all_tests() -> passed = mirrored_supervisor_tests:all_tests(), application:set_env(rabbit, file_handles_high_watermark, 10, infinity), ok = file_handle_cache:set_limit(10), + passed = test_multi_call(), passed = test_file_handle_cache(), passed = test_backing_queue(), passed = test_priority_queue(), @@ -107,6 +108,26 @@ run_cluster_dependent_tests(SecondaryNode) -> passed. +test_multi_call() -> + Fun = fun() -> + receive + {'$gen_call', {From, Mref}, request} -> + From ! {Mref, response} + end, + receive + never -> ok + end + end, + Pid1 = spawn(Fun), + Pid2 = spawn(Fun), + Pid3 = spawn(Fun), + exit(Pid2, bang), + {[{Pid1, response}, {Pid3, response}], [{Pid2, _Fail}]} = + rabbit_misc:multi_call([Pid1, Pid2, Pid3], request), + exit(Pid1, bang), + exit(Pid3, bang), + passed. + test_priority_queue() -> false = priority_queue:is_queue(not_a_queue), -- cgit v1.2.1