aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests/torture_temp_dir.c
blob: feff23c7f1eaa71c43e4dcd58d16ad3ff6c74a95 (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
#include "config.h"

#include "torture.h"
#define LIBSSH_STATIC

const char template[] = "temp_dir_XXXXXX";

static int setup(void **state)
{
    char *temp_dir = NULL;

    temp_dir = torture_make_temp_dir(template);
    assert_non_null(temp_dir);

    *state = (void *)temp_dir;

    return 0;
}

static int teardown(void **state)
{
    char *temp_dir = *((char **)state);

    torture_rmdirs((const char *)temp_dir);

    free(temp_dir);

    return 0;
}


static void torture_create_temp_dir(void **state)
{
    char *temp_dir = *((char **)state);

    printf("Created temp dir: %s\n", temp_dir);
}

int torture_run_tests(void)
{
    int rc;
    struct CMUnitTest tests[] = {
        cmocka_unit_test_setup_teardown(torture_create_temp_dir, setup, teardown),
    };

    torture_filter_tests(tests);
    rc = cmocka_run_group_tests(tests, NULL, NULL);

    return rc;
}