diff --git a/build.xml b/build.xml index 9f23ad7da..e22564690 100644 --- a/build.xml +++ b/build.xml @@ -213,6 +213,10 @@ + + + + diff --git a/core/perl/i2pbench.sh b/core/perl/i2pbench.sh index 464e962d5..ba3cbe76c 100644 --- a/core/perl/i2pbench.sh +++ b/core/perl/i2pbench.sh @@ -1,4 +1,21 @@ #!/usr/bin/perl +# Use the "--gij" parameter to run the tests against libgcj. +# Use the "--sourcedir" parameter if running this from the source tree. + +$runtime = "java"; +$classpath = "../lib/i2p.jar:../lib/jbigi.jar"; + +foreach $argv (@ARGV) { + if ($argv eq "--gij") { + $runtime = "gij"; + print "\n*** Using gij + libgcj ***\n\n"; + } + if ($argv eq "--sourcedir") { + $classpath = "../../build/i2p.jar:../../build/jbigi.jar"; + } +} + +$javacommand = "$runtime -cp $classpath -Dlogger.shutdownDelay=0"; print "\nBenchmark Suite #1: i2p/core/java/test/net/i2p/crypto/*\n\n"; @@ -6,7 +23,7 @@ print "\nBenchmark Suite #1: i2p/core/java/test/net/i2p/crypto/*\n\n"; foreach $testclass (@testclasses) { print "[BENCHMARK] $testclass:\n\n"; - system("java -cp lib/i2p.jar:lib/jbigi.jar net.i2p.crypto.$testclass"); + system("$javacommand net.i2p.crypto.$testclass"); print "\n"; } diff --git a/core/perl/i2ptest.sh b/core/perl/i2ptest.sh index 63cdaf585..a9e565412 100644 --- a/core/perl/i2ptest.sh +++ b/core/perl/i2ptest.sh @@ -1,6 +1,25 @@ #!/usr/bin/perl +# Use the "--gij" parameter to run the tests against libgcj. +# Use the "--sourcedir" parameter if running this from the source tree. # Yeah yeah, a lot of repetitive code here, but it works for now. +#i2p/apps/proxyscript/i2pProxy.pac + +$runtime = "java"; +$classpath = "../lib/i2p.jar:../lib/jbigi.jar"; + +foreach $argv (@ARGV) { + if ($argv eq "--gij") { + $runtime = "gij"; + print "\n*** Using gij + libgcj ***\n\n"; + } + if ($argv eq "--sourcedir") { + $classpath = "../../build/i2p.jar:../../build/jbigi.jar"; + } +} + +$javacommand = "$runtime -cp $classpath -Dlogger.shutdownDelay=0"; + $failed = 0; $passed = 0; $failedtotal = 0; @@ -21,7 +40,7 @@ print "\nTest Suite #1: i2p/core/java/test/net/i2p/data/*Test\n\n"; foreach $testclass (@testclasses) { print "[TEST] $testclass: "; - if(! system("java -cp lib/i2p.jar:lib/jbigi.jar net.i2p.data.TestData test $testclass $testclass.dat > /dev/null 2>test.tmp")) { + if(! system("$javacommand net.i2p.data.TestData test $testclass $testclass.dat > /dev/null 2>test.tmp")) { print "OK\n"; $passed++; } else { @@ -51,7 +70,7 @@ print "\nTest Suite #2: i2p/core/java/test/net/i2p/crypto/*\n\n"; foreach $testclass (@testclasses) { if ($testclass eq "SessionEncryptionTest") { print "[TEST] $testclass: "; - if(! system("java -cp lib/i2p.jar:lib/jbigi.jar net.i2p.crypto.SessionEncryptionTest > /dev/null 2>test.tmp")) { + if(! system("$javacommand net.i2p.crypto.SessionEncryptionTest > /dev/null 2>test.tmp")) { print "OK\n"; $passed++; } else { @@ -65,7 +84,7 @@ foreach $testclass (@testclasses) { } } else { print "[TEST] $testclass:\n\n"; - if(! system("java -cp lib/i2p.jar:lib/jbigi.jar net.i2p.crypto.$testclass")) { + if(! system("$javacommand net.i2p.crypto.$testclass")) { $passed++; } else { $failed++; @@ -90,7 +109,7 @@ print "\nTest Suite #3: Miscellaneous\n\n"; foreach $testclass (@testclasses) { if ($testclass eq "net.i2p.data.UnsignedInteger") { print "[TEST] $testclass:\n\n"; - if(! system("java -cp lib/i2p.jar:lib/jbigi.jar net.i2p.data.UnsignedInteger")) { + if(! system("$javacommand net.i2p.data.UnsignedInteger")) { $passed++; } else { $failed++; @@ -98,7 +117,7 @@ foreach $testclass (@testclasses) { print "\n"; } else { print "[TEST] $testclass: "; - if(! system("java -cp lib/i2p.jar:lib/jbigi.jar $testclass > /dev/null 2>test.tmp")) { + if(! system("$javacommand $testclass > /dev/null 2>test.tmp")) { print "OK\n"; $passed++; } else { diff --git a/history.txt b/history.txt index dcf551e83..6b500988f 100644 --- a/history.txt +++ b/history.txt @@ -1,4 +1,13 @@ -$Id: history.txt,v 1.134 2005/01/26 01:29:19 smeghead Exp $ +$Id: history.txt,v 1.135 2005/01/26 19:21:10 smeghead Exp $ + +2005-01-26 smeghead + * i2pProxy.pac, i2pbench.sh, and i2ptest.sh are now shipped with the dist + packages and installed to $i2pinstalldir/scripts. + * Added command line params to i2ptest.sh and i2pbench.sh: --gij to run them + using gij + libgcj, and --sourcedir to run them from the source tree + instead of the installation directory. + * Fixed unreachable for() statement clause in the KBucketImpl class that was + causing gcj to toss a compilation warning (jrandom++). 2005-01-26 smeghead * Added a couple of scripts, i2ptest.sh and i2pbench.sh, to manage the core diff --git a/installer/resources/postinstall.sh b/installer/resources/postinstall.sh index ee59fb136..2bb32b230 100644 --- a/installer/resources/postinstall.sh +++ b/installer/resources/postinstall.sh @@ -56,6 +56,8 @@ esac cp $wrapperpath/wrapper.jar ./lib/ cp $wrapperpath/i2psvc . chmod 744 ./i2psvc +chmod 744 ./scripts/i2pbench.sh +chmod 744 ./scripts/i2ptest.sh rm -rf ./icons rm -rf ./lib/wrapper rm -f ./lib/*.dll diff --git a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java index 9e13b9a58..31ac09cad 100644 --- a/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java +++ b/router/java/src/net/i2p/router/networkdb/kademlia/KBucketImpl.java @@ -108,32 +108,39 @@ class KBucketImpl implements KBucket { return false; for (int i = 0; i < distance.length; i++) { - if ( (i < upperLimitByte) && (distance[i] != 0x00) ) { - // outright too large - return true; - } else { - int upperVal = 1 << (upperLimitBit % 8); - if (distance[i] > upperVal) { - // still too large, but close + if (i < upperLimitByte) { + if (distance[i] != 0x00) { + // outright too large return true; - } else if (distance[i] == upperVal) { - // ok, it *may* equal the upper limit, - // if the rest of the bytes are 0 - for (int j = i+1; j < distance.length; i++) { - if (distance[j] != 0x00) { - // nope - return true; - } - } - // w00t, the rest is made of 0x00 bytes, so it - // exactly matches the upper limit. kooky, very improbable, - // but possible + } + } else if (i == upperLimitByte) { + if (distance[i] == 0x00) { + // no bits set through the high bit return false; } else { - // no bits set before or at the upper limit, so its - // definitely not too large - return false; + int upperVal = 1 << (upperLimitBit % 8); + if (distance[i] > upperVal) { + // still too large, but close + return true; + } else if (distance[i] == upperVal) { + // ok, it *may* equal the upper limit, + // if the rest of the bytes are 0 + for (int j = i+1; j < distance.length; j++) { + if (distance[j] != 0x00) { + // nope + return true; + } + } + // w00t, the rest is made of 0x00 bytes, so it + // exactly matches the upper limit. kooky, very improbable, + // but possible + return false; + } } + } else if (i > upperLimitByte) { + // no bits set before or at the upper limit, so its + // definitely not too large + return false; } } _log.log(Log.CRIT, "wtf, gravity broke: distance=" + DataHelper.toHexString(distance)