|
|
@@ -37,9 +37,10 @@ int fakeclose(int fd, struct s_sandboxenv *env)
|
|
|
}
|
|
|
|
|
|
|
|
|
-int test_open(struct s_sandboxenv *env)
|
|
|
+int test_open(struct s_sandboxenv *env, int *final_fd)
|
|
|
{
|
|
|
t_fileinfo *fi;
|
|
|
+ t_fd *fd_struct;
|
|
|
|
|
|
close(open("_test", O_CREAT, 0644));
|
|
|
_assertEqual(sllist_count(env->filetable), 0);
|
|
|
@@ -48,7 +49,7 @@ int test_open(struct s_sandboxenv *env)
|
|
|
_assertEqual(env->syscall_no.syscall_return, fd);
|
|
|
_assertEqual(sllist_count(env->filetable), 0);
|
|
|
close(fd);
|
|
|
- fd = fakeopen("_test", O_WRONLY, 0, env);
|
|
|
+ fd = fakeopen("_test", O_WRONLY, 0646, env);
|
|
|
_assertDiff(fd, -1);
|
|
|
_assertEqual(env->syscall_no.syscall_return, fd);
|
|
|
_assertEqual(sllist_count(env->filetable), 1);
|
|
|
@@ -61,8 +62,11 @@ int test_open(struct s_sandboxenv *env)
|
|
|
_assertEqual(sllist_count(fi->fds), 2);
|
|
|
fakeclose(fd2, env);
|
|
|
_assertEqual(sllist_count(fi->fds), 1);
|
|
|
- fakeclose(fd, env);
|
|
|
- unlink("_test");
|
|
|
+ fd_struct = sllist_at(fi->fds, 0);
|
|
|
+ _assertNotNull(fd_struct);
|
|
|
+ _assertEqual(fd_struct->fd, fd);
|
|
|
+ _assertEqual(fd_struct->flags, O_WRONLY);
|
|
|
+ _assertEqual(fd_struct->mod, 0646);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -75,14 +79,17 @@ int main()
|
|
|
{
|
|
|
int success = 1;
|
|
|
struct s_sandboxenv env;
|
|
|
+ int fd;
|
|
|
t_param params;
|
|
|
|
|
|
tests_init_env(&env, ¶ms);
|
|
|
|
|
|
- success &= !test_open(&env);
|
|
|
+ success &= !test_open(&env, &fd);
|
|
|
success &= !test_write(&env);
|
|
|
|
|
|
tests_release_env(&env, ¶ms);
|
|
|
+ fakeclose(fd, &env);
|
|
|
+ unlink("_test");
|
|
|
exit(success ? EXIT_SUCCESS: EXIT_FAILURE);
|
|
|
}
|
|
|
|