Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add a new test for PR kern/56713 and set to expected_failure...



details:   https://anonhg.NetBSD.org/src/rev/0697f83e0867
branches:  trunk
changeset: 365868:0697f83e0867
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Apr 29 22:17:49 2022 +0000

description:
Add a new test for PR kern/56713 and set to expected_failure for now.

diffstat:

 distrib/sets/lists/debug/mi                |   3 +-
 distrib/sets/lists/tests/mi                |   8 ++-
 etc/mtree/NetBSD.dist.tests                |   4 +-
 tests/lib/libc/Makefile                    |   3 +-
 tests/lib/libc/kevent_nullmnt/Makefile     |  14 +++++
 tests/lib/libc/kevent_nullmnt/h_nullmnt.c  |  77 ++++++++++++++++++++++++++++++
 tests/lib/libc/kevent_nullmnt/t_nullmnt.sh |  35 +++++++++++++
 7 files changed, 140 insertions(+), 4 deletions(-)

diffs (226 lines):

diff -r 9061f7fc1bbd -r 0697f83e0867 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi       Fri Apr 29 21:39:50 2022 +0000
+++ b/distrib/sets/lists/debug/mi       Fri Apr 29 22:17:49 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.376 2022/04/08 23:35:51 riastradh Exp $
+# $NetBSD: mi,v 1.377 2022/04/29 22:17:49 pgoyette Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib                                      comp-sys-usr            compatdir
 ./usr/lib/i18n/libBIG5_g.a                     comp-c-debuglib         debuglib,compatfile
@@ -2041,6 +2041,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/ieeefp/t_subnormal.debug                tests-obsolete          obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/inet/t_inet_addr.debug          tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/inet/t_inet_network.debug       tests-lib-debug         debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libc/kevent_nullmnt/h_nullmnt.debug  tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_btowc.debug            tests-lib-debug         debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_ctype1.debug           tests-obsolete          obsolete,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libc/locale/t_ctype2.debug           tests-obsolete          obsolete,compattestfile
diff -r 9061f7fc1bbd -r 0697f83e0867 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Apr 29 21:39:50 2022 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Apr 29 22:17:49 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1200 2022/04/28 21:38:38 rillig Exp $
+# $NetBSD: mi,v 1.1201 2022/04/29 22:17:50 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -103,6 +103,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/hash            tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libc/ieeefp          tests-obsolete          obsolete
 ./usr/libdata/debug/usr/tests/lib/libc/inet            tests-lib-debug         compattestfile,atf
+./usr/libdata/debug/usr/tests/lib/libc/kevent_nullmnt  tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libc/locale          tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libc/membar          tests-lib-debug         compattestfile,atf
 ./usr/libdata/debug/usr/tests/lib/libc/misc            tests-lib-debug         compattestfile,atf
@@ -2932,6 +2933,11 @@
 ./usr/tests/lib/libc/inet/Kyuafile                     tests-lib-tests         compattestfile,atf,kyua
 ./usr/tests/lib/libc/inet/t_inet_addr                  tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/inet/t_inet_network               tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/kevent_nullmnt                    tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/kevent_nullmnt/Atffile            tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/kevent_nullmnt/Kyuafile           tests-lib-tests         compattestfile,atf,kyua
+./usr/tests/lib/libc/kevent_nullmnt/h_nullmnt          tests-lib-tests         compattestfile,atf
+./usr/tests/lib/libc/kevent_nullmnt/t_nullmnt          tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/locale                            tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/locale/Atffile                    tests-lib-tests         compattestfile,atf
 ./usr/tests/lib/libc/locale/Kyuafile                   tests-lib-tests         compattestfile,atf,kyua
diff -r 9061f7fc1bbd -r 0697f83e0867 etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Fri Apr 29 21:39:50 2022 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Fri Apr 29 22:17:49 2022 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.190 2022/04/08 23:35:52 riastradh Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.191 2022/04/29 22:17:50 pgoyette Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -85,6 +85,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc/hash
 ./usr/libdata/debug/usr/tests/lib/libc/inet
 ./usr/libdata/debug/usr/tests/lib/libc/locale
+./usr/libdata/debug/usr/tests/lib/libc/kevent_nullmnt
 ./usr/libdata/debug/usr/tests/lib/libc/membar
 ./usr/libdata/debug/usr/tests/lib/libc/misc
 ./usr/libdata/debug/usr/tests/lib/libc/net
@@ -288,6 +289,7 @@
 ./usr/tests/lib/libc/hash/data
 ./usr/tests/lib/libc/inet
 ./usr/tests/lib/libc/locale
+./usr/tests/lib/libc/kevent_nullmnt
 ./usr/tests/lib/libc/membar
 ./usr/tests/lib/libc/misc
 ./usr/tests/lib/libc/net
diff -r 9061f7fc1bbd -r 0697f83e0867 tests/lib/libc/Makefile
--- a/tests/lib/libc/Makefile   Fri Apr 29 21:39:50 2022 +0000
+++ b/tests/lib/libc/Makefile   Fri Apr 29 22:17:49 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.51 2022/04/08 23:35:52 riastradh Exp $
+# $NetBSD: Makefile,v 1.52 2022/04/29 22:17:49 pgoyette Exp $
 
 .include "Makefile.inc"
 .include <bsd.own.mk>
@@ -11,6 +11,7 @@
 TESTS_SUBDIRS+=        gen
 TESTS_SUBDIRS+=        hash
 TESTS_SUBDIRS+=        inet
