Reviewer needed: regression test fix in IcedTea7-jdk
Dr Andrew John Hughes
ahughes at redhat.com
Wed Aug 10 08:16:41 PDT 2011
On 15:26 Wed 10 Aug , Pavel Tisnovsky wrote:
> Greetings,
>
> I'd like to fix regression test
> "openjdk/jdk/test/java/nio/MappedByteBuffer/Basic.java" in IcedTea7 JDK.
> This test should delete all its temporary files, but the method
> File.deleteOnExit() does not work properly if such test is called from
> JTreg tool in sameVM mode (the same test was fixed in IcedTea6).
>
> Here's ChangeLog entry for IcedTea7 repo:
>
> 2011-08-10 Pavel Tisnovsky <ptisnovs at redhat.com>
>
>
>
> Make sure that the regression test
>
> openjdk/jdk/test/java/nio/MappedByteBuffer/Basic.java
>
> deletes all its work files.
>
> * Makefile.am:
>
> (JDK_CHANGESET): Updated.
>
> (JDK_SHA256SUM): Likewise.
>
>
> Can anybody please review this fix?
>
> Thank you in advance,
> Pavel
The patch for the forest is fine.
Do NOT update IcedTea7 to a new changeset at this time.
I have stuff I'm working on and I don't want IcedTea7 pulling it yet.
> diff -r 4da6bd3bb35e test/java/nio/MappedByteBuffer/Basic.java
> --- a/test/java/nio/MappedByteBuffer/Basic.java Thu Aug 04 05:09:19 2011 +0100
> +++ b/test/java/nio/MappedByteBuffer/Basic.java Wed Aug 10 15:11:59 2011 +0200
> @@ -35,50 +35,61 @@
> byte[] srcData = new byte[20];
> for (int i=0; i<20; i++)
> srcData[i] = 3;
> - File blah = File.createTempFile("blah", null);
> - blah.deleteOnExit();
> - FileOutputStream fos = new FileOutputStream(blah);
> - FileChannel fc = fos.getChannel();
> - fc.write(ByteBuffer.wrap(srcData));
> - fc.close();
> - fos.close();
> + File blah = null;
> + try {
> + blah = File.createTempFile("blah", null);
> + blah.deleteOnExit();
> + FileOutputStream fos = new FileOutputStream(blah);
> + FileChannel fc = fos.getChannel();
> + fc.write(ByteBuffer.wrap(srcData));
> + fc.close();
> + fos.close();
>
> - FileInputStream fis = new FileInputStream(blah);
> - fc = fis.getChannel();
> - MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
> - mbb.load();
> - mbb.isLoaded();
> - mbb.force();
> - if (!mbb.isReadOnly())
> - throw new RuntimeException("Incorrect isReadOnly");
> + FileInputStream fis = new FileInputStream(blah);
> + fc = fis.getChannel();
> + MappedByteBuffer mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
> + mbb.load();
> + mbb.isLoaded();
> + mbb.force();
> + if (!mbb.isReadOnly()) {
> + throw new RuntimeException("Incorrect isReadOnly");
> + }
>
> - // repeat with unaligned position in file
> - mbb = fc.map(FileChannel.MapMode.READ_ONLY, 1, 10);
> - mbb.load();
> - mbb.isLoaded();
> - mbb.force();
> - fc.close();
> - fis.close();
> + // repeat with unaligned position in file
> + mbb = fc.map(FileChannel.MapMode.READ_ONLY, 1, 10);
> + mbb.load();
> + mbb.isLoaded();
> + mbb.force();
> + fc.close();
> + fis.close();
>
> - RandomAccessFile raf = new RandomAccessFile(blah, "r");
> - fc = raf.getChannel();
> - mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
> - if (!mbb.isReadOnly())
> - throw new RuntimeException("Incorrect isReadOnly");
> - fc.close();
> - raf.close();
> + RandomAccessFile raf = new RandomAccessFile(blah, "r");
> + fc = raf.getChannel();
> + mbb = fc.map(FileChannel.MapMode.READ_ONLY, 0, 10);
> + if (!mbb.isReadOnly()) {
> + throw new RuntimeException("Incorrect isReadOnly");
> + }
> + fc.close();
> + raf.close();
>
> - raf = new RandomAccessFile(blah, "rw");
> - fc = raf.getChannel();
> - mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, 10);
> - if (mbb.isReadOnly())
> - throw new RuntimeException("Incorrect isReadOnly");
> - fc.close();
> - raf.close();
> + raf = new RandomAccessFile(blah, "rw");
> + fc = raf.getChannel();
> + mbb = fc.map(FileChannel.MapMode.READ_WRITE, 0, 10);
> + if (mbb.isReadOnly()) {
> + throw new RuntimeException("Incorrect isReadOnly");
> + }
> + fc.close();
> + raf.close();
>
> - // clean-up
> - mbb = null;
> - System.gc();
> - Thread.sleep(500);
> + // clean-up
> + mbb = null;
> + System.gc();
> + Thread.sleep(500);
> + }
> + finally {
> + if (blah != null) {
> + blah.delete();
> + }
> + }
> }
> }
--
Andrew :)
Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)
Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org
PGP Key: F5862A37 (https://keys.indymedia.org/)
Fingerprint = EA30 D855 D50F 90CD F54D 0698 0713 C3ED F586 2A37
More information about the distro-pkg-dev
mailing list