Commits

arkdro committed 2c1add4

set default app to be used in tests

Comments (0)

Files changed (1)

erlang/src/c_server.erl

                }).
 
 -define(SERVER, ?MODULE).
+-define(DEFAULT_APP, odeci).
 
 %%==================================================================
 %% API
 %% gen_server callbacks
 %%==================================================================
 init(_) ->
-    {ok, PortCommand} = application:get_env(port_command),
+    App = get_app(),
+    {ok, PortCommand} = application:get_env(App, port_command),
     Port = open_port({spawn, PortCommand}, [{packet, 4}, binary, exit_status]),
     port_command(Port, term_to_binary(ping)),
     {ok, #state{status = init, port = Port, portcmd = PortCommand }}.
     State#state{start=undefined, count=Cnt+1, duration=Dur+D}.
 
 %-------------------------------------------------------------------
+get_app() ->
+    case application:get_application() of
+        {ok, App} ->
+            App;
+        undefined ->
+            ?DEFAULT_APP
+    end.
+
+%-------------------------------------------------------------------