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

zbxmockexit.c « tests - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2a1d5a73dd2cc2cf51e4259e51b9dd6170144602 (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
/*
** 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.
**/

#define exit	__real_exit
#include <stdlib.h>
#undef exit

#include "zbxmocktest.h"
#include "zbxmockdata.h"

#include "common.h"

void	__wrap_exit(int status);

void	__wrap_exit(int status)
{
	zbx_mock_error_t	error;
	int			expected_status;

	if (ZBX_MOCK_NO_EXIT_CODE == (error = zbx_mock_exit_code(&expected_status)))
		expected_status = EXIT_SUCCESS;
	else
	{
		if (ZBX_MOCK_SUCCESS != error)
			fail_msg("Cannot get exit code from test case data: %s", zbx_mock_error_string(error));
	}

	switch (status)
	{
		case EXIT_SUCCESS:
		case EXIT_FAILURE:
			if (status != expected_status)
				fail_msg("exit() called with status %d, expected %d.", status, expected_status);
			__real_exit(EXIT_SUCCESS);
		default:
			fail_msg("exit() called with status %d that is neither EXIT_SUCCESS nor EXIT_FAILURE.", status);
	}
}