Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147250530
D15842.id43918.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D15842.id43918.diff
View Options
Index: head/tests/sys/audit/file-attribute-access.c
===================================================================
--- head/tests/sys/audit/file-attribute-access.c
+++ head/tests/sys/audit/file-attribute-access.c
@@ -661,6 +661,144 @@
}
+ATF_TC_WITH_CLEANUP(pathconf_success);
+ATF_TC_HEAD(pathconf_success, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+ "pathconf(2) call");
+}
+
+ATF_TC_BODY(pathconf_success, tc)
+{
+ /* File needs to exist to call pathconf(2) */
+ ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
+ FILE *pipefd = setup(fds, auclass);
+ /* Get the maximum number of bytes of filename */
+ ATF_REQUIRE(pathconf(path, _PC_NAME_MAX) != -1);
+ check_audit(fds, successreg, pipefd);
+ close(filedesc);
+}
+
+ATF_TC_CLEANUP(pathconf_success, tc)
+{
+ cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(pathconf_failure);
+ATF_TC_HEAD(pathconf_failure, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+ "pathconf(2) call");
+}
+
+ATF_TC_BODY(pathconf_failure, tc)
+{
+ FILE *pipefd = setup(fds, auclass);
+ /* Failure reason: file does not exist */
+ ATF_REQUIRE_EQ(-1, pathconf(errpath, _PC_NAME_MAX));
+ check_audit(fds, failurereg, pipefd);
+}
+
+ATF_TC_CLEANUP(pathconf_failure, tc)
+{
+ cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(lpathconf_success);
+ATF_TC_HEAD(lpathconf_success, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+ "lpathconf(2) call");
+}
+
+ATF_TC_BODY(lpathconf_success, tc)
+{
+ /* Symbolic link needs to exist to call lpathconf(2) */
+ ATF_REQUIRE_EQ(0, symlink("symlink", path));
+ FILE *pipefd = setup(fds, auclass);
+ /* Get the maximum number of bytes of symlink's name */
+ ATF_REQUIRE(lpathconf(path, _PC_SYMLINK_MAX) != -1);
+ check_audit(fds, successreg, pipefd);
+}
+
+ATF_TC_CLEANUP(lpathconf_success, tc)
+{
+ cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(lpathconf_failure);
+ATF_TC_HEAD(lpathconf_failure, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+ "lpathconf(2) call");
+}
+
+ATF_TC_BODY(lpathconf_failure, tc)
+{
+ FILE *pipefd = setup(fds, auclass);
+ /* Failure reason: symbolic link does not exist */
+ ATF_REQUIRE_EQ(-1, lpathconf(errpath, _PC_SYMLINK_MAX));
+ check_audit(fds, failurereg, pipefd);
+}
+
+ATF_TC_CLEANUP(lpathconf_failure, tc)
+{
+ cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(fpathconf_success);
+ATF_TC_HEAD(fpathconf_success, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful "
+ "fpathconf(2) call");
+}
+
+ATF_TC_BODY(fpathconf_success, tc)
+{
+ pid = getpid();
+ snprintf(extregex, sizeof(extregex), "fpathconf.*%d.*success", pid);
+
+ /* File needs to exist to call fpathconf(2) */
+ ATF_REQUIRE((filedesc = open(path, O_CREAT, mode)) != -1);
+ FILE *pipefd = setup(fds, auclass);
+ /* Get the maximum number of bytes of filename */
+ ATF_REQUIRE(fpathconf(filedesc, _PC_NAME_MAX) != -1);
+ check_audit(fds, extregex, pipefd);
+ close(filedesc);
+}
+
+ATF_TC_CLEANUP(fpathconf_success, tc)
+{
+ cleanup();
+}
+
+
+ATF_TC_WITH_CLEANUP(fpathconf_failure);
+ATF_TC_HEAD(fpathconf_failure, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful "
+ "fpathconf(2) call");
+}
+
+ATF_TC_BODY(fpathconf_failure, tc)
+{
+ FILE *pipefd = setup(fds, auclass);
+ const char *regex = "fpathconf.*return,failure : Bad file descriptor";
+ /* Failure reason: Bad file descriptor */
+ ATF_REQUIRE_EQ(-1, fpathconf(-1, _PC_NAME_MAX));
+ check_audit(fds, regex, pipefd);
+}
+
+ATF_TC_CLEANUP(fpathconf_failure, tc)
+{
+ cleanup();
+}
+
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, stat_success);
@@ -693,6 +831,13 @@
ATF_TP_ADD_TC(tp, eaccess_failure);
ATF_TP_ADD_TC(tp, faccessat_success);
ATF_TP_ADD_TC(tp, faccessat_failure);
+
+ ATF_TP_ADD_TC(tp, pathconf_success);
+ ATF_TP_ADD_TC(tp, pathconf_failure);
+ ATF_TP_ADD_TC(tp, lpathconf_success);
+ ATF_TP_ADD_TC(tp, lpathconf_failure);
+ ATF_TP_ADD_TC(tp, fpathconf_success);
+ ATF_TP_ADD_TC(tp, fpathconf_failure);
return (atf_no_error());
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 10, 10:59 AM (10 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29488871
Default Alt Text
D15842.id43918.diff (3 KB)
Attached To
Mode
D15842: Add tests for syscalls concerned with retrieving configurable pathname variables
Attached
Detach File
Event Timeline
Log In to Comment