Processes configuration

Overview

Definition of TAPI to configure processes. More…

// typedefs

typedef enum tapi_cfg_ps_exit_status_type_t tapi_cfg_ps_exit_status_type_t;
typedef struct tapi_cfg_ps_exit_status_t tapi_cfg_ps_exit_status_t;

// enums

enum tapi_cfg_ps_exit_status_type_t;

// structs

struct tapi_cfg_ps_exit_status_t;

// global functions

te_errno tapi_cfg_ps_add(const char* ta, const char* ps_name, const char* exe, bool start);
te_errno tapi_cfg_ps_del(const char* ta, const char* ps_name);
te_errno tapi_cfg_ps_start(const char* ta, const char* ps_name);
te_errno tapi_cfg_ps_stop(const char* ta, const char* ps_name);
te_errno tapi_cfg_ps_get_status(const char* ta, const char* ps_name, bool* status);
te_errno tapi_cfg_ps_add_arg(const char* ta, const char* ps_name, unsigned int order, const char* arg);
te_errno tapi_cfg_ps_add_env(const char* ta, const char* ps_name, const char* env_name, const char* value);
te_errno tapi_cfg_ps_add_opt(const char* ta, const char* ps_name, const char* opt_name, const char* value);
te_errno tapi_cfg_ps_set_long_opt_sep(const char* ta, const char* ps_name, const char* value);
te_errno tapi_cfg_ps_set_autorestart(const char* ta, const char* ps_name, unsigned int value);
te_errno tapi_cfg_ps_get_autorestart(const char* ta, const char* ps_name, unsigned int* value);
te_errno tapi_cfg_ps_set_workdir(const char* ta, const char* ps_name, const char* workdir);
te_errno tapi_cfg_ps_get_workdir(const char* ta, const char* ps_name, char** workdir);
te_errno tapi_cfg_ps_kill(const char* ta, const char* ps_name, int signo);
te_errno tapi_cfg_ps_killpg(const char* ta, const char* ps_name, int signo);
te_errno tapi_cfg_ps_wait(const char* ta, const char* ps_name, int timeout_ms, tapi_cfg_ps_exit_status_t* exit_status);

Detailed Documentation

Definition of TAPI to configure processes.

Copyright (C) 2020-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef enum tapi_cfg_ps_exit_status_type_t tapi_cfg_ps_exit_status_type_t

Cause of process termination.

typedef struct tapi_cfg_ps_exit_status_t tapi_cfg_ps_exit_status_t

Structure that represents status of a terminated process.

Global Functions

te_errno tapi_cfg_ps_add(const char* ta, const char* ps_name, const char* exe, bool start)

Add process.

Parameters:

ta

Test Agent.

ps_name

Process name.

exe

Executable to run.

start

Start it just after addition

Returns:

Status code

te_errno tapi_cfg_ps_del(const char* ta, const char* ps_name)

Delete process.

Parameters:

ta

Test Agent.

ps_name

Process name.

Returns:

Status code

te_errno tapi_cfg_ps_start(const char* ta, const char* ps_name)

Start process. For autorestart processes this function should be called only once. The following process executions will be done by the autorestart subsystem.

Parameters:

ta

Test Agent.

ps_name

Process name.

Returns:

Status code

See also:

tapi_cfg_ps_set_autorestart

te_errno tapi_cfg_ps_stop(const char* ta, const char* ps_name)

Stop process. For autorestart processes this function will stop the process and prevent the autorestart subsystem from starting the process over until tapi_cfg_ps_start() is called.

Successfull call of this function guarantees that tapi_cfg_ps_get_status() will return false, thus the process parameters are allowed to be changed (using tapi_cfg_ps_add_arg(), etc.).

Parameters:

ta

Test Agent.

ps_name

Process name.

Returns:

Status code

See also:

tapi_cfg_ps_set_autorestart

te_errno tapi_cfg_ps_get_status(const char* ta, const char* ps_name, bool* status)

Get current process status.

If status is false, the process parameters are allowed to be changed.

Parameters:

ta

Test Agent.

ps_name

Process name.

status

Process current status. For autorestart processes true means that the autorestart subsystem is working with the process and it will be restarted when needed; false means that the process is most likely not running and will not be started by the autorestart subsystem. For other processes true means that the process is running, false that it is not.

Returns:

Status code

See also:

tapi_cfg_ps_set_autorestart

te_errno tapi_cfg_ps_add_arg(const char* ta, const char* ps_name, unsigned int order, const char* arg)

Add process argument.

Parameters:

ta

Test Agent.

ps_name

Process.

order

Relative order.

arg

Argument itself.

Returns:

Status code

te_errno tapi_cfg_ps_add_env(const char* ta, const char* ps_name, const char* env_name, const char* value)

Add environment variable.

Parameters:

ta

Test Agent.

ps_name

Process.

env_name

Variable name.

value

Variable value.

Returns:

Status code

te_errno tapi_cfg_ps_add_opt(const char* ta, const char* ps_name, const char* opt_name, const char* value)

Add option.

Parameters:

ta

Test Agent.

ps_name

Process.

opt_name

Option name.

value

Option value.

Returns:

Status code

te_errno tapi_cfg_ps_set_long_opt_sep(const char* ta, const char* ps_name, const char* value)

Set long option value separator.

Parameters:

ta

Test Agent.

ps_name

Process.

value

Value to set.

Returns:

Status code

te_errno tapi_cfg_ps_set_autorestart(const char* ta, const char* ps_name, unsigned int value)

Set autorestart timeout. The value represents a frequency with which the autorestart subsystem will check whether the process stopped running (regardless of the reason) and restart it if it did.

Parameters:

ta

Test Agent.

ps_name

Process.

value

Autorestart timeout in seconds or 0 to disable autorestart for the process.

Returns:

Status code

te_errno tapi_cfg_ps_get_autorestart(const char* ta, const char* ps_name, unsigned int* value)

Get autorestart timeout.

Parameters:

ta

Test Agent.

ps_name

Process.

value

Autorestart timeout in seconds. If 0 the autorestart is disabled.

Returns:

Status code

te_errno tapi_cfg_ps_set_workdir(const char* ta, const char* ps_name, const char* workdir)

Set working directory.

Parameters:

ta

Test Agent name.

ps_name

Process.

workdir

New process working directory.

Returns:

Status code.

te_errno tapi_cfg_ps_get_workdir(const char* ta, const char* ps_name, char** workdir)

Get working directory.

Parameters:

ta

Test Agent name.

ps_name

Process.

workdir

Process current working directory.

Returns:

Status code.

te_errno tapi_cfg_ps_kill(const char* ta, const char* ps_name, int signo)

Send a signal to the process.

Parameters:

ta

Test Agent.

ps_name

Process.

signo

Number of signal to send.

Returns:

Status code

te_errno tapi_cfg_ps_killpg(const char* ta, const char* ps_name, int signo)

Send a signal to the process’s porcess group.

Parameters:

ta

Test Agent.

ps_name

Process.

signo

Number of signal to send.

Returns:

Status code

te_errno tapi_cfg_ps_wait(const char* ta, const char* ps_name, int timeout_ms, tapi_cfg_ps_exit_status_t* exit_status)

Wait for a process completion (or check its status if timeout_ms is zero).

Parameters of the process are allowed to be changed after successful call of this function.

Parameters:

ta

Test Agent.

ps_name

Process.

timeout_ms

Time to wait for the process. 0 means to check current status and exit, negative value means that the call of the function blocks until the process changes its status.

exit_status

Process exit status location, may be NULL.

0

The process completed running or was never started

TE_EINPROGRESS

The process is still running.

Returns:

Status code