blob: 2bb4273a9fe834bcb772e36f98854dcf205fca75 (
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
|
/*
* blogc: A blog compiler.
* Copyright (C) 2014-2019 Rafael G. Martins <rafael@rafaelmartins.eng.br>
*
* This program can be distributed under the terms of the BSD License.
* See the file LICENSE.
*/
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "../../src/common/error.h"
#include "../../src/common/utils.h"
#include "../../src/blogc/sysinfo.h"
// this test exists because we can't test more than one return values for
// blogc_sysinfo_get_inside_docker() in the same binary, because the results
// are cached globally for performance.
char*
__wrap_bc_file_get_contents(const char *path, bool utf8, size_t *len, bc_error_t **err)
{
assert_string_equal(path, "/proc/1/cgroup");
assert_false(utf8);
*err = bc_error_new(0, "");
return NULL;
}
static void
test_sysinfo_get_inside_docker(void **state)
{
assert_false(blogc_sysinfo_get_inside_docker());
}
int
main(void)
{
const UnitTest tests[] = {
unit_test(test_sysinfo_get_inside_docker),
};
return run_tests(tests);
}
|