[XRay] Attempt to fix failure on Windows
Original version of the code relied on implementation-defined order of bitfields.
Follow-up on D51210.
llvm-svn: 341194
diff --git a/llvm/unittests/XRay/FDRTraceWriterTest.cpp b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
index 9d7da50..97a0119 100644
--- a/llvm/unittests/XRay/FDRTraceWriterTest.cpp
+++ b/llvm/unittests/XRay/FDRTraceWriterTest.cpp
@@ -135,6 +135,11 @@
std::memcpy(H.FreeFormData, reinterpret_cast<const char *>(&BufferSize),
sizeof(BufferSize));
FDRTraceWriter Writer(OS, H);
+ OS.flush();
+
+ // Ensure that at this point the Data buffer has the file header serialized
+ // size.
+ ASSERT_THAT(Data.size(), Eq(32u));
auto L = LogBuilder()
.add<NewBufferRecord>(1)
.add<WallclockRecord>(1, 1)
@@ -150,6 +155,10 @@
OS.write_zeros(4016);
OS.flush();
+ // For version 1 of the log, we need the whole buffer to be the size of the
+ // file header plus 32.
+ ASSERT_THAT(Data.size(), Eq(BufferSize + 32));
+
// Then from here we load the Trace file.
DataExtractor DE(Data, true, 8);
auto TraceOrErr = loadTrace(DE, true);