Source
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
ZBX_VECTOR_DECL(kv, zbx_dc_kv_t)
ZBX_VECTOR_IMPL(kv, zbx_dc_kv_t)
typedef struct
{
zbx_um_cache_t *cache;
zbx_vector_kv_t macros;
zbx_vector_uint64_t hostids;
zbx_um_mock_cache_t mock_cache;
}
zbx_mock_step_t;
ZBX_PTR_VECTOR_DECL(mock_step, zbx_mock_step_t *)
ZBX_PTR_VECTOR_IMPL(mock_step, zbx_mock_step_t *)
static void mock_step_free(zbx_mock_step_t *step)
{
int i;
for (i = step->cache->refcount; i != 0; i--)
um_cache_release(step->cache);
zbx_vector_kv_destroy(&step->macros);
zbx_vector_uint64_destroy(&step->hostids);
zbx_free(step);
}
static void mock_step_validate(zbx_mock_step_t *step)
{
int i;
for (i = 0; i < step->macros.values_num; i++)
{
const char *value = NULL;
um_cache_resolve_const(step->cache, step->hostids.values, step->hostids.values_num,
step->macros.values[i].key, ZBX_MACRO_ENV_SECURE, &value);