test - Add test case for prior select(2)/EOF bug
authorSamuel J. Greear <sjg@thesjg.com>
Sun, 5 Dec 2010 03:24:28 +0000 (03:24 +0000)
committerSamuel J. Greear <sjg@thesjg.com>
Sun, 5 Dec 2010 03:24:28 +0000 (03:24 +0000)
* This test reproduces the problem fixed in commit:
  57b24f4ee66aaaa59b54e9577b93253cf435672f

Issue: http://bugs.dragonflybsd.org/issue1809
Submitted-by: Johannes Hofmann
tools/test/select/select_eof.c [new file with mode: 0644]

diff --git a/tools/test/select/select_eof.c b/tools/test/select/select_eof.c
new file mode 100644 (file)
index 0000000..2e65461
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/select.h>
+#include <sys/types.h>
+
+main(int argc, char *argv[])
+{
+    int result, fd;
+    fd_set rset;
+    char tmpstr[] = "seltest.XXXX";
+
+    if ((fd = mkstemp(tmpstr)) < 0) {
+        printf ("Error %d opening temp file\n", errno);
+        exit (-1);
+    }
+
+    lseek(fd, 0, SEEK_END);
+
+    FD_ZERO(&rset);
+    FD_SET(fd, &rset);
+
+    result = select(fd + 1, &rset, 0, 0, 0);
+    if (result == 1)
+        printf("OK\n");
+    else
+        printf("FAIL\n");
+}