diff --git a/pgw/PGW_Tests.ttcn b/pgw/PGW_Tests.ttcn index 2bb0ddcea..34090d2a8 100644 --- a/pgw/PGW_Tests.ttcn +++ b/pgw/PGW_Tests.ttcn @@ -23,6 +23,7 @@ modulepar { charstring mp_local_hostname_c := "127.0.0.1"; charstring mp_local_hostname_u := "127.0.0.1"; + charstring mp_run_prog_log_path := "/tmp"; charstring mp_run_prog_as_user := "laforge"; charstring mp_ping_hostname := "10.45.0.1"; @@ -394,7 +395,8 @@ private function f_delete_session(template (omit) OCT1 tx_cause := omit, } /* start a program on the user plane side; return its PID */ -private function f_start_prog(charstring command) runs on PGW_Session_CT return integer +private function f_start_prog(charstring command, boolean redirect_output := true) +runs on PGW_Session_CT return integer { var UECUPS_StartProgram sprog := { command := command, @@ -402,6 +404,14 @@ private function f_start_prog(charstring command) runs on PGW_Session_CT return run_as_user := mp_run_prog_as_user, tun_netns_name := g_pars.tun_netns_name }; + + /* Redirect stdout/stderr to the user-specified location */ + if (redirect_output) { + var charstring prefix := mp_run_prog_log_path & "/" & testcasename(); + sprog.command := sprog.command & " 1>>" & prefix & ".prog.stdout"; + sprog.command := sprog.command & " 2>>" & prefix & ".prog.stderr"; + } + log("Starting a program: ", command); var UECUPS_StartProgramRes res := f_gtp2_start_program(sprog); if (res.result != OK) { @@ -432,9 +442,13 @@ private function f_wait_term(integer pid, template (present) integer exit_code : } /* execute a program and wait for result */ -private function f_start_prog_wait(charstring command, template integer exit_code := 0, float tout := 10.0) runs on PGW_Session_CT +private function f_start_prog_wait(charstring command, + template integer exit_code := 0, + float tout := 10.0, + boolean redirect_output := true) +runs on PGW_Session_CT { - var integer pid := f_start_prog(command); + var integer pid := f_start_prog(command, redirect_output); f_wait_term(pid, exit_code, tout); }