Program: 15674
Project: 15674
Buggy source:
private void testFileSystem() throws IOException {
  FilePathReorderWrites fs=FilePathReorderWrites.register();
  FilePathReorderWrites.setPartialWrites(false);
  String fileName="String_Node_Str";
  ByteBuffer empty=ByteBuffer.allocate(1024);
  Random r=new Random(1);
  long minSize=Long.MAX_VALUE;
  long maxSize=0;
  int minWritten=Integer.MAX_VALUE;
  int maxWritten=0;
  for (int i=0; i < 100; i++) {
    fs.setPowerOffCountdown(100,i);
    FileUtils.delete(fileName);
    FileChannel fc=FilePath.get(fileName).open("String_Node_Str");
    for (int j=0; j < 20; j++) {
      fc.write(empty,j * 1024);
      empty.flip();
    }
    fs.setPowerOffCountdown(4 + r.nextInt(20),i);
    int lastWritten=0;
    int lastTruncated=0;
    for (int j=20; j >= 0; j--) {
      try {
        byte[] bytes=new byte[1024];
        Arrays.fill(bytes,(byte)j);
        ByteBuffer data=ByteBuffer.wrap(bytes);
        fc.write(data,0);
        lastWritten=j;
      }
 catch (      IOException e) {
        break;
      }
      try {
        fc.truncate(j * 1024);
        lastTruncated=j * 1024;
      }
 catch (      IOException e) {
        break;
      }
    }
    if (lastTruncated <= 0 || lastWritten <= 0) {
      fail();
    }
    fs.setPowerOffCountdown(100,0);
    fc=FilePath.get(fileName).open("String_Node_Str");
    ByteBuffer data=ByteBuffer.allocate(1024);
    fc.read(data,0);
    data.flip();
    int got=data.get();
    long size=fc.size();
    minSize=Math.min(minSize,size);
    maxSize=Math.max(minSize,size);
    minWritten=Math.min(minWritten,got);
    maxWritten=Math.max(maxWritten,got);
  }
  assertTrue(minSize < maxSize);
  assertTrue(minWritten < maxWritten);
  FileUtils.delete(fileName);
}

Fixed version (ground truth):
private void testFileSystem() throws IOException {
  FilePathReorderWrites fs=FilePathReorderWrites.register();
  FilePathReorderWrites.setPartialWrites(false);
  String fileName="String_Node_Str";
  final ByteBuffer empty=ByteBuffer.allocate(1024);
  Random r=new Random(1);
  long minSize=Long.MAX_VALUE;
  long maxSize=0;
  int minWritten=Integer.MAX_VALUE;
  int maxWritten=0;
  for (int i=0; i < 100; i++) {
    fs.setPowerOffCountdown(100,i);
    FileUtils.delete(fileName);
    FileChannel fc=FilePath.get(fileName).open("String_Node_Str");
    for (int j=0; j < 20; j++) {
      fc.write(empty,j * 1024);
      empty.flip();
    }
    fs.setPowerOffCountdown(4 + r.nextInt(20),i);
    int lastWritten=0;
    int lastTruncated=0;
    for (int j=20; j >= 0; j--) {
      try {
        byte[] bytes=new byte[1024];
        Arrays.fill(bytes,(byte)j);
        ByteBuffer data=ByteBuffer.wrap(bytes);
        fc.write(data,0);
        lastWritten=j;
      }
 catch (      IOException e) {
        break;
      }
      try {
        fc.truncate(j * 1024);
        lastTruncated=j * 1024;
      }
 catch (      IOException e) {
        break;
      }
    }
    if (lastTruncated <= 0 || lastWritten <= 0) {
      fail();
    }
    fs.setPowerOffCountdown(100,0);
    fc=FilePath.get(fileName).open("String_Node_Str");
    ByteBuffer data=ByteBuffer.allocate(1024);
    fc.read(data,0);
    data.flip();
    int got=data.get();
    long size=fc.size();
    minSize=Math.min(minSize,size);
    maxSize=Math.max(minSize,size);
    minWritten=Math.min(minWritten,got);
    maxWritten=Math.max(maxWritten,got);
  }
  assertTrue(minSize < maxSize);
  assertTrue(minWritten < maxWritten);
  FileUtils.delete(fileName);
}