Update ZTS to work on FreeBSD

Update the common ZTS scripts and individual test cases as needed 
in order to allow them to be run on FreeBSD.  The high level goal
is to provide compatibility wrappers whenever possible to minimize
changes to individual test cases.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@ixsystems.com>
Closes #9692
This commit is contained in:
Matthew Macy
2019-12-18 12:29:43 -08:00
committed by Brian Behlendorf
parent 118fc3ef07
commit 7839c4b5e1
145 changed files with 1723 additions and 573 deletions
+9 -5
View File
@@ -2,7 +2,6 @@ EXTRA_DIST = file_common.h
SUBDIRS = \
chg_usr_exec \
user_ns_exec \
devname2devid \
dir_rd_update \
file_check \
@@ -19,11 +18,16 @@ SUBDIRS = \
mmap_libaio \
mmapwrite \
nvlist_to_lua \
randfree_file \
randwritecomp \
readmmap \
rename_dir \
rm_lnkcnt_zero_file \
threadsappend \
xattrtest \
stride_dd
stride_dd \
threadsappend
if BUILD_LINUX
SUBDIRS += \
randfree_file \
user_ns_exec \
xattrtest
endif
+3
View File
@@ -4,3 +4,6 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
pkgexec_PROGRAMS = mkfile
mkfile_SOURCES = mkfile.c
if BUILD_FREEBSD
mkfile_LDADD = -L/usr/local/lib -lintl
endif
+11 -2
View File
@@ -137,8 +137,17 @@ main(int argc, char **argv)
argv++;
argc--;
continue;
}
if (lseek(fd, (off_t)size-1, SEEK_SET) < 0) {
} else if (fchown(fd, getuid(), getgid()) < 0) {
saverr = errno;
(void) fprintf(stderr, gettext(
"Could not set owner/group of %s: %s\n"),
argv[1], strerror(saverr));
(void) close(fd);
errors++;
argv++;
argc--;
continue;
} else if (lseek(fd, (off_t)size-1, SEEK_SET) < 0) {
saverr = errno;
(void) fprintf(stderr, gettext(
"Could not seek to offset %ld in %s: %s\n"),
+4
View File
@@ -55,6 +55,10 @@ main(int argc, char **argv)
(void) fprintf(stderr, "Failed to create %s %s\n", buf,
strerror(errno));
return (-4);
} else if (fchown(fd, getuid(), getgid()) < 0) {
(void) fprintf(stderr, "Failed to chown %s %s\n", buf,
strerror(errno));
return (-5);
}
(void) close(fd);
}
+4
View File
@@ -30,7 +30,9 @@
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#ifdef __linux__
#include <sys/xattr.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -176,11 +178,13 @@ crtfile(char *pname)
exit(errno);
}
#ifdef __linux__
if (fsetxattr(fd, "user.xattr", pbuf, 1024, 0) < 0) {
(void) fprintf(stderr, "fsetxattr(fd, \"xattr\", pbuf, "
"1024, 0) failed.\n[%d]: %s.\n", errno, strerror(errno));
exit(errno);
}
#endif
(void) close(fd);
free(pbuf);