fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/27054 )
Change subject: PGW_Tests: f_start_prog(): redirect stdout/stderr to files ......................................................................
PGW_Tests: f_start_prog(): redirect stdout/stderr to files
This would allow us to see the output of a program being executed.
Change-Id: I04ab92c13fcd893d39dbb6a8a8af5ff41d207e36 Related: SYS#5602 --- M pgw/PGW_Tests.ttcn 1 file changed, 17 insertions(+), 3 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/pgw/PGW_Tests.ttcn b/pgw/PGW_Tests.ttcn index 2bb0ddc..34090d2 100644 --- a/pgw/PGW_Tests.ttcn +++ b/pgw/PGW_Tests.ttcn @@ -23,6 +23,7 @@ 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 @@ }
/* 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 @@ 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 @@ }
/* 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); }