Bug 191349 - [tests] Failure with tools/regression/file/flock testcase # 16; testcase doesn't deal with EINTR properly
Summary: [tests] Failure with tools/regression/file/flock testcase # 16; testcase does...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.0-STABLE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-24 21:36 UTC by Enji Cooper
Modified: 2014-06-26 02:17 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enji Cooper freebsd_committer 2014-06-24 21:36:05 UTC
Testcase # 16 of tools/regression/file/flock fails because it doesn't properly
handle EINTR in the test thread:

# git log -n 1 .
commit 4af3a7a23ff67d621a71f1a73ff8ea3f892a07d9
Author: ru <ru@FreeBSD.org>
Date:   Thu Feb 25 14:42:26 2010 +0000

    Fixed missing or broken library dependencies.

Notes:
    svn path=/head/; revision=204311

# ./flock . 16
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
fcntl failed: Interrupted system call
16 - F_SETLKW on locked region by two threads: FAIL ((uintptr_t)res != 0)
# git diff .
diff --git a/tools/regression/file/flock/flock.c b/tools/regression/file/flock/flock.c
index c411853..cb575d2 100644
--- a/tools/regression/file/flock/flock.c
+++ b/tools/regression/file/flock/flock.c
@@ -27,6 +27,7 @@
  * $FreeBSD$
  */

+#include <sys/param.h>
 #include <sys/time.h>
 #ifdef __FreeBSD__
 #include <sys/mount.h>
@@ -55,7 +56,7 @@
 #endif
 #endif

-int verbose = 0;
+static int verbose = 0;

 static int
 make_file(const char *pathname, off_t sz)
@@ -1413,7 +1414,11 @@ test16_func(void *tc_in)
        uintptr_t error;
        struct test_ctx *tc = tc_in;

-       error = fcntl(tc->tc_fd, F_SETLKW, &tc->tc_fl);
+       if (fcntl(tc->tc_fd, F_SETLKW, &tc->tc_fl) == -1) {
+               error = errno;
+               perror("fcntl failed");
+       } else
+               error = 0;

        pthread_exit((void *)error);
 }
@@ -1514,7 +1519,7 @@ struct test {
        int intr;               /* non-zero if the test interrupts a lock */
 };

-struct test tests[] = {
+static struct test tests[] = {
        {       test1,          1,      0       },
        {       test2,          2,      0       },
        {       test3,          3,      1       },
@@ -1532,7 +1537,6 @@ struct test tests[] = {
        {       test15,         15,     1       },
        {       test16,         16,     1       },
 };
-int test_count = sizeof(tests) / sizeof(tests[0]);

 int
 main(int argc, const char *argv[])
@@ -1540,10 +1544,10 @@ main(int argc, const char *argv[])
        int testnum;
        int fd;
        int nointr;
-       int i;
        struct sigaction sa;
        int test_argc;
        const char **test_argv;
+       unsigned int i;

        if (argc < 2) {
                errx(1, "usage: flock <directory> [test number] ...");
@@ -1578,7 +1582,7 @@ main(int argc, const char *argv[])
        }
 #endif

-       for (i = 0; i < test_count; i++) {
+       for (i = 0; i < nitems(tests); i++) {
                if (tests[i].intr && nointr)
                        continue;
                if (!testnum || tests[i].num == testnum)
#

The testcase should be fixed or disabled.
Comment 1 Enji Cooper freebsd_committer 2014-06-24 21:38:52 UTC
Sorry. I called git log incorrectly. This is what I meant to do:

# git log -n 1
commit d1fedb79716b3633051843a297eabe4593846eeb
Author: delphij <delphij@FreeBSD.org>
Date:   Tue Jun 24 19:04:55 2014 +0000

    Fix multiple vulnerabilities in file(1) and libmagic(3).

    Security:   FreeBSD-SA-14:16.file
    Approved by:        so

Notes:
    svn path=/stable/10/; revision=267828