-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.1
-
x86
-
windows_98
Name: aaR10208 Date: 04/30/2002
Filed By : J2SE-SQA [###@###.###
JDK : jdk1.4.1-b10
JCK : JCK1.4-b17
Platform[s] : Windows 98, Windows ME
switch/Mode : -client -Xcomp -Xfuture, -client -Xfuture
JCK test owner : http://javaweb.eng/jck/usr/owners.jto
Failing Test : api/java_net/InetSocketAddress/index.html#Ctor [InetSocketAddress0008]
The test tries to resolve different hosts using two differerent ways and compares results.
The problem is that this two ways both use InetAddress.getByName(host) method which
behaves differently in the case of iterative calls.
Here is a sample app that demonstrate the problem. The test class just
calls InetAddress.getByName(host).getHostName() twice and compare results.
===== test.java =====
import java.io.*;
import java.net.*;
public class test {
public static void main( String[] args ) throws Exception {
PrintStream ref = System.out;
PrintStream log = System.out;
boolean passed = true;
String host = "127.0.0.1";
ref.println("Testing InetAddress.getByName(host).getHostName with: host="+host);
for (int i = 0; i < 1000; i++ ) {
/*
The original JCK test calls "new InetSocketAddress", then InetSocketAddress.getAddress,
and it's own function resolveHost(String) that calls InetAddress.getByName(String), and compares results.
Since InetSocketAddress' ctor (String, int) just calls InetAddress.getByName(String), I've replaced such
code with double call to InetAddress.getByName(host).
// JCK test's source
InetSocketAddress addr = new InetSocketAddress(host, port);
InetAddress resolved = resolveHost(host);
InetAddress returnedAddress = addr.getAddress();
String returnedHost = addr.getHostName();
String expectedHost = host;
int returnedPort = addr.getPort();
// end of JCK test's source
*/
String returnedHost = InetAddress.getByName(host).getHostName();
String expectedHost = InetAddress.getByName(host).getHostName();
boolean check = true;
if( !expectedHost.equals(returnedHost) ) {
passed = false;
check = false;
}
if( (!check || i==0) ) {
ref.println( i==0 && check ? "Normal values are: " : "Test FAILED at step#"+i+" :");
ref.println("getHostName() returns: " + returnedHost);
ref.println(" expected: " + expectedHost);
ref.println("----------------------------------------------");
}
}
ref.println(passed?"passed":"failed");
};
};
===== end test.java =====
Here is test output (java -showversion test):
===== test log =====
ava version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, mixed mode)
Testing InetAddress.getByName(host).getHostName with: host=127.0.0.1
Normal values are:
getHostName() returns: localhost.nbsp.nsk.su
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#87 :
getHostName() returns: 127.0.0.1
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#91 :
getHostName() returns: localhost.nbsp.nsk.su
expected: 127.0.0.1
----------------------------------------------
Test FAILED at step#117 :
getHostName() returns: 127.0.0.1
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#312 :
getHostName() returns: 127.0.0.1
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#337 :
getHostName() returns: localhost.nbsp.nsk.su
expected: 127.0.0.1
----------------------------------------------
Test FAILED at step#568 :
getHostName() returns: 127.0.0.1
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#593 :
getHostName() returns: localhost.nbsp.nsk.su
expected: 127.0.0.1
----------------------------------------------
Test FAILED at step#824 :
getHostName() returns: 127.0.0.1
expected: localhost.nbsp.nsk.su
----------------------------------------------
Test FAILED at step#849 :
getHostName() returns: localhost.nbsp.nsk.su
expected: 127.0.0.1
----------------------------------------------
failed
===== end test log =====
Test source location:
=====================
/net/jdk/export/disk8/local.java/jck1.4/JCK-runtime-14/tests/api/java_net/InetSocketAddress/CtorTests.java
jtr file location:
==================
/net/jtgb4u4c.eng/export/sail15/results/hopper/b10/jck14/win32/win98_client_comp_linux-17/workDir/api/java_net/InetSocketAddress/index_Ctor.jtr
How to reproduce:
=================
Run the following script on Windows 98 machine. (You may need to change JCK and JDK variables).
The script below creates necessary .JTE and .JTP files and then run the test using JavaTest in the
batch mode. After running test in the batch mode, the script will run the test without harness.
The first step (running the test in batch mode) is necessary to show the failure
since the bug is reproducible only when running with JavaTest harness (at least on the test Win98 machine)
and is not reproducible using the only JCK test that is demonstrated with the second step.
===== test.sh =====
#!/bin/sh
#
# You may need to change JCK or JDK values
#
export JCK=c:/jck1.4/JCK-runtime-14
export JDK=c:/jdk1.4.1/
PRODUCT=c:/jdk1.4.1/
OPTIONS="-client -Xcomp -Xfuture -showversion"
PWD=`pwd`
mkdir -p reportDir
mkdir -p workDir
cat >jck.jtp <<__END_OF_JCK_JTP__
javasoft.sqe.javatest.execution.otherRef=
javasoft.sqe.javatest.selection.keywords.note=false
javasoft.sqe.javatest.selection.keywordOp=expr
javasoft.sqe.javatest.selection.excludeList=
javasoft.sqe.javatest.execution.refSelect=none
javasoft.sqe.javatest.execution.envFiles=$PWD/jck.jte
javasoft.sqe.javatest.selection.prev.passed=false
javasoft.sqe.javatest.results.reportDir=$PWD/reportDir
javasoft.sqe.javatest.results.workDir=$PWD/workDir
javasoft.sqe.javatest.selection.initialFiles=api/java_net/InetSocketAddress/index.html
javasoft.sqe.javatest.selection.status=ignore
javasoft.sqe.javatest.selection.excludeList.note=false
javasoft.sqe.javatest.selection.prev.error=true
javasoft.sqe.javatest.execution.concurrency=1
javasoft.sqe.javatest.selection.prev.failed=true
javasoft.sqe.javatest.execution.timeFactor=1
javasoft.sqe.javatest.selection.status.note=false
javasoft.sqe.javatest.selection.testSuite=$JCK/tests
javasoft.sqe.javatest.selection.keywordsMenu=JmppTest interactive & compiler runtime !interactive |
javasoft.sqe.javatest.selection.prev.check=true
javasoft.sqe.javatest.selection.prev.notRun=true
javasoft.sqe.javatest.execution.environment=OtherJVM
javasoft.sqe.javatest.selection.keywords=!interactive & runtime
__END_OF_JCK_JTP__
cat > jck.jte <<__END_OF_JCK_JTE__
env.OtherJVM.testsuite=com.sun.jck.lib.JCKTestSuite -runtime -dirWalk
env.OtherJVM.context.nativeCodeSupported=true
env.OtherJVM.command.testExecute=javasoft.sqe.javatest.lib.ExecJCKTestOtherJVMCmd DISPLAY=:0 LD_LIBRARY_PATH=$JCK/lib;$JCK/lib/Windows_98.x86 WINDIR=c:/windows SystemRoot=c:/windows
PATH=$JCK/lib;H:\\JAVA\\JDK1.3.1\\WIN32\\BIN;.;C:\\WINDOWS\\SYSTEM;C:\\WINDOWS;C:\\WINDOWS;C:\\WINDOWS\\COMMAND;C:\\MKSNT; $JDK/bin/java -client -Xcomp -Xfuture -cp $JCK/classes;$JCK/javatest.jar -Djava.security.policy=$JCK/lib/jck.policy -Djava.security.auth.policy=$JCK/lib/java.auth.policy
-Djava.security.auth.login.config=$JCK/lib/java.login.config javasoft.sqe.tests.api.java.net.InetSocketAddress.CtorTests
__END_OF_JCK_JTE__
echo "Running JavaTest"
$JDK/bin/java -cp $JCK/classes\;$JCK/javatest.jar com.sun.javatest.tool.Main -batch jck.jtp
echo "Results:"
cat workDir/api/java_net/InetSocketAddress/index_Ctor.jtr | more
echo "Running the test without harness"
$JDK/bin/java $OPTIONS -cp $JCK/classes\;$JCK/javatest.jar javasoft.sqe.tests.api.java.net.InetSocketAddress.CtorTests
===== end test.sh =====
Test output:
============
Running JavaTest
test results: failed: 1
Report written to H:\users\sundr\bugs\b10\InetAddr\reportDir\report.html
Results written to H:\users\sundr\bugs\b10\InetAddr\workDir
Error: some tests failed or other problems occurred
Results:
[...]
----------ref:(22/775)----------
InetSocketAddress(String, int) fails with:
127.0.0.1 and 65535
getAddress() returns: localhost.nbsp.nsk.su/127.0.0.1
expected: 127.0.0.1/127.0.0.1
getHostName() returns: localhost.nbsp.nsk.su
expected: 127.0.0.1
getPort() returns: 65535
expected: 65535
isUnresolved() returns: false
expected: false
----------------------------------------------
[...]
----------log:(10/447)----------
[...]
InetSocketAddress0008: Failed. fails with host and port
[...]
STATUS:Failed.tests: 9; passed: 8; failed: 1; first test case failure: InetSocketAddress0008
result: Failed. tests: 9; passed: 8; failed: 1; first test case failure: InetSocketAddress0008
test result: Failed. tests: 9; passed: 8; failed: 1; first test case failure: InetSocketAddress0008
[...]
Running the test without harness
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b10)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b10, compiled mode)
InetSocketAddress0001: Passed. OKAY
InetSocketAddress0002: Passed. OKAY
InetSocketAddress0003: Passed. OKAY
InetSocketAddress0004: Passed. OKAY
InetSocketAddress0005: Passed. OKAY
InetSocketAddress0006: Passed. OKAY
InetSocketAddress0007: Passed. OKAY
InetSocketAddress0008: Passed. OKAY
InetSocketAddress2001: Passed. OKAY
STATUS:Passed.tests: 9; passed: 9
Specific Machine Info:
======================
Hostname: linux-17
Os: Windows 98
======================================================================