+TESTS_SUBDIRS+= kevent_nullmnt
 TESTS_SUBDIRS+=        locale
 TESTS_SUBDIRS+=        membar
 TESTS_SUBDIRS+=        misc
diff -r 9061f7fc1bbd -r 0697f83e0867 tests/lib/libc/kevent_nullmnt/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/kevent_nullmnt/Makefile    Fri Apr 29 22:17:49 2022 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2022/04/29 22:17:49 pgoyette Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/lib/libc/kevent_nullmnt
+
+TESTS_SH+=     t_nullmnt
+
+BINDIR=                ${TESTSDIR}
+MKMAN=         no
+
+PROGS+=                h_nullmnt
+
+.include <bsd.test.mk>
diff -r 9061f7fc1bbd -r 0697f83e0867 tests/lib/libc/kevent_nullmnt/h_nullmnt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/kevent_nullmnt/h_nullmnt.c Fri Apr 29 22:17:49 2022 +0000
@@ -0,0 +1,77 @@
+#include <err.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <sys/event.h>
+#include <sys/time.h>
+
+/*
+ * External set-up code is expected to do the equivalent of
+ *     cd $TOPDIR
+ *     mkdir realdir
+ *     mkdir nulldir
+ *     mount -t null $TOPDIR/realdir $TOPDIR/nulldir
+ *     rm -f $TOPDIR/realdir/afile
+ *     touch $TOPDIR/realdir/afile
+ * then execute this test program:
+ *     ./h_nullmnt $TOPDIR/realdir/afile $TOPDIR/nulldir/afile
+ *
+ * The expected result is that the write() to the nullfile will
+ * queue up a preexisting kevent which will then be detected by
+ * the (second) call to kevent(); the failure mode is that the
+ * write()'s extension to the file is not seen, and the kevent
+ * call times out after 5 seconds.
+ *
+ * Clean-up code should undo the null mount and delete everything
+ * in the test directory.
+ */
+
+int main(int argc, char **argv)
+{
+       int realfile, nullfile;
+       int kq, nev, rsize;
+       struct timespec timeout;
+       struct kevent eventlist;
+       const char outbuf[] = "new\n";
+       char inbuf[20];
+
+       if (argc <= 2)
+               errx(EXIT_FAILURE, "insufficient args %d", argc);
+
+       realfile = open(argv[1], O_RDONLY);
+       if (realfile == -1)
+               err(EXIT_FAILURE, "failed to open realfile %s",
+                   argv[1]);
+
+       nullfile = open(argv[2], O_WRONLY, O_APPEND);
+       if (nullfile == -1)
+               err(EXIT_FAILURE, "failed to open nullfile %s",
+                   argv[2]);
+
+       if ((kq = kqueue()) == -1)
+               err(EXIT_FAILURE, "Cannot create kqueue");
+
+       timeout.tv_sec = 5;
+       timeout.tv_nsec = 0;
+
+       EV_SET(&eventlist, realfile,
+           EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR,
+           NOTE_WRITE | NOTE_EXTEND, 0, 0);
+       if (kevent(kq, &eventlist, 1, NULL, 0, NULL) == -1)
+               err(EXIT_FAILURE, "Failed to set eventlist for fd %d",
+                   realfile);
+
+       rsize = read(realfile, &inbuf, sizeof(inbuf));
+       if (rsize)
+               errx(EXIT_FAILURE, "Ooops we got %d bytes of data!\n", rsize);
+
+       write(nullfile, &outbuf, sizeof(outbuf) - 1);
+
+       nev = kevent(kq, NULL, 0, &eventlist, 1, &timeout);
+       if (nev == -1)
+               err(EXIT_FAILURE, "Failed to retrieve event");
+
+       errx((nev == 0) ? EXIT_FAILURE : EXIT_SUCCESS,
+           "Retrieved %d events, first 0x%x", nev, eventlist.flags);
+}
diff -r 9061f7fc1bbd -r 0697f83e0867 tests/lib/libc/kevent_nullmnt/t_nullmnt.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/kevent_nullmnt/t_nullmnt.sh        Fri Apr 29 22:17:49 2022 +0000
@@ -0,0 +1,35 @@
+atf_test_case nullmnt cleanup
+nullmnt_head()
+{ 
+       atf_set "descr" "ensure file events traverse null-mounts"
+}    
+
+nullmnt_body()
+{    
+       srcdir=$(atf_get_srcdir)
+       helper=${srcdir}/h_nullmnt
+
+       mkdir ${srcdir}/realdir
+       mkdir ${srcdir}/nulldir
+       mount -t null ${srcdir}/realdir ${srcdir}/nulldir
+       rm -f ${srcdir}/realdir/afile
+       touch ${srcdir}/realdir/afile
+
+       atf_expect_fail "PR kern/56713"
+
+       atf_check -e ignore -o ignore -s exit:0 \
+               ${helper} ${srcdir}/realdir/afile ${srcdir}/nulldir/afile
+
+} 
+
+nullmnt_cleanup()
+{
+       srcdir=$(atf_get_srcdir)
+       umount ${srcdir}/nulldir
+       rm -rf ${srcdir}/realdir ${srcdir}/nulldir
+}
+
+atf_init_test_cases()
+{
+       atf_add_test_case nullmnt
+}



Home | Main Index | Thread Index | Old Index