Debian Codegraph @

tests/unittests/torture_temp_dir.c

raw
1 #include "config.h"
2
3 #include "torture.h"
4 #define LIBSSH_STATIC
5
6 const char template[] = "temp_dir_XXXXXX";
7
8 static int setup(void **state)
9 {
10 char *temp_dir = NULL;
11
12 temp_dir = torture_make_temp_dir(template);
13 assert_non_null(temp_dir);
14
15 *state = (void *)temp_dir;
16
17 return 0;
18 }
19
20 static int teardown(void **state)
21 {
22 char *temp_dir = *((char **)state);
23
24 torture_rmdirs((const char *)temp_dir);
25
26 free(temp_dir);
27
28 return 0;
29 }
30
31
32 static void torture_create_temp_dir(void **state)
33 {
34 char *temp_dir = *((char **)state);
35
36 printf("Created temp dir: %s\n", temp_dir);
37 }
38
39 int torture_run_tests(void)
40 {
41 int rc;
42 struct CMUnitTest tests[] = {
43 cmocka_unit_test_setup_teardown(torture_create_temp_dir, setup, teardown),
44 };
45
46 torture_filter_tests(tests);
47 rc = cmocka_run_group_tests(tests, NULL, NULL);
48
49 return rc;
50 }
51