File: mocks-syslog.c

package info (click to toggle)
rpma 1.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,040 kB
  • sloc: ansic: 27,313; sh: 1,805; perl: 1,148; makefile: 8
file content (53 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (2)
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
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2020, Intel Corporation */

/*
 * mocks-syslog.c -- syslog mocks
 */

#include "cmocka_headers.h"
#include "mocks-stdio.h"
#include "test-common.h"

/*
 * openlog -- openlog() mock
 */
void
openlog(const char *__ident, int __option, int __facility)
{
	check_expected(__ident);
	check_expected(__option);
	check_expected(__facility);
}

/*
 * closelog -- closelog() mock
 */
void
closelog(void)
{
	function_called();
}

/*
 * syslog -- syslog() mock
 */
void
syslog(int priority, const char *format, ...)
{
	static char syslog_output[MOCK_BUFF_LEN];

	va_list ap;
	va_start(ap, format);
	int ret = __real_vsnprintf(syslog_output, MOCK_BUFF_LEN, format, ap);
	assert_true(ret > 0);
	va_end(ap);

	int cmd = mock_type(int);
	if (cmd == MOCK_VALIDATE) {
		check_expected(priority);
		check_expected_ptr(syslog_output);
	} else {
		assert_int_equal(cmd, MOCK_PASSTHROUGH);
	}
}