@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"));
    // Do nothing. Expected exception.
  }
}