Hi Tim,

I took a look at the test, and found there are some problems in the test.

The test looks like:
while(true){
count = read();
if(count <= 0){ // Error! For nonblocking read, returns 0 means non data
available currently
break;
}
}

For nonblocking read, I think "count <= 0" is not the rigth condition to
break out. "count < 0" should be used instead. What's your opnion? I'm not
very sure whether my patch could fix the problem thoroughly because my
netwrok is so good that the test never fails even with "count <= 0".
Thanks!
Here's the patch for this problem: (or shall I raise a separated JIRA ? )

Index:
src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
===================================================================
---
src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
(revision
417326)
+++
src/test/java/org/apache/harmony/tests/java/nio/channels/SocketChannelTest.java
(working
copy)
@@ -2490,7 +2490,7 @@
            int total = 0;
            while (total < CAPACITY_64KB) {
                count = this.channel1.read(buf);
-                if (count <= 0){
+                if (count < 0){
                    break;
                }
                total = total + count;
@@ -2509,13 +2509,13 @@
            count = in.read(serverRBuf);
            while (total < CAPACITY_64KB + 1) {
                count = this.channel1.read(buf);
-                if (count <= 0){
+                if (count < 0){
                    break;
                }
                total = total + count;
            }
            if (total > 0) {
-                assertEquals(total, CAPACITY_64KB);
+                assertEquals(CAPACITY_64KB, total);
                for (int i = 0; i < count; i++) {
                    assertEquals((byte) i, serverRBuf[i]);
                }


On 6/27/06, Tim Ellison <[EMAIL PROTECTED]> wrote:

Apache Harmony Build wrote:
> Online report :
http://ibmonly.hursley.ibm.com/continuum/win.ia32/servlet/continuum/target/ProjectBuild.vm/view/ProjectBuild/id/6/buildId/1435
> Build statistics:
>   State: Failed
>   Previous State: Ok
>   Started at: Mon, 26 Jun 2006 16:09:03 +0100
>   Finished at: Mon, 26 Jun 2006 16:22:52 +0100
>   Total time: 13m 48s
>   Build Trigger: Schedule
>   Exit code: 1
>   Building machine hostname: hy1
>   Operating system : Windows XP(Service Pack 2)
>   Java version : 1.5.0_06(Sun Microsystems Inc.)

<snip>

>      [exec]     [junit] T2 not closed
>      [exec]     [junit] T1 not closed
>      [exec]     [junit] Read fail in capacity64KB,
testReadByteBuffer_NonBlocking_ReadWriteRealTooLargeData not finish.
>      [exec]     [junit] Tests run: 80, Failures: 1, Errors: 0, Time
elapsed: 15.491 sec
>      [exec]     [junit] TEST
org.apache.harmony.tests.java.nio.channels.SocketChannelTest FAILED
>      [exec]     [junit] Tests run: 14, Failures: 0, Errors: 0, Time
elapsed: 0.313 sec
>      [exec]     [junit] Tests run: 3, Failures: 0, Errors: 0, Time
elapsed: 0 sec
>      [exec]     [junit] Tests run: 9, Failures: 0, Errors: 0, Time
elapsed: 0.126 sec
>      [exec]     [junit] Tests run: 2, Failures: 0, Errors: 0, Time
elapsed: 0.016 sec
>      [exec]     [junit] Tests run: 6, Failures: 0, Errors: 0, Time
elapsed: 0.094 sec
>      [exec]     [junit] Tests run: 2, Failures: 0, Errors: 0, Time
elapsed: 0.016 sec
>      [exec]     [junit] Tests FAILED


This test seems to be frequently, if intermittently, failing.

expected:<7300> but was:<65536>

junit.framework.AssertionFailedError: expected:<7300> but was:<65536> at

org.apache.harmony.tests.java.nio.channels.SocketChannelTest.testReadByteBuffer_NonBlocking_ReadWriteRealTooLargeData
(SocketChannelTest.java:2518)
at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:205)



Regards,
Tim

--

Tim Ellison ([EMAIL PROTECTED])
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Andrew Zhang
China Software Development Lab, IBM

Reply via email to