Source
static zbx_mock_error_t zbx_mock_builtin_parameter(zbx_mock_parameter_t type, const char *name, zbx_mock_handle_t *parameter)
/*
** Copyright (C) 2001-2025 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/>.
**/
FILE *__real_fopen(const char *path, const char *mode);
int __real_fclose(FILE *stream);
static zbx_vector_ptr_t handle_pool; /* a place to store handles provided to mock data user */
static zbx_vector_str_t string_pool; /* a place to store strings provided to mock data user */
static yaml_document_t test_case; /* parsed YAML document with test case data */
static const yaml_node_t *root; /* the root document node */
static const yaml_node_t *in = NULL; /* pointer to "in" section of test case document */
static const yaml_node_t *out = NULL; /* pointer to "out" section of test case document */
static const yaml_node_t *db_data = NULL; /* pointer to "db data" section of test case document */
static const yaml_node_t *files = NULL; /* pointer to "files" section of test case document */
static const yaml_node_t *exit_code = NULL; /* pointer to "exit code" section of test case document */
typedef struct
{
const yaml_node_t *node; /* node of test_case document handle is associated with */
const yaml_node_item_t *item; /* current iterator position for vector handle */
}
zbx_mock_pool_handle_t;
typedef enum
{
ZBX_MOCK_IN, /* parameter from "in" section of test case data */
ZBX_MOCK_OUT, /* parameter from "out" section of test case data */
ZBX_MOCK_DB_DATA, /* data source from "db data" section of test case data */
ZBX_MOCK_FILES /* file contents from "files" section of test case data */
}
zbx_mock_parameter_t;
static const char *zbx_yaml_error_string(yaml_error_type_t error)
{
switch (error)
{
case YAML_NO_ERROR:
return "No error is produced.";
case YAML_MEMORY_ERROR:
return "Cannot allocate or reallocate a block of memory.";
case YAML_READER_ERROR:
return "Cannot read or decode the input stream.";