This source file includes following definitions.
- setup
- teardown
- START_TEST
- START_TEST
- main
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 #define TEST_SUITE_NAME "/lib/vfs"
27
28 #include "tests/mctest.h"
29
30 #include "lib/charsets.h"
31 #include "lib/strutil.h"
32 #include "lib/vfs/xdirentry.h"
33 #include "lib/vfs/path.h"
34
35 #include "src/vfs/local/local.c"
36
37
38
39
40 static void
41 setup (void)
42 {
43
44 g_unsetenv ("MC_TMPDIR");
45
46 str_init_strings (NULL);
47
48 vfs_init ();
49 vfs_init_localfs ();
50 vfs_setup_work_dir ();
51 }
52
53
54
55
56 static void
57 teardown (void)
58 {
59 vfs_shut ();
60 str_uninit_strings ();
61 }
62
63
64
65
66 START_TEST (test_mc_tmpdir)
67 {
68
69 const char *tmpdir;
70 const char *env_tmpdir;
71
72
73 tmpdir = mc_tmpdir ();
74 env_tmpdir = g_getenv ("MC_TMPDIR");
75
76
77 ck_assert_msg (g_file_test (tmpdir, G_FILE_TEST_EXISTS)
78 && g_file_test (tmpdir, G_FILE_TEST_IS_DIR),
79 "\nNo such directory: %s\n", tmpdir);
80 mctest_assert_str_eq (env_tmpdir, tmpdir);
81 }
82 END_TEST
83
84
85
86
87 START_TEST (test_mc_mkstemps)
88 {
89
90 vfs_path_t *pname_vpath = NULL;
91 char *begin_pname;
92 int fd;
93
94
95 fd = mc_mkstemps (&pname_vpath, "mctest-", NULL);
96 begin_pname = g_build_filename (mc_tmpdir (), "mctest-", (char *) NULL);
97
98
99 close (fd);
100 ck_assert_int_ne (fd, -1);
101
102 const char *pname = vfs_path_as_str (pname_vpath);
103
104 ck_assert_msg (g_file_test (pname, G_FILE_TEST_EXISTS)
105 && g_file_test (pname, G_FILE_TEST_IS_REGULAR),
106 "\nNo such file: %s\n", pname);
107 unlink (pname);
108 ck_assert_msg (strncmp (pname, begin_pname, strlen (begin_pname)) == 0,
109 "\nstart of %s should be equal to %s\n", pname, begin_pname);
110 vfs_path_free (pname_vpath, TRUE);
111 }
112 END_TEST
113
114
115
116 int
117 main (void)
118 {
119 TCase *tc_core;
120
121 tc_core = tcase_create ("Core");
122
123 tcase_add_checked_fixture (tc_core, setup, teardown);
124
125
126 tcase_add_test (tc_core, test_mc_tmpdir);
127 tcase_add_test (tc_core, test_mc_mkstemps);
128
129
130 return mctest_run_all (tc_core);
131 }
132
133