file-delete.c (a19dca2dfd63cb0205c6fac1fc0c4e00e8bea89a) | file-delete.c (b13a70d5a4979997a0dbc0795d27bb7e22ec794b) |
---|---|
1/*- 2 * Copyright 2018 Aniket Pandey 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 21 unchanged lines hidden (view full) --- 30#include <atf-c.h> 31#include <fcntl.h> 32#include <unistd.h> 33 34#include "utils.h" 35 36static struct pollfd fds[1]; 37static mode_t mode = 0777; | 1/*- 2 * Copyright 2018 Aniket Pandey 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 21 unchanged lines hidden (view full) --- 30#include <atf-c.h> 31#include <fcntl.h> 32#include <unistd.h> 33 34#include "utils.h" 35 36static struct pollfd fds[1]; 37static mode_t mode = 0777; |
38static int filedesc; |
|
38static const char *path = "fileforaudit"; 39static const char *errpath = "dirdoesnotexist/fileforaudit"; 40static const char *successreg = "fileforaudit.*return,success"; 41static const char *failurereg = "fileforaudit.*return,failure"; 42 43 44ATF_TC_WITH_CLEANUP(rmdir_success); 45ATF_TC_HEAD(rmdir_success, tc) --- 41 unchanged lines hidden (view full) --- 87ATF_TC_HEAD(rename_success, tc) 88{ 89 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 90 "rename(2) call"); 91} 92 93ATF_TC_BODY(rename_success, tc) 94{ | 39static const char *path = "fileforaudit"; 40static const char *errpath = "dirdoesnotexist/fileforaudit"; 41static const char *successreg = "fileforaudit.*return,success"; 42static const char *failurereg = "fileforaudit.*return,failure"; 43 44 45ATF_TC_WITH_CLEANUP(rmdir_success); 46ATF_TC_HEAD(rmdir_success, tc) --- 41 unchanged lines hidden (view full) --- 88ATF_TC_HEAD(rename_success, tc) 89{ 90 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 91 "rename(2) call"); 92} 93 94ATF_TC_BODY(rename_success, tc) 95{ |
95 ATF_REQUIRE(open(path, O_CREAT, mode) != -1); | 96 ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1); |
96 FILE *pipefd = setup(fds, "fd"); 97 ATF_REQUIRE_EQ(0, rename(path, "renamed")); 98 check_audit(fds, successreg, pipefd); | 97 FILE *pipefd = setup(fds, "fd"); 98 ATF_REQUIRE_EQ(0, rename(path, "renamed")); 99 check_audit(fds, successreg, pipefd); |
100 close(filedesc); |
|
99} 100 101ATF_TC_CLEANUP(rename_success, tc) 102{ 103 cleanup(); 104} 105 106 --- 22 unchanged lines hidden (view full) --- 129ATF_TC_HEAD(renameat_success, tc) 130{ 131 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 132 "renameat(2) call"); 133} 134 135ATF_TC_BODY(renameat_success, tc) 136{ | 101} 102 103ATF_TC_CLEANUP(rename_success, tc) 104{ 105 cleanup(); 106} 107 108 --- 22 unchanged lines hidden (view full) --- 131ATF_TC_HEAD(renameat_success, tc) 132{ 133 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 134 "renameat(2) call"); 135} 136 137ATF_TC_BODY(renameat_success, tc) 138{ |
137 ATF_REQUIRE(open(path, O_CREAT, mode) != -1); | 139 ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1); |
138 FILE *pipefd = setup(fds, "fd"); 139 ATF_REQUIRE_EQ(0, renameat(AT_FDCWD, path, AT_FDCWD, "renamed")); 140 check_audit(fds, successreg, pipefd); | 140 FILE *pipefd = setup(fds, "fd"); 141 ATF_REQUIRE_EQ(0, renameat(AT_FDCWD, path, AT_FDCWD, "renamed")); 142 check_audit(fds, successreg, pipefd); |
143 close(filedesc); |
|
141} 142 143ATF_TC_CLEANUP(renameat_success, tc) 144{ 145 cleanup(); 146} 147 148 --- 22 unchanged lines hidden (view full) --- 171ATF_TC_HEAD(unlink_success, tc) 172{ 173 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 174 "unlink(2) call"); 175} 176 177ATF_TC_BODY(unlink_success, tc) 178{ | 144} 145 146ATF_TC_CLEANUP(renameat_success, tc) 147{ 148 cleanup(); 149} 150 151 --- 22 unchanged lines hidden (view full) --- 174ATF_TC_HEAD(unlink_success, tc) 175{ 176 atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " 177 "unlink(2) call"); 178} 179 180ATF_TC_BODY(unlink_success, tc) 181{ |
179 ATF_REQUIRE(open(path, O_CREAT, mode) != -1); | 182 ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1); |
180 FILE *pipefd = setup(fds, "fd"); 181 ATF_REQUIRE_EQ(0, unlink(path)); 182 check_audit(fds, successreg, pipefd); | 183 FILE *pipefd = setup(fds, "fd"); 184 ATF_REQUIRE_EQ(0, unlink(path)); 185 check_audit(fds, successreg, pipefd); |
186 close(filedesc); |
|
183} 184 185ATF_TC_CLEANUP(unlink_success, tc) 186{ 187 cleanup(); 188} 189 190 --- 80 unchanged lines hidden --- | 187} 188 189ATF_TC_CLEANUP(unlink_success, tc) 190{ 191 cleanup(); 192} 193 194 --- 80 unchanged lines hidden --- |