From 7a07a41cbb4c48db19c49bda99479cfdec7d3a0d Mon Sep 17 00:00:00 2001 From: Dean Michael Berris Date: Fri, 31 Aug 2018 10:03:52 +0000 Subject: [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 --- llvm/unittests/XRay/FDRTraceWriterTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/unittests/XRay/FDRTraceWriterTest.cpp') diff --git a/llvm/unittests/XRay/FDRTraceWriterTest.cpp b/llvm/unittests/XRay/FDRTraceWriterTest.cpp index 9d7da50f0ab..97a011977b1 100644 --- a/llvm/unittests/XRay/FDRTraceWriterTest.cpp +++ b/llvm/unittests/XRay/FDRTraceWriterTest.cpp @@ -135,6 +135,11 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) { std::memcpy(H.FreeFormData, reinterpret_cast(&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(1) .add(1, 1) @@ -150,6 +155,10 @@ TEST(FDRTraceWriterTest, WriteToStringBufferVersion1) { 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); -- cgit v1.2.3