diff options
author | Alex Richardson <arichardson@FreeBSD.org> | 2021-02-02 09:55:18 +0000 |
---|---|---|
committer | Alex Richardson <arichardson@FreeBSD.org> | 2021-02-02 09:55:19 +0000 |
commit | 40407d3998d1a12cbe929721f4dbe72b4be478a6 (patch) | |
tree | 762ccc65d25239346a070579df5348199555c35f /tests/sys/audit/utils.c | |
parent | 83c20b8a2da04937cf4af127366b3dc92c855784 (diff) | |
download | src-40407d3998d1a12cbe929721f4dbe72b4be478a6.tar.gz src-40407d3998d1a12cbe929721f4dbe72b4be478a6.zip |
tests/sys/audit: Skip extattr tests if extattrs are not supported
In the CheriBSD CI, we run the testsuite with /tmp as tmpfs. This causes
the extattr audit tests to fail since tmpfs does not (yet) support
extattrs. Skip those tests if the target path is on a file system that
does not support extended file attributes.
While touching these two files also convert the ATF_REQUIRE_EQ(-1, ...)
checks to use ATF_REQURIE_ERRNO().
Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D28392
Diffstat (limited to 'tests/sys/audit/utils.c')
-rw-r--r-- | tests/sys/audit/utils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/sys/audit/utils.c b/tests/sys/audit/utils.c index d7a1e6792b1c..be31f4138412 100644 --- a/tests/sys/audit/utils.c +++ b/tests/sys/audit/utils.c @@ -25,6 +25,8 @@ * $FreeBSD$ */ +#include <sys/types.h> +#include <sys/extattr.h> #include <sys/ioctl.h> #include <bsm/libbsm.h> @@ -204,6 +206,22 @@ check_audit(struct pollfd fd[], const char *auditrgx, FILE *pipestream) { ATF_REQUIRE_EQ(0, fclose(pipestream)); } +void +skip_if_extattr_not_supported(const char *path) +{ + ssize_t result; + + /* + * Some file systems (e.g. tmpfs) do not support extattr, so we need + * skip tests that use extattrs. To detect this we can check whether + * the extattr_list_file returns EOPNOTSUPP. + */ + result = extattr_list_file(path, EXTATTR_NAMESPACE_USER, NULL, 0); + if (result == -1 && errno == EOPNOTSUPP) { + atf_tc_skip("File system does not support extattrs."); + } +} + FILE *setup(struct pollfd fd[], const char *name) { |