1: %%
    2: %% %CopyrightBegin%
    3: %%
    4: %% Copyright Ericsson AB 2007-2011. All Rights Reserved.
    5: %%
    6: %% The contents of this file are subject to the Erlang Public License,
    7: %% Version 1.1, (the "License"); you may not use this file except in
    8: %% compliance with the License. You should have received a copy of the
    9: %% Erlang Public License along with this software. If not, it can be
   10: %% retrieved online at http://www.erlang.org/.
   11: %%
   12: %% Software distributed under the License is distributed on an "AS IS"
   13: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
   14: %% the License for the specific language governing rights and limitations
   15: %% under the License.
   16: %%
   17: %% %CopyrightEnd%
   18: %%
   19: 
   20: -module(fun_r13_SUITE).
   21: -compile(r13).
   22: 
   23: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
   24: 	 init_per_group/2,end_per_group/2,
   25: 	 init_per_testcase/2,end_per_testcase/2,dist_old_release/1]).
   26: 
   27: -define(default_timeout, ?t:minutes(1)).
   28: -include_lib("test_server/include/test_server.hrl").
   29: 
   30: suite() -> [{ct_hooks,[ts_install_cth]}].
   31: 
   32: all() ->
   33:     [dist_old_release].
   34: 
   35: groups() ->
   36:     [].
   37: 
   38: init_per_suite(Config) ->
   39:     Config.
   40: 
   41: end_per_suite(_Config) ->
   42:     ok.
   43: 
   44: init_per_group(_GroupName, Config) ->
   45:     Config.
   46: 
   47: end_per_group(_GroupName, Config) ->
   48:     Config.
   49: 
   50: 
   51: init_per_testcase(_Case, Config) ->
   52:     ?line Dog = test_server:timetrap(?default_timeout),
   53:     [{watchdog, Dog}|Config].
   54: 
   55: end_per_testcase(_Case, Config) ->
   56:     Dog=?config(watchdog, Config),
   57:     test_server:timetrap_cancel(Dog),
   58:     ok.
   59: 
   60: dist_old_release(Config) when is_list(Config) ->
   61:     case ?t:is_release_available("r12b") of
   62: 	true -> do_dist_old(Config);
   63: 	false -> {skip,"No R12B found"}
   64:     end.
   65: 
   66: do_dist_old(Config) when is_list(Config) ->
   67:     ?line Pa = filename:dirname(code:which(?MODULE)),
   68:     Name = fun_dist_r12,
   69:     ?line {ok,Node} = ?t:start_node(Name, peer,
   70: 				    [{args,"-pa "++Pa},
   71: 				     {erl,[{release,"r12b"}]}]),
   72: 
   73:     ?line Pid = spawn_link(Node,
   74: 			   fun() ->
   75: 				   receive
   76: 				       Fun when is_function(Fun) ->
   77: 					   R12BFun = fun(H) -> cons(H, [b,c]) end,
   78: 					   Fun(Fun, R12BFun)
   79: 				   end
   80: 			   end),
   81:     Self = self(),
   82:     Fun = fun(F, R12BFun) ->
   83: 		  {pid,Self} = erlang:fun_info(F, pid),
   84: 		  {module,?MODULE} = erlang:fun_info(F, module),
   85: 		  Self ! {ok,F,R12BFun}
   86: 	  end,
   87:     ?line Pid ! Fun,
   88:     ?line receive
   89: 	      {ok,Fun,R12BFun} ->
   90: 		  ?line [a,b,c] = R12BFun(a);
   91: 	      Other ->
   92: 		  ?line ?t:fail({bad_message,Other})
   93: 	  end,
   94:     ok.
   95: 
   96: cons(H, T) ->
   97:     [H|T].