#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <string.h>#include <errno.h>#include <poll.h>#include <fcntl.h>#include <sys/time.h>#include <sys/wait.h>#include <signal.h>#include <sched.h>#include <libxml/xmlstring.h>#include "remote_executor.h"#include <time.h>#include <syslog.h>#include "testrunnerlite.h"Go to the source code of this file.
Functions | |
| static pid_t | fork_process_redirect (int *stdout_fd, int *stderr_fd, const char *command) |
| static pid_t | fork_process (const char *command) |
| static void * | stream_data_realloc (stream_data *data, int size) |
| static void | stream_data_free (stream_data *data) |
| static void | stream_data_append (stream_data *data, char *src) |
| static int | read_and_append (int fd, stream_data *data) |
| static void | timer_handler (int signum) |
| static int | set_timer (long secs) |
| static void | reset_timer () |
| static int | execution_terminated (exec_data *data) |
| static void | process_output_streams (int stdout_fd, int stderr_fd, exec_data *data) |
| static void | communicate (int stdout_fd, int stderr_fd, exec_data *data) |
| static void | strip_ctrl_chars (stream_data *data) |
| static void | utf8_check (stream_data *data, const char *id, pid_t pid) |
| static int | exec_wrapper (const char *command) |
| int | execute (const char *command, exec_data *data) |
| void | init_exec_data (exec_data *data) |
| void | clean_exec_data (exec_data *data) |
| void | init_stream_data (stream_data *data, int allocate) |
| void | clean_stream_data (stream_data *data) |
| void | kill_pgroup (int pgroup, int sig) |
| void | executor_init (testrunner_lite_options *opts) |
| void | executor_close () |
| void | handle_sigint (int signum) |
| void | handle_sigterm (int signum) |
Variables | |
| int | bail_out |
| char * | global_failure |
| static volatile sig_atomic_t | timer_value = 0 |
| static struct sigaction | default_alarm_action = { .sa_handler = NULL } |
| static testrunner_lite_options * | options |
| static exec_data * | current_data |
| void clean_exec_data | ( | exec_data * | data | ) |
Definition at line 837 of file executor.c.
| void clean_stream_data | ( | stream_data * | data | ) |
Clean stream_data structure
| data | Pointer to data |
Definition at line 862 of file executor.c.
| static void communicate | ( | int | stdout_fd, | |
| int | stderr_fd, | |||
| exec_data * | data | |||
| ) | [static] |
Set timeout timers, read output, and control execution of test step
| stdout_fd | File descriptor to read stdout stream | |
| stderr_fd | File descriptor to read stderr stream | |
| data | Input and output data controlling execution |
Definition at line 589 of file executor.c.
| static int exec_wrapper | ( | const char * | command | ) | [static] |
Executes a command on local or remote host
| command | Command to execute |
Definition at line 169 of file executor.c.
| int execute | ( | const char * | command, | |
| exec_data * | data | |||
| ) |
Execute a test step command
| command | Command to execute | |
| data | Input and output data controlling execution |
Definition at line 776 of file executor.c.
| static int execution_terminated | ( | exec_data * | data | ) | [static] |
Do unblocking wait for state change of process(es) belonging to process group
| data | Input and output data of the process |
Definition at line 450 of file executor.c.
| void executor_close | ( | ) |
Clean up for executor
Definition at line 903 of file executor.c.
| void executor_init | ( | testrunner_lite_options * | opts | ) |
Sets the remote host for executor
| opts | testrunner lite options |
Definition at line 893 of file executor.c.
| static pid_t fork_process | ( | const char * | command | ) | [static] |
Create new process with new session ID
| command | Command to execute |
Definition at line 257 of file executor.c.
| static pid_t fork_process_redirect | ( | int * | stdout_fd, | |
| int * | stderr_fd, | |||
| const char * | command | |||
| ) | [static] |
Create new process with new session ID and redirect its output
| stdout_fd | Pointer to a file descriptor used to read stdout of executed command | |
| stderr_fd | Pointer to a file descriptor used to read stderr of executed command | |
| command | Command to execute |
Definition at line 192 of file executor.c.
| void handle_sigint | ( | int | signum | ) |
Definition at line 912 of file executor.c.
| void handle_sigterm | ( | int | signum | ) |
Definition at line 926 of file executor.c.
| void init_exec_data | ( | exec_data * | data | ) |
Initialize exec_data structure
| data | Pointer to data |
Definition at line 825 of file executor.c.
| void init_stream_data | ( | stream_data * | data, | |
| int | allocate | |||
| ) |
Initialize stream_data structure
| data | Pointer to data | |
| allocate | Number of bytes to allocate for string buffer |
Definition at line 847 of file executor.c.
| void kill_pgroup | ( | int | pgroup, | |
| int | sig | |||
| ) |
Send signal to process group of a test process
| pgroup | Process group ID for signal | |
| sig | Signal number |
Definition at line 870 of file executor.c.
| static void process_output_streams | ( | int | stdout_fd, | |
| int | stderr_fd, | |||
| exec_data * | data | |||
| ) | [static] |
Read output streams from executed process
| stdout_fd | File descriptor to read stdout stream | |
| stderr_fd | File descriptor to read stderr stream | |
| data | Input and output data controlling execution |
Definition at line 543 of file executor.c.
| static int read_and_append | ( | int | fd, | |
| stream_data * | data | |||
| ) | [static] |
Read data from file descriptor and append to stream_data. Reallocates memory if necessary
| fd | File descriptor to read | |
| data | Pointer to stream_data structure |
Definition at line 333 of file executor.c.
| static void reset_timer | ( | ) | [static] |
Reset timer and restore signal action of SIGALRM
Definition at line 422 of file executor.c.
| static int set_timer | ( | long | secs | ) | [static] |
Initialize timer and set signal action for SIGALRM
| secs | Value in seconds after which global variable timer_value will be set |
Definition at line 381 of file executor.c.
| static void stream_data_append | ( | stream_data * | data, | |
| char * | src | |||
| ) | [static] |
Append data to stream_data and reallocate memory if necessary
| data | Pointer to stream_data structure | |
| src | Data to append |
Definition at line 316 of file executor.c.
| static void stream_data_free | ( | stream_data * | data | ) | [static] |
Free memory allocated for stream_data
| data | Pointer to stream_data structure |
Definition at line 305 of file executor.c.
| static void * stream_data_realloc | ( | stream_data * | data, | |
| int | size | |||
| ) | [static] |
Allocate memory for stream_data
| data | Pointer to stream_data structure | |
| size | Number of bytes to be allocated |
Definition at line 283 of file executor.c.
| static void strip_ctrl_chars | ( | stream_data * | data | ) | [static] |
Replace control characters with space
| data | stream data to mangle |
Definition at line 671 of file executor.c.
| static void timer_handler | ( | int | signum | ) | [static] |
Signal handler for SIGALRM (timer)
| signum | Identifier of received signal |
Definition at line 370 of file executor.c.
| static void utf8_check | ( | stream_data * | data, | |
| const char * | id, | |||
| pid_t | pid | |||
| ) | [static] |
If the data contains non utf-8 write the data to file instead of result xml
| data | stream data to mangle | |
| id | identifier (stdout/stderr) | |
| pid | pid of test step |
Definition at line 710 of file executor.c.
| int bail_out |
Definition at line 67 of file testdefinitionprocessor.c.
exec_data* current_data [static] |
Definition at line 77 of file executor.c.
struct sigaction default_alarm_action = { .sa_handler = NULL } [static] |
Definition at line 75 of file executor.c.
| char* global_failure |
Definition at line 66 of file testdefinitionprocessor.c.
testrunner_lite_options* options [static] |
Definition at line 76 of file executor.c.
volatile sig_atomic_t timer_value = 0 [static] |
Definition at line 74 of file executor.c.
1.6.3