Unverified Commit c0f54e5d authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: bump trace format header to TRACEv1 (#99781)

## Summary

Bumps the trace file header from `TRACEv0` to `TRACEv1`, because the
stack below changed the row format incompatibly. Readers only accept the
current version and fail with a clear error on anything else. No v0
support is kept.

- `TRACE_HEADER`, `TRACE_HEADER_PREFIX` and `check_trace_header` live in
`turbopack-trace-utils` and are shared by the writer, the trace server
and `turbo-trace-size`.
- Trace server: format detection is now a small tested function. A
`TRACEv*` file with another version fails with `Unsupported trace file
version: expected TRACEv1, found TRACEv0`. That includes a file with
only the 7-byte header. The fallback that read header-less files as
Turbopack traces is gone, so unknown formats fail with an error. Next.js
JSON traces and heaptrack files are still detected. Empty or
partial-prefix files still wait for more data, because the server
follows traces while they're written.
- `turbo-trace-size` fails on missing or unsupported headers.
- `next internal upload-trace` checks for `TRACEv1` and reports an
unsupported version separately from a non-trace file.
- `contributing/turbopack/tracing.md` documents the format and
versioning.

Stack (on top of #99765):

1. #99777: `no-memory` flag
2. #99778: Merge allocation counters into Enter/Exit rows
3. #99779: Delta-encode allocation counters, skip unchanged ones
4. #99780: Omit Exit+Enter pairs with (almost) no gap
5. #99808: zstd flags
6. #99809: Delta-encoded timestamps
7. #99781: **This PR**: bump the trace header to `TRACEv1`
8. #99810: `upload-trace` accepts compressed traces

## Measurements (whole stack)

`next build` of `bench/heavy-npm-deps`, release native binding built
from source:

| | `1` raw | `1,zstd` | `turbo-tasks,zstd` |
| --- | --- | --- | --- |
| before (#99765) | 68.2 MiB | 21.4 MiB (zstd -3 offline) | |
| after #99780 | 22.8 MiB | 5.9 MiB | 26.8 MiB |
| after this stack | **20.1 MiB** | **4.5 MiB** | **21.1 MiB** |

The `before` zstd number comes from compressing the raw trace offline;
the writer couldn't write zstd before this stack.

## Verification

- **Tests:** `check_trace_header`, server format detection (old,
unknown, partial and header-only files), and `turbo-trace-size`
rejecting missing or old headers.
- **Captures:** traces from a locally built release binding (`1`,
`1,zstd`, `turbo-tasks,zstd`) start with `TRACEv1`, and
`turbo-trace-size` decodes them fully.
  - The trace server loads them completely: 39,481 and 817,619 spans.
  - Both tools reject a `TRACEv0` file with the error above.

<!-- NEXT_JS_LLM -->


<!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 -->
Co-authored-by: 's avatarvercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com>
Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 3cdbd0f2
...@@ -92,5 +92,10 @@ To keep trace files small, an `Exit` of a span that is followed by an `Enter` of ...@@ -92,5 +92,10 @@ To keep trace files small, an `Exit` of a span that is followed by an `Enter` of
Timestamps are stored as the (signed) difference to the previous timestamp in the trace file, which needs fewer bytes than absolute timestamps and compresses better. The trace is written in chunks per thread, and in every chunk a `TimestampBase` row with an absolute timestamp comes before the first row with a timestamp, so every chunk can be decoded on its own. Timestamps are stored as the (signed) difference to the previous timestamp in the trace file, which needs fewer bytes than absolute timestamps and compresses better. The trace is written in chunks per thread, and in every chunk a `TimestampBase` row with an absolute timestamp comes before the first row with a timestamp, so every chunk can be decoded on its own.
### Trace format
A trace file starts with a `TRACEv<version>` header, followed by [postcard] serialized `TraceRow`s (see `turbopack-trace-utils`). The version is bumped on every incompatible change of the format. The trace server and `turbo-trace-size` only read the current version and fail with an error for any other version, so a trace has to be opened with tools built from the same version that captured it.
[postcard]: https://docs.rs/postcard
[turbo-trace-viewer]: https://turbo-trace-viewer.vercel.app/ [turbo-trace-viewer]: https://turbo-trace-viewer.vercel.app/
[youtube-tutorial]: https://www.youtube.com/watch?v=PGO2szAye7A [youtube-tutorial]: https://www.youtube.com/watch?v=PGO2szAye7A
...@@ -6,8 +6,10 @@ const UPLOAD_TRACE_URL = 'https://nextjs.org/api/upload-trace' ...@@ -6,8 +6,10 @@ const UPLOAD_TRACE_URL = 'https://nextjs.org/api/upload-trace'
// V8 CPU profiles are JSON objects starting with {"nodes": // V8 CPU profiles are JSON objects starting with {"nodes":
const CPUPROFILE_HEADER = Buffer.from('{"nodes":') const CPUPROFILE_HEADER = Buffer.from('{"nodes":')
// Turbopack trace files start with this magic header (written by trace_writer.rs) // Turbopack trace files start with this magic header, including the trace format
const TURBOPACK_TRACE_HEADER = Buffer.from('TRACEv0') // version (written by trace_writer.rs, `TRACE_HEADER` in turbopack-trace-utils)
const TURBOPACK_TRACE_HEADER = Buffer.from('TRACEv1')
const TURBOPACK_TRACE_HEADER_PREFIX = Buffer.from('TRACEv')
const PROGRESS_CHUNK_SIZE = 64 * 1024 // 64 KB const PROGRESS_CHUNK_SIZE = 64 * 1024 // 64 KB
...@@ -66,17 +68,24 @@ function validateCpuProfile(header: Buffer, file: string): void { ...@@ -66,17 +68,24 @@ function validateCpuProfile(header: Buffer, file: string): void {
} }
function validateTurbopackTrace(header: Buffer, file: string): void { function validateTurbopackTrace(header: Buffer, file: string): void {
const actual = header.subarray(0, TURBOPACK_TRACE_HEADER.length)
if (actual.equals(TURBOPACK_TRACE_HEADER)) {
return
}
if ( if (
header.length < TURBOPACK_TRACE_HEADER.length || actual
!header .subarray(0, TURBOPACK_TRACE_HEADER_PREFIX.length)
.subarray(0, TURBOPACK_TRACE_HEADER.length) .equals(TURBOPACK_TRACE_HEADER_PREFIX)
.equals(TURBOPACK_TRACE_HEADER)
) { ) {
console.error( console.error(
`Error: ${file} does not appear to be a valid Turbopack trace (missing TRACEv0 header).` `Error: ${file} has an unsupported Turbopack trace version (expected ${TURBOPACK_TRACE_HEADER}, found ${actual}). Capture the trace again with this version of Next.js.`
)
} else {
console.error(
`Error: ${file} does not appear to be a valid Turbopack trace (missing ${TURBOPACK_TRACE_HEADER} header).`
) )
process.exit(1)
} }
process.exit(1)
} }
export async function uploadTraceToBlob( export async function uploadTraceToBlob(
......
...@@ -16,6 +16,7 @@ use std::{ ...@@ -16,6 +16,7 @@ use std::{
use anyhow::Result; use anyhow::Result;
use flate2::bufread::GzDecoder; use flate2::bufread::GzDecoder;
use turbopack_trace_utils::tracing::{TRACE_HEADER, TRACE_HEADER_PREFIX, check_trace_header};
use crate::{ use crate::{
reader::{heaptrack::HeaptrackFormat, nextjs::NextJsFormat, turbopack::TurbopackFormat}, reader::{heaptrack::HeaptrackFormat, nextjs::NextJsFormat, turbopack::TurbopackFormat},
...@@ -29,6 +30,42 @@ const BATCH_SIZE: usize = 1024 * 1024; ...@@ -29,6 +30,42 @@ const BATCH_SIZE: usize = 1024 * 1024;
const MIN_INITIAL_REPORT_SIZE: u64 = 100 * 1024 * 1024; const MIN_INITIAL_REPORT_SIZE: u64 = 100 * 1024 * 1024;
#[derive(Debug, PartialEq, Eq)]
enum FormatKind {
Turbopack,
NextJs,
Heaptrack,
}
const NEXT_JS_PREFIX: &[u8] = b"[{\"name\"";
const HEAPTRACK_PREFIX: &[u8] = b"v ";
/// Detects the format of a trace file from its (decompressed) start. Returns `None` when more
/// data is needed to decide.
fn detect_format(buffer: &[u8]) -> Result<Option<FormatKind>> {
let could_be = |prefix: &[u8]| {
let len = buffer.len().min(prefix.len());
buffer[..len] == prefix[..len]
};
if could_be(TRACE_HEADER_PREFIX) {
if buffer.len() < TRACE_HEADER.len() {
return Ok(None);
}
check_trace_header(buffer)?;
return Ok(Some(FormatKind::Turbopack));
}
if could_be(NEXT_JS_PREFIX) {
return Ok((buffer.len() >= NEXT_JS_PREFIX.len()).then_some(FormatKind::NextJs));
}
if could_be(HEAPTRACK_PREFIX) {
return Ok((buffer.len() >= HEAPTRACK_PREFIX.len()).then_some(FormatKind::Heaptrack));
}
anyhow::bail!(
"Unknown trace file format (expected a {} header, a Next.js trace or a heaptrack file)",
String::from_utf8_lossy(TRACE_HEADER)
);
}
pub(crate) trait TraceFormat { pub(crate) trait TraceFormat {
type Reused: Default; type Reused: Default;
/// Create the initial reused buffer. Override to pre-allocate capacity. /// Create the initial reused buffer. Override to pre-allocate capacity.
...@@ -247,24 +284,29 @@ impl TraceReader { ...@@ -247,24 +284,29 @@ impl TraceReader {
index = 0; index = 0;
} }
buffer.extend_from_slice(&chunk[..bytes_read]); buffer.extend_from_slice(&chunk[..bytes_read]);
if format.is_none() && buffer.len() >= 8 { if format.is_none() {
let erased_format = if buffer.starts_with(b"TRACEv0") { let kind = match detect_format(&buffer) {
index = 7; Ok(Some(kind)) => kind,
ErasedTraceFormat(Box::new(TurbopackFormat::new( // Not enough data yet
self.store.clone(), Ok(None) => continue,
))) Err(err) => {
} else if buffer.starts_with(b"[{\"name\"") { println!("Trace file error: {err}");
ErasedTraceFormat(Box::new(NextJsFormat::new(self.store.clone()))) return true;
} else if buffer.starts_with(b"v ") { }
ErasedTraceFormat(Box::new(HeaptrackFormat::new( };
self.store.clone(), let erased_format = match kind {
))) FormatKind::Turbopack => {
} else { index = TRACE_HEADER.len();
// Fallback to the format without magic bytes ErasedTraceFormat(Box::new(TurbopackFormat::new(
// TODO Remove this after a while and show an error instead self.store.clone(),
ErasedTraceFormat(Box::new(TurbopackFormat::new( )))
self.store.clone(), }
))) FormatKind::NextJs => ErasedTraceFormat(Box::new(
NextJsFormat::new(self.store.clone()),
)),
FormatKind::Heaptrack => ErasedTraceFormat(Box::new(
HeaptrackFormat::new(self.store.clone()),
)),
}; };
let reuse = erased_format.create_reused(); let reuse = erased_format.create_reused();
format = Some((erased_format, reuse)); format = Some((erased_format, reuse));
...@@ -468,7 +510,7 @@ mod tests { ...@@ -468,7 +510,7 @@ mod tests {
} }
fn trace(spans: u64) -> Vec<u8> { fn trace(spans: u64) -> Vec<u8> {
let mut bytes = b"TRACEv0".to_vec(); let mut bytes = TRACE_HEADER.to_vec();
bytes.extend(span_rows(1, spans)); bytes.extend(span_rows(1, spans));
bytes bytes
} }
...@@ -598,4 +640,46 @@ mod tests { ...@@ -598,4 +640,46 @@ mod tests {
); );
} }
} }
#[test]
fn detects_trace_formats() {
assert_eq!(detect_format(b"").unwrap(), None);
assert_eq!(detect_format(b"TRACE").unwrap(), None);
assert_eq!(
detect_format(b"TRACEv1").unwrap(),
Some(FormatKind::Turbopack)
);
assert_eq!(
detect_format(b"TRACEv1\x00\x01").unwrap(),
Some(FormatKind::Turbopack)
);
assert_eq!(detect_format(b"[{\"na").unwrap(), None);
assert_eq!(
detect_format(b"[{\"name\":").unwrap(),
Some(FormatKind::NextJs)
);
assert_eq!(detect_format(b"v").unwrap(), None);
assert_eq!(
detect_format(b"v 1.0").unwrap(),
Some(FormatKind::Heaptrack)
);
}
#[test]
fn rejects_old_and_unknown_formats() {
// Also a file that only consists of the old header
for data in [&b"TRACEv0"[..], b"TRACEv0\x00\x01"] {
assert_eq!(
detect_format(data).unwrap_err().to_string(),
"Unsupported trace file version: expected TRACEv1, found TRACEv0"
);
}
// Old files without any header
assert!(
detect_format(b"\x00\x01\x02")
.unwrap_err()
.to_string()
.starts_with("Unknown trace file format")
);
}
} }
//! Size analysis for Turbopack trace files (`trace-turbopack.bin`). //! Size analysis for Turbopack trace files (`trace-turbopack.bin`).
//! //!
//! A trace file is a `TRACEv0` magic header followed by a stream of //! A trace file is a [`TRACE_HEADER`] (magic bytes with the format version)
//! followed by a stream of
//! [`postcard`]-serialized [`TraceRow`]s, optionally gzip or zstd compressed. //! [`postcard`]-serialized [`TraceRow`]s, optionally gzip or zstd compressed.
//! [`TraceSizeAnalyzer`] decodes that stream and attributes the bytes of every //! [`TraceSizeAnalyzer`] decodes that stream and attributes the bytes of every
//! row to its row type and span, and the bytes of attributes and strings to //! row to its row type and span, and the bytes of attributes and strings to
...@@ -20,10 +21,9 @@ use std::{ ...@@ -20,10 +21,9 @@ use std::{
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use flate2::bufread::MultiGzDecoder; use flate2::bufread::MultiGzDecoder;
use rustc_hash::{FxHashMap, FxHashSet}; use rustc_hash::{FxHashMap, FxHashSet};
use turbopack_trace_utils::tracing::{Allocations, TimestampDecoder, TraceRow, TraceValue}; use turbopack_trace_utils::tracing::{
Allocations, TRACE_HEADER, TimestampDecoder, TraceRow, TraceValue, check_trace_header,
/// The magic bytes at the start of every (uncompressed) trace file. };
pub const TRACE_HEADER: &[u8] = b"TRACEv0";
const READ_CHUNK_SIZE: usize = 16 * 1024 * 1024; const READ_CHUNK_SIZE: usize = 16 * 1024 * 1024;
...@@ -213,7 +213,7 @@ pub struct TraceSizeAnalyzer { ...@@ -213,7 +213,7 @@ pub struct TraceSizeAnalyzer {
pub compression: Compression, pub compression: Compression,
/// Size of the decompressed trace stream, including the header. /// Size of the decompressed trace stream, including the header.
pub uncompressed_size: u64, pub uncompressed_size: u64,
/// Bytes of the `TRACEv0` header. /// Bytes of the [`TRACE_HEADER`].
pub header_bytes: u64, pub header_bytes: u64,
/// Bytes at the end of the stream that don't form a complete row (e.g. /// Bytes at the end of the stream that don't form a complete row (e.g.
/// when the process was killed while writing the trace). /// when the process was killed while writing the trace).
...@@ -291,11 +291,9 @@ impl TraceSizeAnalyzer { ...@@ -291,11 +291,9 @@ impl TraceSizeAnalyzer {
if buffer.len() < TRACE_HEADER.len() && !eof { if buffer.len() < TRACE_HEADER.len() && !eof {
continue; continue;
} }
// Old trace files don't have a header check_trace_header(&buffer)?;
if buffer.starts_with(TRACE_HEADER) { start = TRACE_HEADER.len();
start = TRACE_HEADER.len(); self.header_bytes = TRACE_HEADER.len() as u64;
self.header_bytes = TRACE_HEADER.len() as u64;
}
header_checked = true; header_checked = true;
} }
loop { loop {
...@@ -1222,15 +1220,24 @@ mod tests { ...@@ -1222,15 +1220,24 @@ mod tests {
} }
#[test] #[test]
fn reads_files_without_header() { fn rejects_files_with_missing_or_unsupported_header() {
let (data, _) = encode(&sample_rows()); let (data, _) = encode(&sample_rows());
let mut analyzer = TraceSizeAnalyzer::new(); let err = TraceSizeAnalyzer::new()
analyzer
.analyze_reader(&data[TRACE_HEADER.len()..]) .analyze_reader(&data[TRACE_HEADER.len()..])
.unwrap(); .unwrap_err();
assert_eq!(analyzer.header_bytes, 0); assert!(err.to_string().contains("missing TRACEv1 header"), "{err}");
assert_eq!(analyzer.row_count(), sample_rows().len() as u64);
assert_eq!(analyzer.row_bytes(), analyzer.uncompressed_size); let mut old = b"TRACEv0".to_vec();
old.extend_from_slice(&data[TRACE_HEADER.len()..]);
let err = TraceSizeAnalyzer::new()
.analyze_reader(&old[..])
.unwrap_err();
assert_eq!(
err.to_string(),
"Unsupported trace file version: expected TRACEv1, found TRACEv0"
);
assert!(TraceSizeAnalyzer::new().analyze_reader(&b""[..]).is_err());
} }
#[test] #[test]
......
...@@ -561,7 +561,7 @@ pub(crate) mod tests { ...@@ -561,7 +561,7 @@ pub(crate) mod tests {
RawTraceLayerOptions, RawTraceLayerOptions,
}, },
trace_writer::TraceWriter, trace_writer::TraceWriter,
tracing::{Allocations, TimestampDecoder, TraceRow}, tracing::{Allocations, TRACE_HEADER, TimestampDecoder, TraceRow},
}; };
thread_local! { thread_local! {
...@@ -662,7 +662,7 @@ pub(crate) mod tests { ...@@ -662,7 +662,7 @@ pub(crate) mod tests {
/// Decodes all rows of a trace file including [`TraceRow::TimestampBase`] rows, skipping the /// Decodes all rows of a trace file including [`TraceRow::TimestampBase`] rows, skipping the
/// header. Timestamps are resolved to absolute values. /// header. Timestamps are resolved to absolute values.
pub(crate) fn decode_all(data: &[u8]) -> Vec<TraceRow<'_, u64>> { pub(crate) fn decode_all(data: &[u8]) -> Vec<TraceRow<'_, u64>> {
let header = b"TRACEv0"; let header = TRACE_HEADER;
assert!(data.starts_with(header), "missing trace header"); assert!(data.starts_with(header), "missing trace header");
let mut remaining = &data[header.len()..]; let mut remaining = &data[header.len()..];
let mut decoder = TimestampDecoder::default(); let mut decoder = TimestampDecoder::default();
......
...@@ -5,7 +5,7 @@ use crossbeam_utils::CachePadded; ...@@ -5,7 +5,7 @@ use crossbeam_utils::CachePadded;
use parking_lot::{Mutex, MutexGuard}; use parking_lot::{Mutex, MutexGuard};
use thread_local::ThreadLocal; use thread_local::ThreadLocal;
use crate::tracing::{DeltaEncodedTimestamp, TimestampEncoder, TraceRow}; use crate::tracing::{DeltaEncodedTimestamp, TRACE_HEADER, TimestampEncoder, TraceRow};
type ThreadLocalState = CachePadded<Mutex<Option<TraceInfoBuffer>>>; type ThreadLocalState = CachePadded<Mutex<Option<TraceInfoBuffer>>>;
...@@ -112,7 +112,7 @@ impl TraceWriter { ...@@ -112,7 +112,7 @@ impl TraceWriter {
} }
let handle: std::thread::JoinHandle<()> = std::thread::spawn(move || { let handle: std::thread::JoinHandle<()> = std::thread::spawn(move || {
let _ = writer.write(b"TRACEv0"); let _ = writer.write(TRACE_HEADER);
let mut buf = Vec::with_capacity(WRITE_BUFFER_SIZE); let mut buf = Vec::with_capacity(WRITE_BUFFER_SIZE);
let mut stolen_buffers = Vec::new(); let mut stolen_buffers = Vec::new();
let mut should_exit = false; let mut should_exit = false;
...@@ -349,7 +349,7 @@ mod tests { ...@@ -349,7 +349,7 @@ mod tests {
use crate::{ use crate::{
trace_writer::{THREAD_LOCAL_INITIAL_BUFFER_SIZE, TraceWriter, WriteGuard}, trace_writer::{THREAD_LOCAL_INITIAL_BUFFER_SIZE, TraceWriter, WriteGuard},
tracing::{TimestampDecoder, TraceRow}, tracing::{TRACE_HEADER, TimestampDecoder, TraceRow},
}; };
#[derive(Clone, Default)] #[derive(Clone, Default)]
...@@ -373,7 +373,7 @@ mod tests { ...@@ -373,7 +373,7 @@ mod tests {
drop(writer); drop(writer);
drop(guard); drop(guard);
let data = Arc::try_unwrap(buffer.0).unwrap().into_inner().unwrap(); let data = Arc::try_unwrap(buffer.0).unwrap().into_inner().unwrap();
data.strip_prefix(b"TRACEv0").unwrap().to_vec() data.strip_prefix(TRACE_HEADER).unwrap().to_vec()
} }
#[test] #[test]
......
...@@ -14,6 +14,31 @@ use serde::{Deserialize, Serialize}; ...@@ -14,6 +14,31 @@ use serde::{Deserialize, Serialize};
#[serde(transparent)] #[serde(transparent)]
pub struct DeltaEncodedTimestamp(pub i64); pub struct DeltaEncodedTimestamp(pub i64);
/// The magic bytes at the start of every trace file. They include the version of the trace
/// format, which must be bumped on every incompatible change to [`TraceRow`]. The header is
/// followed by a stream of [`postcard`] serialized [`TraceRow`]s.
pub const TRACE_HEADER: &[u8] = b"TRACEv1";
/// The part of [`TRACE_HEADER`] that is the same for all versions.
pub const TRACE_HEADER_PREFIX: &[u8] = b"TRACEv";
/// Checks that `data` starts with the [`TRACE_HEADER`] of the supported trace format version.
/// `data` must contain at least `TRACE_HEADER.len()` bytes, unless the file is shorter.
pub fn check_trace_header(data: &[u8]) -> anyhow::Result<()> {
if data.starts_with(TRACE_HEADER) {
return Ok(());
}
let expected = String::from_utf8_lossy(TRACE_HEADER);
if data.starts_with(TRACE_HEADER_PREFIX) {
let found = &data[..data.len().min(TRACE_HEADER.len())];
anyhow::bail!(
"Unsupported trace file version: expected {expected}, found {}",
String::from_utf8_lossy(found)
);
}
anyhow::bail!("Not a trace file: missing {expected} header");
}
/// A raw trace line. /// A raw trace line.
/// ///
/// # Timestamps /// # Timestamps
...@@ -388,6 +413,7 @@ impl TraceValue<'_> { ...@@ -388,6 +413,7 @@ impl TraceValue<'_> {
mod tests { mod tests {
use crate::tracing::{ use crate::tracing::{
DeltaEncodedTimestamp, TimestampDecodeError, TimestampDecoder, TimestampEncoder, TraceRow, DeltaEncodedTimestamp, TimestampDecodeError, TimestampDecoder, TimestampEncoder, TraceRow,
check_trace_header,
}; };
fn end(ts: u64) -> TraceRow<'static, u64> { fn end(ts: u64) -> TraceRow<'static, u64> {
...@@ -575,4 +601,23 @@ mod tests { ...@@ -575,4 +601,23 @@ mod tests {
decoder.decode(base(i64::MAX as u64)).unwrap(); decoder.decode(base(i64::MAX as u64)).unwrap();
assert_eq!(ts_of(&decoder.decode(encoded_end(5)).unwrap()), beyond); assert_eq!(ts_of(&decoder.decode(encoded_end(5)).unwrap()), beyond);
} }
#[test]
fn checks_trace_header() {
assert!(check_trace_header(b"TRACEv1").is_ok());
assert!(check_trace_header(b"TRACEv1\x00\x01").is_ok());
assert_eq!(
check_trace_header(b"TRACEv0\x00").unwrap_err().to_string(),
"Unsupported trace file version: expected TRACEv1, found TRACEv0"
);
assert_eq!(
check_trace_header(b"TRACEv2").unwrap_err().to_string(),
"Unsupported trace file version: expected TRACEv1, found TRACEv2"
);
assert_eq!(
check_trace_header(b"\x00\x01\x02").unwrap_err().to_string(),
"Not a trace file: missing TRACEv1 header"
);
assert!(check_trace_header(b"").is_err());
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment