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
This commit is contained in:
parent
ca587f154c
commit
284c68e735
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue