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