aboutsummaryrefslogtreecommitdiffstats
path: root/tests/blogc/check_sysinfo2.c
blob: 9a700595e2656526ea1c2c4f2253da1a664620b6 (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
/*
 * 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 <squareball.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_sb_file_get_contents(const char *path, size_t *len, sb_error_t **err)
{
    assert_string_equal(path, "/proc/1/cgroup");
    *err = sb_strerror_new("");
    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);
}