[erlang-questions] eunit question

36 views
Skip to first unread message

Amit Murthy

unread,
Aug 16, 2009, 6:02:38 AM8/16/09
to Erlang
Hi,

I am using eunit for some simple tests and within a test have a need to
sleep for a couple of seconds, i.e. the test function flows something like
this:

func_test() ->
some erlang code...
wait_for_2_seconds(),
some more erlang code....


To implement the wait_for_2_seconds() I have tried
receive after 2000 -> ok end, and
timer:sleep(2000),
as well as writing a simple spin wait function that just does idle
recursive execution in place for 2 seconds.

All of the above basically result in my eunit test function just hanging
forever and the last line printed on screen is

met_fb:request_content_ban_test...*timed out*

where met_fb is the module under test and request_content_ban_test is the
test function.

The actual test function is

request_content_ban_test() ->
?debugFmt("~n~nTEST : request_content_ban", []),
ok = request_content_ban(2, 1, 1, 2, 1),
ok = request_content_ban(3, 1, 1, 3, 2),

% spin loop for 2 seconds
spin_loop(epoch_secs(), 2),

?debugFmt("~n~nTEST : get_content_to_review", []),
Now = epoch_secs(),
[2,3] = get_content_to_review(1, 1, Now - 120),


ok = request_content_ban(4, 1, 1, 9, 3),
[4] = get_content_to_review(1, 1, Now - 1).

Would appreciate any help in figuring out what is going on here.

Regards,
Amit

Richard Carlsson

unread,
Aug 17, 2009, 2:11:04 PM8/17/09
to Amit Murthy, Erlang
Amit Murthy wrote:
> All of the above basically result in my eunit test function just hanging
> forever and the last line printed on screen is
>
> met_fb:request_content_ban_test...*timed out*

Older versions of eunit (before OTP R13B) used to have this
kind of problem. Which version are you using?

/Richard


________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org

Amit Murthy

unread,
Aug 17, 2009, 2:15:36 PM8/17/09
to Richard Carlsson, Erlang
R13A. I guess that explains it.

Amit Murthy

unread,
Aug 16, 2009, 8:24:47 AM8/16/09
to Erlang
My bad.

Seems like the default timeout for a single test is 5 seconds. I increased
it using the "timeout" test descriptor and things are OK now.

But I still don't understand why my erlang console should just hang after
the "met_fb:request_content_ban_test...*timed out*" message is printed.

Amit

Amit Murthy

unread,
Aug 18, 2009, 12:03:45 AM8/18/09
to Richard Carlsson, Erlang
Also the default timeout of around 5 seconds for a single test does not seem
to have been documented anywhere.

Once I increased it using the "timeout" control specification, my test cases
went through.

Amit

Richard Carlsson

unread,
Aug 18, 2009, 4:06:10 AM8/18/09
to Amit Murthy, Erlang
Amit Murthy wrote:
> My bad.
>
> Seems like the default timeout for a single test is 5 seconds. I increased
> it using the "timeout" test descriptor and things are OK now.
>
> But I still don't understand why my erlang console should just hang after
> the "met_fb:request_content_ban_test...*timed out*" message is printed.

It's the eunit frontend that hangs; it's still waiting for some message
from the test, and doesn't return to the shell. But as far as I know,
this only happens in versions before R13B.

Reply all
Reply to author
Forward
0 new messages