SimpleperfTraceParser implements TraceParser { @Override public CpuCapture parse(File trace, long traceId) throws IOException { parseTraceFile(trace); parseSampleData(); return new CpuCapture(this, traceId, Cpu.CpuTraceType.SIMPLEPERF); } SimpleperfTraceParser(); @Override CpuCapture parse(File trace, long traceId); @Override boolean supportsDualClock(); @Override Map<CpuThreadInfo, CaptureNode> getCaptureTrees(); @Override Range getRange(); long getLostSampleCount(); long getSampleCount();  }
@Test public void invalidFileShouldFailDueToMagicNumberMismatch() throws IOException { ByteString traceBytes = traceFileToByteString("simpleperf_malformed.trace"); File trace = FileUtil.createTempFile("cpu_trace", ".trace"); try (FileOutputStream out = new FileOutputStream(trace)) { out.write(traceBytes.toByteArray()); } myParser = new SimpleperfTraceParser(); try { myParser.parse(trace, 0); fail("IllegalStateException should have been thrown due to missing file."); } catch (IllegalStateException e) { assertTrue(e.getMessage().contains("magic number mismatch")); } }