olegantonyan / googletest

Automatically exported from code.google.com/p/googletest. Added qmake build
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

why a test's run time is less than zero? #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
my code :
TEST_F(EspheadWrite,testWrite7)
{
        int ret = esphead_write(sockfd, write_head, send_buf, timeout_ms1);
        EXPECT_TRUE(ret == ESPHEAD_RET_SUCCESS);
        ret=esphead_read(data_sockfd, &read_head, read_buf, buf_size,
timeout_ms1);
        EXPECT_TRUE(ret == ESPHEAD_RET_SUCCESS);

        ret=esphead_disconnect(sockfd);
        EXPECT_TRUE(ret == ESPHEAD_RET_SUCCESS);
        usleep(10000);
        ret = esphead_write(sockfd, write_head, send_buf, timeout_ms1);
        EXPECT_EQ(ret,ESPHEAD_RET_EWRITEHEAD);
}

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

why can it be less than zero?

Original issue reported on code.google.com by jingwei...@gmail.com on 14 May 2009 at 9:50

Attachments:

GoogleCodeExporter commented 9 years ago
Please provide the name and version of your compiler and operating system.

It would be great if you could provide a small but complete program that shows 
the 
problem.

Original comment by zhanyong...@gmail.com on 15 May 2009 at 5:12

GoogleCodeExporter commented 9 years ago
compile version: g++
os:red hat linux,2.4.31

the problem don't reappear,
so I can't give out a complete program.

at least,if a time<0,change it to 0……。
Can I know how does it happen?

Original comment by jingwei...@gmail.com on 15 May 2009 at 6:40

GoogleCodeExporter commented 9 years ago
Which version of gcc are you using?  What command line flags are you giving it?

Changing negative time to 0 is not a good option as it gives the user the wrong
impression that the test finished quickly.  It's better to make the user aware 
that
the timing info is bogus and cannot be trusted.

I don't know how it happened as I don't have all the information needed to 
solve the
puzzle.  A repro will really help.

Original comment by zhanyong...@gmail.com on 15 May 2009 at 5:55

GoogleCodeExporter commented 9 years ago
I can think of two possibilities:

1. your test program has a buffer overrun that corrupts the elapsed_time field 
of a test.
2. somehow your system time is modified during the test, causing the end time 
to be
before the start time.

Original comment by zhanyong...@gmail.com on 15 May 2009 at 6:10

GoogleCodeExporter commented 9 years ago
Closing as we cannot repro it.

Original comment by zhanyong...@gmail.com on 5 Jun 2009 at 6:23