diff --git a/xls/modules/zstd/BUILD b/xls/modules/zstd/BUILD index f26a09d45e..6e09d4f7c1 100644 --- a/xls/modules/zstd/BUILD +++ b/xls/modules/zstd/BUILD @@ -154,7 +154,6 @@ cc_library( ], deps = [ "@com_google_absl//absl/algorithm:container", - "@com_google_absl//absl/status", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/time", @@ -210,7 +209,6 @@ cc_test( ":frame_header_test_dslx", ], shard_count = 50, - tags = ["manual"], deps = [ ":data_generator", "@com_google_absl//absl/container:flat_hash_map", @@ -999,7 +997,6 @@ cc_test( ":zstd_dec_test.ir", ], shard_count = 50, - tags = ["manual"], deps = [ ":data_generator", "@com_google_absl//absl/container:flat_hash_map", diff --git a/xls/modules/zstd/frame_header_test.cc b/xls/modules/zstd/frame_header_test.cc index e78af06577..9a3be2c0f3 100644 --- a/xls/modules/zstd/frame_header_test.cc +++ b/xls/modules/zstd/frame_header_test.cc @@ -57,10 +57,22 @@ enum FrameHeaderStatus : uint8_t { UNSUPPORTED_WINDOW_SIZE }; -struct ZstdFrameHeader { - absl::Span kBuffer; - ZSTD_frameHeader kHeader; - size_t kResult; +class ZstdFrameHeader { + public: + absl::Span buffer() const { + return absl::MakeConstSpan(buffer_); + } + + ZSTD_frameHeader header() const { return header_; } + + size_t result() const { return result_; } + + ZstdFrameHeader(absl::Span buffer, ZSTD_frameHeader h, + size_t r) + : header_(std::move(h)), result_(r) { + std::vector v(buffer.begin(), buffer.end()); + buffer_ = v; + } // Parse a frame header from an arbitrary buffer with the ZSTD library. static absl::StatusOr Parse( absl::Span buffer) { @@ -69,8 +81,13 @@ struct ZstdFrameHeader { ZSTD_frameHeader zstd_fh; size_t result = ZSTD_getFrameHeader_advanced( &zstd_fh, buffer.data(), buffer.size(), ZSTD_f_zstd1_magicless); - return ZstdFrameHeader(buffer, zstd_fh, result); + return ZstdFrameHeader(buffer, std::move(zstd_fh), result); } + + private: + std::vector buffer_; + ZSTD_frameHeader header_; + size_t result_; }; class FrameHeaderTest : public xls::IrTestBase { @@ -113,7 +130,7 @@ class FrameHeaderTest : public xls::IrTestBase { // expected values. void RunAndExpectFrameHeader(const ZstdFrameHeader& zstd_frame_header) { // Extend buffer contents to 128 bits if necessary. - const absl::Span& buffer = zstd_frame_header.kBuffer; + const absl::Span buffer = zstd_frame_header.buffer(); std::vector buffer_extended(kDslxBufferSizeBytes, 0); absl::Span input_buffer; if (buffer.size() < kDslxBufferSizeBytes) { @@ -124,8 +141,8 @@ class FrameHeaderTest : public xls::IrTestBase { } // Decide on the expected status - ZSTD_frameHeader zstd_fh = zstd_frame_header.kHeader; - size_t result = zstd_frame_header.kResult; + ZSTD_frameHeader zstd_fh = zstd_frame_header.header(); + size_t result = zstd_frame_header.result(); FrameHeaderStatus expected_status = FrameHeaderStatus::OK; if (result != 0) { if (ZSTD_isError(result)) {