Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SYSTEM_HW_CHASSIS.c « linux « zbxsysinfo « libs « tests - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a394c8e61e0e1499e5fe200efd3ea95f08a60aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/

#include "zbxmocktest.h"
#include "zbxmockdata.h"
#include "zbxmockutil.h"
#include "zbxmockhelper.h"

#include "zbxcommon.h"
#include "zbxsysinfo.h"

void	zbx_mock_test_entry(void **state)
{
	AGENT_REQUEST		request;
	AGENT_RESULT		result;
	const char		*param, *expected_value;
	int			expected_result, actual_result;

	ZBX_UNUSED(state);

	param = zbx_mock_get_parameter_string("in.param");
	expected_value = zbx_mock_get_parameter_string("out.value");
	expected_result = zbx_mock_str_to_return_code(zbx_mock_get_parameter_string("out.return"));

	zbx_init_agent_request(&request);
	zbx_init_agent_result(&result);

	if (SUCCEED != zbx_parse_item_key(param, &request))
		fail_msg("Cannot parse item key: %s", param);

	if (expected_result != (actual_result = SYSTEM_HW_CHASSIS(&request, &result)))
	{
		fail_msg("Unexpected return code from SYSTEM_HW_CHASSIS(): expected %s, got %s",
				zbx_sysinfo_ret_string(expected_result), zbx_sysinfo_ret_string(actual_result));
	}

	if (SYSINFO_RET_OK == expected_result && 0 == strcmp(expected_value, *ZBX_GET_STR_RESULT(&result)))
	{
		if (NULL == ZBX_GET_STR_RESULT(&result))
			fail_msg("Got 'NULL' instead of '%s' as a value.", expected_value);
	}
	else /* SYSINFO_RET_FAIL == expected_result */
	{
		if (NULL == ZBX_GET_MSG_RESULT(&result) || 0 != strcmp(expected_value, *ZBX_GET_MSG_RESULT(&result)))
		{
				fail_msg("Got '%s' instead of '%s' as a value.",
					(NULL != ZBX_GET_MSG_RESULT(&result) ? *ZBX_GET_MSG_RESULT(&result) : "NULL"),
					expected_value);
		}
	}

	zbx_free_agent_request(&request);
	zbx_free_agent_result(&result);
}