| File tests/commands/misc_fops.c changed (mode: 100644) (index 9bc4bc12c..5dbb34120) |
| 10 |
10 |
|
|
| 11 |
11 |
#include "../../src/compat/fs_limits.h" |
#include "../../src/compat/fs_limits.h" |
| 12 |
12 |
#include "../../src/compat/os.h" |
#include "../../src/compat/os.h" |
|
13 |
|
#include "../../src/engine/keys.h" |
|
14 |
|
#include "../../src/modes/modes.h" |
| 13 |
15 |
#include "../../src/ui/statusbar.h" |
#include "../../src/ui/statusbar.h" |
| 14 |
16 |
#include "../../src/ui/ui.h" |
#include "../../src/ui/ui.h" |
| 15 |
17 |
#include "../../src/utils/fs.h" |
#include "../../src/utils/fs.h" |
| 16 |
18 |
#include "../../src/utils/path.h" |
#include "../../src/utils/path.h" |
| 17 |
19 |
#include "../../src/cmd_core.h" |
#include "../../src/cmd_core.h" |
| 18 |
20 |
#include "../../src/filelist.h" |
#include "../../src/filelist.h" |
|
21 |
|
#include "../../src/ops.h" |
| 19 |
22 |
#include "../../src/registers.h" |
#include "../../src/registers.h" |
|
23 |
|
#include "../../src/undo.h" |
|
24 |
|
|
|
25 |
|
static OpsResult exec_func(OPS op, void *data, const char *src, |
|
26 |
|
const char *dst); |
|
27 |
|
static int op_avail(OPS op); |
| 20 |
28 |
|
|
| 21 |
29 |
static char *saved_cwd; |
static char *saved_cwd; |
| 22 |
30 |
|
|
| |
| ... |
... |
TEST(chmod_works, IF(not_windows)) |
| 124 |
132 |
assert_success(remove(path)); |
assert_success(remove(path)); |
| 125 |
133 |
} |
} |
| 126 |
134 |
|
|
|
135 |
|
TEST(chmod_undo_restores_all_bits, IF(not_windows)) |
|
136 |
|
{ |
|
137 |
|
char path[PATH_MAX + 1]; |
|
138 |
|
|
|
139 |
|
modes_init(); |
|
140 |
|
|
|
141 |
|
undo_teardown(); |
|
142 |
|
|
|
143 |
|
static int max_undo_levels = 1; |
|
144 |
|
un_init(&exec_func, &op_avail, NULL, &max_undo_levels); |
|
145 |
|
|
|
146 |
|
assert_success(chdir(sandbox)); |
|
147 |
|
|
|
148 |
|
strcpy(lwin.curr_dir, sandbox); |
|
149 |
|
append_view_entry(&lwin, "file"); |
|
150 |
|
|
|
151 |
|
snprintf(path, sizeof(path), "%s/file", sandbox); |
|
152 |
|
create_file(path); |
|
153 |
|
assert_success(os_chmod(path, 0777)); |
|
154 |
|
|
|
155 |
|
populate_dir_list(&lwin, /*reload=*/1); |
|
156 |
|
#ifndef _WIN32 |
|
157 |
|
/* Can't just assume 0777 because of umask. */ |
|
158 |
|
int expected_mode = lwin.dir_entry[0].mode & 0777; |
|
159 |
|
#endif |
|
160 |
|
|
|
161 |
|
(void)cmds_dispatch("chmod 000", &lwin, CIT_COMMAND); |
|
162 |
|
|
|
163 |
|
populate_dir_list(&lwin, /*reload=*/1); |
|
164 |
|
#ifndef _WIN32 |
|
165 |
|
assert_int_equal(0000, lwin.dir_entry[0].mode & 0777); |
|
166 |
|
#endif |
|
167 |
|
|
|
168 |
|
(void)cmds_dispatch("normal u", &lwin, CIT_COMMAND); |
|
169 |
|
|
|
170 |
|
populate_dir_list(&lwin, /*reload=*/1); |
|
171 |
|
#ifndef _WIN32 |
|
172 |
|
assert_int_equal(expected_mode, lwin.dir_entry[0].mode & 0777); |
|
173 |
|
#endif |
|
174 |
|
|
|
175 |
|
snprintf(path, sizeof(path), "%s/file", sandbox); |
|
176 |
|
remove_file(path); |
|
177 |
|
|
|
178 |
|
vle_keys_reset(); |
|
179 |
|
} |
|
180 |
|
|
| 127 |
181 |
TEST(putting_files_works) |
TEST(putting_files_works) |
| 128 |
182 |
{ |
{ |
| 129 |
183 |
char path[PATH_MAX + 1]; |
char path[PATH_MAX + 1]; |
| |
| ... |
... |
TEST(zero_count_is_rejected) |
| 190 |
244 |
assert_string_equal(expected, ui_sb_last()); |
assert_string_equal(expected, ui_sb_last()); |
| 191 |
245 |
} |
} |
| 192 |
246 |
|
|
|
247 |
|
static OpsResult |
|
248 |
|
exec_func(OPS op, void *data, const char *src, const char *dst) |
|
249 |
|
{ |
|
250 |
|
return perform_operation(op, NULL, data, src, dst); |
|
251 |
|
} |
|
252 |
|
|
|
253 |
|
static int |
|
254 |
|
op_avail(OPS op) |
|
255 |
|
{ |
|
256 |
|
#ifndef _WIN32 |
|
257 |
|
if(op == OP_CHMOD) |
|
258 |
|
{ |
|
259 |
|
return 1; |
|
260 |
|
} |
|
261 |
|
#endif |
|
262 |
|
return 0; |
|
263 |
|
} |
|
264 |
|
|
| 193 |
265 |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
| 194 |
266 |
/* vim: set cinoptions+=t0 filetype=c : */ |
/* vim: set cinoptions+=t0 filetype=c : */ |