Environment variables configuration

Overview

Definition of API to deal with thread-safe stack of jumps. More…

// global functions

static te_errno tapi_sh_env_set(rcf_rpc_server* pco, const char* env_name, const char* env_value, bool force, bool restart);
static te_errno tapi_sh_env_get(rcf_rpc_server* pco, const char* env_name, char** val);
static te_errno tapi_sh_env_get_int(rcf_rpc_server* pco, const char* env_name, int* val);
static te_errno tapi_sh_env_set_int(rcf_rpc_server* pco, const char* env_name, int env_value, bool force, bool restart);
static te_errno tapi_sh_env_save_set(rcf_rpc_server* pco, const char* env_name, bool* existed, char** old_value, const char* new_value, bool restart);
static te_errno tapi_sh_env_unset(rcf_rpc_server* pco, const char* env_name, bool force, bool restart);
static te_errno tapi_sh_env_save_set_int(rcf_rpc_server* pco, const char* env_name, int env_value, bool restart, bool* existed, int* old_value);
static te_errno tapi_sh_env_rollback_int(rcf_rpc_server* pco, const char* env_name, bool existed, int env_value, bool restart);
static te_errno tapi_sh_env_rollback(rcf_rpc_server* pco, const char* env_name, bool existed, const char* env_value, bool restart);
static bool tapi_getenv_bool(const char* var_name);
static te_errno tapi_sh_env_ta_path_append(const char* ta, const char* dir);
int tapi_expand_path_all_ta(const char** dirs);

Detailed Documentation

Definition of API to deal with thread-safe stack of jumps.

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

Global Functions

static te_errno tapi_sh_env_set(rcf_rpc_server* pco, const char* env_name, const char* env_value, bool force, bool restart)

Set shell environment for the given agent and may be restart a PCO so it’s aware.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

env_value

New value

force

Should we only add or overwrite?

restart

Should the PCO be restarted

Returns:

errno

static te_errno tapi_sh_env_get(rcf_rpc_server* pco, const char* env_name, char** val)

Get shell environment for the given agent.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

val

Location for value, memory is allocated with malloc, so the obtained string must be freed after using

Returns:

errno

static te_errno tapi_sh_env_get_int(rcf_rpc_server* pco, const char* env_name, int* val)

Get int shell environment for the given agent.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

val

Location for value

Returns:

errno

static te_errno tapi_sh_env_set_int(rcf_rpc_server* pco, const char* env_name, int env_value, bool force, bool restart)

Set integer shell environment for the given agent and may be restart a PCO so it’s aware.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

env_value

New value

force

Should we only add or overwrite?

restart

Should the PCO be restarted

Returns:

errno

static te_errno tapi_sh_env_save_set(rcf_rpc_server* pco, const char* env_name, bool* existed, char** old_value, const char* new_value, bool restart)

Check whether environment variable exists, save its current value if it does, then set a new value.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

existed

[out] Whether this variable already existed in an environment or not

old_value

[out] Where to save existing value

new_value

New value

restart

Should the PCO be restarted

Returns:

errno

static te_errno tapi_sh_env_unset(rcf_rpc_server* pco, const char* env_name, bool force, bool restart)

Unset environment for the agent and may be restart given PCO.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

force

Ignore if the variable was not set

restart

Should the PCO be restarted?

static te_errno tapi_sh_env_save_set_int(rcf_rpc_server* pco, const char* env_name, int env_value, bool restart, bool* existed, int* old_value)

Set integer shell environment and save previous value if it is necessary.

Parameters:

pco

PCO handle

env_name

Name of the environment variable

env_value

New value

force

Should we only add or overwrite?

restart

Should the PCO be restarted

existed

[out] Whether this variable already existed in an environment or not

old_value

[out] Where to save existing value

Returns:

Status code

static te_errno tapi_sh_env_rollback_int(rcf_rpc_server* pco, const char* env_name, bool existed, int env_value, bool restart)

Rollback integer shell environment variable

Parameters:

pco

PCO handle

env_name

The environment variable name

existed

Did this variable exist in an environment or not

env_value

Integer value to set if the env existed

restart

Should the PCO be restarted

Returns:

Status code

static te_errno tapi_sh_env_rollback(rcf_rpc_server* pco, const char* env_name, bool existed, const char* env_value, bool restart)

Rollback environment variable

Parameters:

pco

PCO handle

env_name

The environment variable name

existed

Did this variable exist in an environment or not

env_value

Value to set if the env existed

restart

Should the PCO be restarted

Returns:

Status code

static bool tapi_getenv_bool(const char* var_name)

Get boolean environment variable on engine. The function stops the test if the variable keeps unexpected value.

Parameters:

var_name

The variable name

Returns:

Boolean value

static te_errno tapi_sh_env_ta_path_append(const char* ta, const char* dir)

Append a location to the PATH on the agent. No restart of the PCOs is done.

Parameters:

ta

Name of the test agent

dir

Directory to be added into the PATH.

Returns:

Status code

int tapi_expand_path_all_ta(const char** dirs)

Add directories to every test agent’s PATH environment variable.

Parameters:

dirs

Array of pointers to directory names terminated by NULL. If dirs itself is NULL, add most commonly required directories (e.g. ‘sbin’ directories).

Returns:

Status code.