#102 incorrect testcase diotest4-4

I/O
closed-fixed
Testcases (113)
5
2007-04-27
2006-11-08
Andrew Vagin
No

--- diotest4.c.third 2006-11-02 20:39:35.000000000 +0300
+++ diotest4.c 2006-11-08 16:55:03.000000000 +0300
@@ -284,7 +284,7 @@ main(int argc, char *argv[])
else
tst_resm (TPASS, "Odd count of read and
write");
total++;
-
+ errno = 0;
/* Test-4: Read beyond the file size */
offset = BUFSIZE * (fblocks + 10);
count = bufsize;
output:
.........
diotest4 4 FAIL : allows read beyond file size.
returns 0: Success
........
error is in this logic expression "(ret > 0 || errno !=
EINVAL)"
If read has returned 0, we should not test errno.

Discussion

    • assigned_to: nobody --> robbiew
    • status: open --> closed-fixed
     
  • Andrew Vagin
    Andrew Vagin
    2006-11-09

    Logged In: YES
    user_id=1618673

    How do you fix?

     
  • Andrew Vagin
    Andrew Vagin
    2006-11-09

    fixed bug

     
    Attachments
  • Andrew Vagin
    Andrew Vagin
    2006-11-09

    Logged In: YES
    user_id=1618673

    My patch reduse to fail test, though mustn't. And it should
    not be commit!!!

    Patch for fixing bug:

    --- diotest4.c.third 2006-11-09 15:41:24.000000000 +0300
    +++ diotest4.c 2006-11-09 16:02:54.000000000 +0300
    @@ -280,7 +280,6 @@ main(int argc, char *argv[])
    else
    tst_resm (TPASS, "Odd count of read and write");
    total++;
    - errno = 0;
    /* Test-4: Read beyond the file size */
    offset = BUFSIZE * (fblocks + 10);
    count = bufsize;
    @@ -291,8 +290,8 @@ main(int argc, char *argv[])
    tst_resm (TFAIL, "Read beyond the file size");
    }
    else {
    - ret = read(fd, buf2, count);
    - if (ret > 0 || errno != EINVAL) {
    + TEST(read(fd, buf2, count));
    + if ( (TEST_RETURN != 0) && ((TEST_RETURN>0)
    || ( TEST_ERRNO != EINVAL)) ) {
    tst_resm(TFAIL,"allows read beyond
    file size. returns %d: %s",
    ret, strerror(errno));
    failed = TRUE;

     
  • Andrew Vagin
    Andrew Vagin
    2006-11-09

    • status: closed-fixed --> open-fixed
     
  • Andrew Vagin
    Andrew Vagin
    2006-11-10

    Logged In: YES
    user_id=1618673

    If read return -1, you should check errno. In some version
    of the kernel read return -1 and errno=EINVAL, in other
    read() return 0.

     
  • Subrata Modak
    Subrata Modak
    2007-04-27

    Logged In: YES
    user_id=1737361
    Originator: NO

    Accepted and Fixed.
    Regards--
    Subrata

     
  • Subrata Modak
    Subrata Modak
    2007-04-27

    • status: open-fixed --> closed-fixed