Index: stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c (revision 313513) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/h_tools.c (revision 313514) @@ -1,299 +1,312 @@ /* $NetBSD: h_tools.c,v 1.4 2011/06/11 18:03:17 christos Exp $ */ /* * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Helper tools for several tests. These are kept in a single file due * to the limitations of bsd.prog.mk to build a single program in a * given directory. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include +#ifdef __FreeBSD__ +#include +#endif + /* --------------------------------------------------------------------- */ static int getfh_main(int, char **); static int kqueue_main(int, char **); static int rename_main(int, char **); static int sockets_main(int, char **); static int statvfs_main(int, char **); /* --------------------------------------------------------------------- */ int getfh_main(int argc, char **argv) { int error; void *fh; size_t fh_size; if (argc < 2) return EXIT_FAILURE; +#ifdef __FreeBSD__ + fh_size = sizeof(fhandle_t); +#else fh_size = 0; +#endif + fh = NULL; for (;;) { if (fh_size) { fh = malloc(fh_size); if (fh == NULL) { fprintf(stderr, "out of memory"); return EXIT_FAILURE; } } /* * The kernel provides the necessary size in fh_size - * but it may change if someone moves things around, * so retry untill we have enough memory. */ +#ifdef __FreeBSD__ + error = getfh(argv[1], fh); +#else error = getfh(argv[1], fh, &fh_size); +#endif if (error == 0) { break; } else { if (fh != NULL) free(fh); if (errno != E2BIG) { warn("getfh"); return EXIT_FAILURE; } } } error = write(STDOUT_FILENO, fh, fh_size); if (error == -1) { warn("write"); return EXIT_FAILURE; } free(fh); return 0; } /* --------------------------------------------------------------------- */ int kqueue_main(int argc, char **argv) { char *line; int i, kq; size_t len; struct kevent *changes, event; if (argc < 2) return EXIT_FAILURE; argc--; argv++; changes = malloc(sizeof(struct kevent) * argc); if (changes == NULL) errx(EXIT_FAILURE, "not enough memory"); for (i = 0; i < argc; i++) { int fd; fd = open(argv[i], O_RDONLY); if (fd == -1) err(EXIT_FAILURE, "cannot open %s", argv[i]); EV_SET(&changes[i], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT, NOTE_ATTRIB | NOTE_DELETE | NOTE_EXTEND | NOTE_LINK | NOTE_RENAME | NOTE_REVOKE | NOTE_WRITE, 0, 0); } kq = kqueue(); if (kq == -1) err(EXIT_FAILURE, "kqueue"); while ((line = fgetln(stdin, &len)) != NULL) { int ec, nev; struct timespec to; to.tv_sec = 0; to.tv_nsec = 100000; (void)kevent(kq, changes, argc, &event, 1, &to); assert(len > 0); assert(line[len - 1] == '\n'); line[len - 1] = '\0'; ec = system(line); if (ec != EXIT_SUCCESS) errx(ec, "%s returned %d", line, ec); do { nev = kevent(kq, changes, argc, &event, 1, &to); if (nev == -1) err(EXIT_FAILURE, "kevent"); else if (nev > 0) { for (i = 0; i < argc; i++) if (event.ident == changes[i].ident) break; if (event.fflags & NOTE_ATTRIB) printf("%s - NOTE_ATTRIB\n", argv[i]); if (event.fflags & NOTE_DELETE) printf("%s - NOTE_DELETE\n", argv[i]); if (event.fflags & NOTE_EXTEND) printf("%s - NOTE_EXTEND\n", argv[i]); if (event.fflags & NOTE_LINK) printf("%s - NOTE_LINK\n", argv[i]); if (event.fflags & NOTE_RENAME) printf("%s - NOTE_RENAME\n", argv[i]); if (event.fflags & NOTE_REVOKE) printf("%s - NOTE_REVOKE\n", argv[i]); if (event.fflags & NOTE_WRITE) printf("%s - NOTE_WRITE\n", argv[i]); } } while (nev > 0); } for (i = 0; i < argc; i++) close(changes[i].ident); free(changes); return EXIT_SUCCESS; } /* --------------------------------------------------------------------- */ int rename_main(int argc, char **argv) { if (argc < 3) return EXIT_FAILURE; if (rename(argv[1], argv[2]) == -1) { warn("rename"); return EXIT_FAILURE; } return EXIT_SUCCESS; } /* --------------------------------------------------------------------- */ int sockets_main(int argc, char **argv) { int error, fd; struct sockaddr_un addr; if (argc < 2) return EXIT_FAILURE; fd = socket(PF_LOCAL, SOCK_STREAM, 0); if (fd == -1) { warn("socket"); return EXIT_FAILURE; } (void)strlcpy(addr.sun_path, argv[1], sizeof(addr.sun_path)); addr.sun_family = PF_UNIX; error = bind(fd, (struct sockaddr *)&addr, sizeof(addr)); if (error == -1) { warn("connect"); return EXIT_FAILURE; } close(fd); return EXIT_SUCCESS; } /* --------------------------------------------------------------------- */ int statvfs_main(int argc, char **argv) { int error; struct statvfs buf; if (argc < 2) return EXIT_FAILURE; error = statvfs(argv[1], &buf); if (error != 0) { warn("statvfs"); return EXIT_FAILURE; } (void)printf("f_bsize=%lu\n", buf.f_bsize); (void)printf("f_blocks=%" PRId64 "\n", buf.f_blocks); (void)printf("f_bfree=%" PRId64 "\n", buf.f_bfree); (void)printf("f_files=%" PRId64 "\n", buf.f_files); return EXIT_SUCCESS; } /* --------------------------------------------------------------------- */ int main(int argc, char **argv) { int error; if (argc < 2) return EXIT_FAILURE; argc -= 1; argv += 1; if (strcmp(argv[0], "getfh") == 0) error = getfh_main(argc, argv); else if (strcmp(argv[0], "kqueue") == 0) error = kqueue_main(argc, argv); else if (strcmp(argv[0], "rename") == 0) error = rename_main(argc, argv); else if (strcmp(argv[0], "sockets") == 0) error = sockets_main(argc, argv); else if (strcmp(argv[0], "statvfs") == 0) error = statvfs_main(argc, argv); else error = EXIT_FAILURE; return error; } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_mount.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_mount.sh (revision 313513) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_mount.sh (revision 313514) @@ -1,140 +1,155 @@ # $NetBSD: t_mount.sh,v 1.6 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # # Verifies that an execution of mount and umount works correctly without # causing errors and that the root node gets correct attributes. # Also verifies command line parsing from mount_tmpfs. # atf_test_case plain plain_head() { atf_set "descr" "Tests a mount and unmount without any options" atf_set "require.user" "root" } plain_body() { test_mount test_unmount } atf_test_case links links_head() { atf_set "descr" "Tests that the mount point has two hard links" atf_set "require.user" "root" } links_body() { test_mount eval $(stat -s ${Mount_Point}) [ ${st_nlink} = 2 ] || \ atf_fail "Root directory does not have two hard links" test_unmount } atf_test_case options options_head() { atf_set "descr" "Tests the read-only mount option" atf_set "require.user" "root" } options_body() { test_mount -o ro mount | grep ${Mount_Point} | grep -q read-only || \ atf_fail "read-only option (ro) does not work" test_unmount } atf_test_case attrs attrs_head() { atf_set "descr" "Tests that root directory attributes are set" \ "correctly" atf_set "require.user" "root" } attrs_body() { test_mount -o -u1000 -o -g100 -o -m755 eval $(stat -s ${Mount_Point}) [ ${st_uid} = 1000 ] || atf_fail "uid is incorrect" [ ${st_gid} = 100 ] || atf_fail "gid is incorrect" [ ${st_mode} = 040755 ] || atf_fail "mode is incorrect" test_unmount } atf_test_case negative negative_head() { atf_set "descr" "Tests that negative values passed to to -s are" \ "handled correctly" atf_set "require.user" "root" } negative_body() { mkdir tmp test_mount -o -s-10 test_unmount } +# Begin FreeBSD +if true; then +atf_test_case large cleanup +large_cleanup() { + umount -f tmp 2>/dev/null +} +else +# End FreeBSD atf_test_case large +# Begin FreeBSD +fi +# End FreeBSD large_head() { atf_set "descr" "Tests that extremely long values passed to -s" \ "are handled correctly" atf_set "require.user" "root" } large_body() { test_mount -o -s9223372036854775807 test_unmount + + # Begin FreeBSD + atf_expect_fail "-o -s succeeds unexpectedly on FreeBSD - bug 212862" + # End FreeBSD mkdir tmp atf_check -s eq:1 -o empty -e ignore \ mount -t tmpfs -o -s9223372036854775808 tmpfs tmp atf_check -s eq:1 -o empty -e ignore \ mount -t tmpfs -o -s9223372036854775808g tmpfs tmp rmdir tmp } atf_test_case mntpt mntpt_head() { atf_set "descr" "Tests that the error messages printed when the" \ "mount point is invalid do not show the source" \ "unused parameter" } mntpt_body() { mount_tmpfs unused $(pwd)/mnt >out 2>&1 atf_check -s eq:1 -o empty -e empty grep unused out atf_check -s eq:0 -o ignore -e empty grep "$(pwd)/mnt" out mount_tmpfs unused mnt >out 2>&1 atf_check -s eq:1 -o empty -e empty grep unused out atf_check -s eq:0 -o ignore -e empty grep mnt out } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case plain atf_add_test_case options atf_add_test_case attrs atf_add_test_case negative atf_add_test_case large atf_add_test_case mntpt } Index: stable/10/contrib/netbsd-tests/fs/tmpfs/t_remove.sh =================================================================== --- stable/10/contrib/netbsd-tests/fs/tmpfs/t_remove.sh (revision 313513) +++ stable/10/contrib/netbsd-tests/fs/tmpfs/t_remove.sh (revision 313514) @@ -1,110 +1,125 @@ # $NetBSD: t_remove.sh,v 1.5 2010/11/07 17:51:18 jmmv Exp $ # # Copyright (c) 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # # Verifies that the remove operation works. # atf_test_case single single_head() { atf_set "descr" "Checks that file removal works" atf_set "require.user" "root" } single_body() { test_mount atf_check -s eq:1 -o empty -e empty test -f a atf_check -s eq:0 -o empty -e empty touch a atf_check -s eq:0 -o empty -e empty test -f a atf_check -s eq:0 -o empty -e empty rm a atf_check -s eq:1 -o empty -e empty test -f a test_unmount } +# Begin FreeBSD +if true; then +atf_test_case uchg cleanup +uchg_cleanup() { + Mount_Point=$(pwd)/mntpt test_unmount || : +} +else +# End FreeBSD atf_test_case uchg +# Begin FreeBSD +fi +# End FreeBSD uchg_head() { atf_set "descr" "Checks that files with the uchg flag set cannot" \ "be removed" atf_set "require.user" "root" } uchg_body() { + # Begin FreeBSD + atf_expect_fail "this fails on FreeBSD with root - bug 212861" + # End FreeBSD + test_mount atf_check -s eq:0 -o empty -e empty touch a atf_check -s eq:0 -o empty -e empty chflags uchg a atf_check -s eq:1 -o empty -e ignore rm -f a atf_check -s eq:0 -o empty -e empty chflags nouchg a atf_check -s eq:0 -o empty -e empty rm a atf_check -s eq:1 -o empty -e empty test -f a test_unmount } atf_test_case dot dot_head() { atf_set "descr" "Checks that '.' cannot be removed" atf_set "require.user" "root" } dot_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir a atf_check -s eq:1 -o empty -e ignore unlink a/. atf_check -s eq:0 -o empty -e empty rmdir a test_unmount } atf_test_case kqueue kqueue_head() { atf_set "descr" "Removes a file and checks the kqueue events" \ "raised" atf_set "require.user" "root" } kqueue_body() { test_mount atf_check -s eq:0 -o empty -e empty mkdir dir atf_check -s eq:0 -o empty -e empty touch dir/a echo 'rm dir/a' | kqueue_monitor 2 dir dir/a kqueue_check dir/a NOTE_DELETE kqueue_check dir NOTE_WRITE atf_check -s eq:0 -o empty -e empty rmdir dir test_unmount } atf_init_test_cases() { . $(atf_get_srcdir)/../h_funcs.subr . $(atf_get_srcdir)/h_funcs.subr atf_add_test_case single atf_add_test_case uchg atf_add_test_case dot atf_add_test_case kqueue } Index: stable/10 =================================================================== --- stable/10 (revision 313513) +++ stable/10 (revision 313514) Property changes on: stable/10 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r307190,307196,307204-307205