private static List<RecordBatch> batches(Records buffer) {
        return TestUtils.toList(buffer.batches());
    }
Test the new FileRecords with pre allocate as true and file has been clearly shut down, the file will be truncate to end of valid data.
clients/src/test/java/org/apache/kafka/common/record/FileRecordsTest.java