making new nodes and spawning functions on them inside of common_test

Fredrik Andersson <>
Wed Nov 18 13:51:40 CET 2009


Hi everyone

I want to use common_test to test our system in a more production like
environment than what ordinary unit testing can do. To do this I have setup
a small suite and am currently trying to spawn processes. This does not seem
to work though and I would like to have some pointer as to what I am doing
wrong and if this i even possible.

This is a small sample test that does not work. It seems to hang in the
receive statement for some reason.

-module(pause_SUITE).
-compile(export_all).
-include_lib("common_test/include/ct.hrl").

%%%%%%%%%%%%%%%%
%% common test callbacks %%
%%%%%%%%%%%%%%%%

all() ->
    [pause_resume_test].

init_per_suite(Config) ->
    error_logger:tty(false),

    slave:start(localhost, test_master),
    slave:start(localhost, test_slave),
    Config.

end_per_suite(_Config) ->
    slave:stop(''),
    slave:stop(''),
    ok.

init_per_testcase(_TestCase, Config) ->
    Config.

end_per_testcase(_TestCase, _Config) ->
    ok.

%%%%%%%%%%
%% test cases %%
%%%%%%%%%%

add_jobs(Pid) ->
    Pid ! success.

pause_resume_test(_Config) ->
    spawn('', ?MODULE, add_jobs, [self()]),
    receive
        success -> ok
    end,
    ok.


More information about the erlang-questions mailing list