update version to 1.1.9
This commit is contained in:
parent
da173a973e
commit
f6343715d1
@ -1,278 +0,0 @@
|
||||
From 72c63614b10be25917c60741b0c58a0387978373 Mon Sep 17 00:00:00 2001
|
||||
From: hanxinke <hanxinke@huawei.com>
|
||||
Date: Thu, 2 Dec 2021 06:54:26 -0500
|
||||
Subject: [PATCH] add testcases and delete unnecessary test code for snappy
|
||||
|
||||
Signed-off-by: hanxinke <hanxinke@huawei.com>
|
||||
---
|
||||
snappy-test.h | 14 +++++
|
||||
snappy_unittest.cc | 131 ++++++++++++++++++++++++++++++++++++++++-----
|
||||
2 files changed, 132 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/snappy-test.h b/snappy-test.h
|
||||
index c8b7d38..4c6ab02 100644
|
||||
--- a/snappy-test.h
|
||||
+++ b/snappy-test.h
|
||||
@@ -170,6 +170,7 @@ namespace snappy {
|
||||
using TypeParam = std::string;
|
||||
|
||||
void Test_CorruptedTest_VerifyCorrupted();
|
||||
+void Test_CorryptedTest_VerifyUncompressFailed();
|
||||
void Test_Snappy_SimpleTests();
|
||||
void Test_Snappy_MaxBlowup();
|
||||
void Test_Snappy_RandomData();
|
||||
@@ -180,6 +181,11 @@ void Test_SnappyCorruption_OverflowingVarint();
|
||||
void Test_Snappy_ReadPastEndOfBuffer();
|
||||
void Test_Snappy_FindMatchLength();
|
||||
void Test_Snappy_FindMatchLengthRandom();
|
||||
+void Test_Snappy_SnappyCompress();
|
||||
+void Test_Snappy_SnappyUncompress();
|
||||
+void Test_Snappy_SnappyValidateCompress();
|
||||
+void Test_Snappy_SnappyValidCompressed();
|
||||
+void Test_Snappy_SnappySlowAppend();
|
||||
|
||||
std::string ReadTestDataFile(const std::string& base, size_t size_limit);
|
||||
|
||||
@@ -262,6 +268,7 @@ class Benchmark {
|
||||
(new Benchmark(#benchmark_name, benchmark_name))
|
||||
|
||||
extern Benchmark* Benchmark_BM_UFlat;
|
||||
+extern Benchmark* Benchmark_BM_UFlatSink;
|
||||
extern Benchmark* Benchmark_BM_UIOVec;
|
||||
extern Benchmark* Benchmark_BM_UValidate;
|
||||
extern Benchmark* Benchmark_BM_ZFlat;
|
||||
@@ -415,6 +422,7 @@ static inline void RunSpecifiedBenchmarks() {
|
||||
fprintf(stderr, "---------------------------------------------------\n");
|
||||
|
||||
snappy::Benchmark_BM_UFlat->Run();
|
||||
+ snappy::Benchmark_BM_UFlatSink->Run();
|
||||
snappy::Benchmark_BM_UIOVec->Run();
|
||||
snappy::Benchmark_BM_UValidate->Run();
|
||||
snappy::Benchmark_BM_ZFlat->Run();
|
||||
@@ -429,6 +437,7 @@ static inline void RunSpecifiedBenchmarks() {
|
||||
static inline int RUN_ALL_TESTS() {
|
||||
fprintf(stderr, "Running correctness tests.\n");
|
||||
snappy::Test_CorruptedTest_VerifyCorrupted();
|
||||
+ snappy::Test_CorryptedTest_VerifyUncompressFailed();
|
||||
snappy::Test_Snappy_SimpleTests();
|
||||
snappy::Test_Snappy_MaxBlowup();
|
||||
snappy::Test_Snappy_RandomData();
|
||||
@@ -439,6 +448,11 @@ static inline int RUN_ALL_TESTS() {
|
||||
snappy::Test_Snappy_ReadPastEndOfBuffer();
|
||||
snappy::Test_Snappy_FindMatchLength();
|
||||
snappy::Test_Snappy_FindMatchLengthRandom();
|
||||
+ snappy::Test_Snappy_SnappyCompress();
|
||||
+ snappy::Test_Snappy_SnappyUncompress();
|
||||
+ snappy::Test_Snappy_SnappyValidateCompress();
|
||||
+ snappy::Test_Snappy_SnappyValidCompressed();
|
||||
+ snappy::Test_Snappy_SnappySlowAppend();
|
||||
fprintf(stderr, "All tests passed.\n");
|
||||
|
||||
return 0;
|
||||
diff --git a/snappy_unittest.cc b/snappy_unittest.cc
|
||||
index 37159c3..1872cac 100644
|
||||
--- a/snappy_unittest.cc
|
||||
+++ b/snappy_unittest.cc
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "snappy-internal.h"
|
||||
#include "snappy-test.h"
|
||||
#include "snappy-sinksource.h"
|
||||
+#include "snappy-c.h"
|
||||
|
||||
DEFINE_int32(start_len, -1,
|
||||
"Starting prefix size for testing (-1: just full file contents)");
|
||||
@@ -215,6 +216,25 @@ static bool Compress(const char* input, size_t input_size, CompressorType comp,
|
||||
return true;
|
||||
}
|
||||
|
||||
+snappy_status SnappyCompress(const char* input, size_t input_length,
|
||||
+ std::string* compressed, size_t compressed_length) {
|
||||
+ // Pre-grow the buffer to the max length of the compressed output
|
||||
+ STLStringResizeUninitialized(compressed, MaxCompressedLength(input_length));
|
||||
+
|
||||
+ snappy_status status = snappy_compress(input, input_length, string_as_array(compressed),
|
||||
+ &compressed_length);
|
||||
+ compressed->resize(compressed_length);
|
||||
+ return status;
|
||||
+}
|
||||
+
|
||||
+snappy_status SnappyUncompress(const char* compressed, size_t compressed_length,
|
||||
+ std::string* uncompressed, size_t uncompressed_length) {
|
||||
+ STLStringResizeUninitialized(uncompressed, uncompressed_length);
|
||||
+ snappy_status status = snappy_uncompress(compressed, compressed_length,
|
||||
+ string_as_array(uncompressed), &uncompressed_length);
|
||||
+ return status;
|
||||
+}
|
||||
+
|
||||
static bool Uncompress(const std::string& compressed, CompressorType comp,
|
||||
int size, std::string* output) {
|
||||
switch (comp) {
|
||||
@@ -392,6 +412,24 @@ static void VerifyStringSink(const std::string& input) {
|
||||
CHECK_EQ(uncompressed, input);
|
||||
}
|
||||
|
||||
+static void VerifySinkAsMuchAsPossible(const std::string& input) {
|
||||
+ std::string compressed;
|
||||
+ DataEndingAtUnreadablePage i(input);
|
||||
+ const size_t written = snappy::Compress(i.data(), i.size(), &compressed);
|
||||
+ CHECK_EQ(written, compressed.size());
|
||||
+ CHECK_LE(compressed.size(),
|
||||
+ snappy::MaxCompressedLength(input.size()));
|
||||
+ CHECK(snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
|
||||
+
|
||||
+ std::string uncompressed;
|
||||
+ uncompressed.resize(input.size());
|
||||
+ snappy::UncheckedByteArraySink sink(string_as_array(&uncompressed));
|
||||
+ DataEndingAtUnreadablePage c(compressed);
|
||||
+ snappy::ByteArraySource source(c.data(), c.size());
|
||||
+ CHECK(snappy::UncompressAsMuchAsPossible(&source, &sink));
|
||||
+ CHECK_EQ(uncompressed, input);
|
||||
+}
|
||||
+
|
||||
static void VerifyIOVec(const std::string& input) {
|
||||
std::string compressed;
|
||||
DataEndingAtUnreadablePage i(input);
|
||||
@@ -510,6 +548,10 @@ static int Verify(const std::string& input) {
|
||||
// Verify using sink based routines
|
||||
VerifyStringSink(input);
|
||||
|
||||
+ if (!input.empty()) {
|
||||
+ VerifySinkAsMuchAsPossible(input);
|
||||
+ }
|
||||
+
|
||||
VerifyNonBlockedCompression(input);
|
||||
VerifyIOVec(input);
|
||||
if (!input.empty()) {
|
||||
@@ -582,7 +624,7 @@ TEST(CorruptedTest, VerifyCorrupted) {
|
||||
// try reading stuff in from a bad file.
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
std::string data =
|
||||
- ReadTestDataFile(StrFormat("baddata%d.snappy", i).c_str(), 0);
|
||||
+ ReadTestDataFile(StrFormat("baddata%d.snappy", i).c_str());
|
||||
std::string uncmp;
|
||||
// check that we don't return a crazy length
|
||||
size_t ulen;
|
||||
@@ -597,6 +639,15 @@ TEST(CorruptedTest, VerifyCorrupted) {
|
||||
}
|
||||
}
|
||||
|
||||
+// This test checks to ensure that snappy compression fails.
|
||||
+TEST(CorruptedTest, VerifyUncompressFailed) {
|
||||
+ std::string source = "BPmaking sure we don't \r\025$crash";
|
||||
+ std::string dest;
|
||||
+ CHECK(!Uncompress(source, &dest));
|
||||
+ source = "B/ma";
|
||||
+ CHECK(!Uncompress(source, &dest));
|
||||
+}
|
||||
+
|
||||
// Helper routines to construct arbitrary compressed strings.
|
||||
// These mirror the compression code in snappy.cc, but are copied
|
||||
// here so that we can bypass some limitations in the how snappy.cc
|
||||
@@ -721,7 +772,6 @@ TEST(Snappy, RandomData) {
|
||||
x.push_back(c);
|
||||
}
|
||||
}
|
||||
-
|
||||
Verify(x);
|
||||
}
|
||||
}
|
||||
@@ -872,6 +922,59 @@ TEST(Snappy, IOVecCopyOverflow) {
|
||||
}
|
||||
}
|
||||
|
||||
+TEST(Snappy, SnappyCompress) {
|
||||
+ std::string source = "making sure we don't crash with corrupted input";
|
||||
+ std::string compressed;
|
||||
+ CHECK_EQ(SnappyCompress(source.c_str(), source.size(),
|
||||
+ &compressed, 100), SNAPPY_OK);
|
||||
+ CHECK_EQ(SnappyCompress(source.c_str(),
|
||||
+ source.size(), &compressed, 50), SNAPPY_BUFFER_TOO_SMALL);
|
||||
+}
|
||||
+
|
||||
+TEST(Snappy, SnappyUncompress) {
|
||||
+ std::string source = "making sure we don't crash with corrupted input";
|
||||
+ std::string compressed;
|
||||
+ CHECK_EQ(SnappyCompress(source.c_str(), source.size(),
|
||||
+ &compressed, 100), SNAPPY_OK);
|
||||
+ std::string uncompressed;
|
||||
+ size_t uncompressed_length;
|
||||
+ CHECK_EQ(SnappyUncompress(compressed.c_str(), compressed.size(),
|
||||
+ &uncompressed, 47), SNAPPY_OK);
|
||||
+ CHECK_EQ(snappy_uncompressed_length(compressed.c_str(),
|
||||
+ compressed.size(), &uncompressed_length), SNAPPY_OK);
|
||||
+ CHECK_EQ(SnappyUncompress(compressed.c_str(), compressed.size(),
|
||||
+ &uncompressed, 46), SNAPPY_BUFFER_TOO_SMALL);
|
||||
+ compressed[0]++;
|
||||
+ CHECK_EQ(SnappyUncompress(compressed.c_str(), compressed.size(),
|
||||
+ &uncompressed, 100), SNAPPY_INVALID_INPUT);
|
||||
+}
|
||||
+
|
||||
+TEST(Snappy, SnappyValidateCompress) {
|
||||
+ std::string source = "making sure we don't crash with corrupted input";
|
||||
+ std::string compressed;
|
||||
+ CHECK_EQ(SnappyCompress(source.c_str(), source.size(),
|
||||
+ &compressed, 100), SNAPPY_OK);
|
||||
+ CHECK_EQ(snappy_validate_compressed_buffer(compressed.c_str(),
|
||||
+ compressed.size()), SNAPPY_OK);
|
||||
+ CHECK_EQ(snappy_validate_compressed_buffer(compressed.c_str(), 50), SNAPPY_INVALID_INPUT);
|
||||
+}
|
||||
+
|
||||
+TEST(Snappy, SnappyValidCompressed) {
|
||||
+ std::string source = "making sure we don't crash with corrupted input";
|
||||
+ ByteArraySource reader(source.c_str(), source.size());
|
||||
+ IsValidCompressed(&reader);
|
||||
+}
|
||||
+
|
||||
+TEST(Snappy, SnappySlowAppend) {
|
||||
+ std::string compressed = "BPmaking sure we don't\r\025$crash with";
|
||||
+ std::string uncompressed;
|
||||
+ uncompressed.resize(compressed.size());
|
||||
+ snappy::UncheckedByteArraySink sink(string_as_array(&uncompressed));
|
||||
+ DataEndingAtUnreadablePage c(compressed);
|
||||
+ snappy::ByteArraySource source(c.data(), c.size());
|
||||
+ CHECK_EQ(snappy::UncompressAsMuchAsPossible(&source, &sink), 21);
|
||||
+}
|
||||
+
|
||||
static bool CheckUncompressedLength(const std::string& compressed,
|
||||
size_t* ulength) {
|
||||
const bool result1 = snappy::GetUncompressedLength(compressed.data(),
|
||||
@@ -1483,23 +1586,25 @@ static void BM_ZFlatIncreasingTableSize(int iters, int arg) {
|
||||
}
|
||||
BENCHMARK(BM_ZFlatIncreasingTableSize)->DenseRange(0, 0);
|
||||
|
||||
+
|
||||
+static void Check_File(int iters) {
|
||||
+ std::string filename;
|
||||
+ filename = "testdata/" + std::string(files[iters].filename);
|
||||
+ fprintf(stderr, "-----%s.\n", filename.c_str());
|
||||
+ snappy::CompressFile(filename.c_str());
|
||||
+ filename = filename.append(".comp");
|
||||
+ snappy::UncompressFile(filename.c_str());
|
||||
+ snappy::MeasureFile(filename.c_str());
|
||||
+}
|
||||
+
|
||||
} // namespace snappy
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
InitGoogle(argv[0], &argc, &argv, true);
|
||||
RunSpecifiedBenchmarks();
|
||||
|
||||
- if (argc >= 2) {
|
||||
- for (int arg = 1; arg < argc; arg++) {
|
||||
- if (FLAGS_write_compressed) {
|
||||
- snappy::CompressFile(argv[arg]);
|
||||
- } else if (FLAGS_write_uncompressed) {
|
||||
- snappy::UncompressFile(argv[arg]);
|
||||
- } else {
|
||||
- snappy::MeasureFile(argv[arg]);
|
||||
- }
|
||||
- }
|
||||
- return 0;
|
||||
+ for (int iter = 0; iter < ARRAYSIZE(snappy::files); iter++) {
|
||||
+ snappy::Check_File(iter);
|
||||
}
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
--
|
||||
2.23.0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From 581af0c0a819da2214466e4d30416616966e781d Mon Sep 17 00:00:00 2001
|
||||
From: hanxinke <hanxinke@huawei.com>
|
||||
Date: Tue, 7 Dec 2021 15:47:14 +0800
|
||||
Subject: [PATCH] fix the AdvanceToNextTag fails to be compiled without inline
|
||||
|
||||
Signed-off-by: hanxinke <hanxinke@huawei.com>
|
||||
---
|
||||
snappy.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/snappy.cc b/snappy.cc
|
||||
index 79dc0e8..51157be 100644
|
||||
--- a/snappy.cc
|
||||
+++ b/snappy.cc
|
||||
@@ -1014,7 +1014,7 @@ void MemMove(ptrdiff_t dst, const void* src, size_t size) {
|
||||
}
|
||||
|
||||
SNAPPY_ATTRIBUTE_ALWAYS_INLINE
|
||||
-size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
|
||||
+inline size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
|
||||
const uint8_t*& ip = *ip_p;
|
||||
// This section is crucial for the throughput of the decompression loop.
|
||||
// The latency of an iteration is fundamentally constrained by the
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
70
remove-dependency-on-google-benchmark-and-gmock.patch
Normal file
70
remove-dependency-on-google-benchmark-and-gmock.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From 14ccda0d6c228999c8d982a84562432cd7465743 Mon Sep 17 00:00:00 2001
|
||||
From: hanxinke <hanxinke@huawei.com>
|
||||
Date: Tue, 7 Dec 2021 15:34:34 +0800
|
||||
Subject: [PATCH] remove dependency on google benchmark and gmock
|
||||
|
||||
Signed-off-by: hanxinke <hanxinke@huawei.com>
|
||||
---
|
||||
CMakeLists.txt | 22 +++++++++++-----------
|
||||
1 file changed, 11 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 672561e..3127d9b 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -88,7 +88,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
|
||||
|
||||
option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
|
||||
|
||||
-option(SNAPPY_BUILD_BENCHMARKS "Build Snappy's benchmarks" ON)
|
||||
+option(SNAPPY_BUILD_BENCHMARKS "Build Snappy's benchmarks" OFF)
|
||||
|
||||
option(SNAPPY_FUZZING_BUILD "Build Snappy for fuzzing." OFF)
|
||||
|
||||
@@ -288,25 +288,25 @@ if(SNAPPY_BUILD_TESTS)
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
set(install_gtest OFF)
|
||||
set(install_gmock OFF)
|
||||
- set(build_gmock ON)
|
||||
+ set(build_gmock OFF)
|
||||
|
||||
# This project is tested using GoogleTest.
|
||||
- add_subdirectory("third_party/googletest")
|
||||
+ # add_subdirectory("third_party/googletest")
|
||||
|
||||
# GoogleTest triggers a missing field initializers warning.
|
||||
- if(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
||||
- set_property(TARGET gtest
|
||||
- APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
||||
- set_property(TARGET gmock
|
||||
- APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
||||
- endif(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
||||
+ # if(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
||||
+ # set_property(TARGET gtest
|
||||
+ # APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
||||
+ # set_property(TARGET gmock
|
||||
+ # APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
|
||||
+ # endif(SNAPPY_HAVE_NO_MISSING_FIELD_INITIALIZERS)
|
||||
|
||||
add_executable(snappy_unittest "")
|
||||
target_sources(snappy_unittest
|
||||
PRIVATE
|
||||
"snappy_unittest.cc"
|
||||
)
|
||||
- target_link_libraries(snappy_unittest snappy_test_support gmock_main gtest)
|
||||
+ target_link_libraries(snappy_unittest snappy_test_support gtest_main gtest)
|
||||
|
||||
add_test(
|
||||
NAME snappy_unittest
|
||||
@@ -332,7 +332,7 @@ if(SNAPPY_BUILD_BENCHMARKS)
|
||||
# This project uses Google benchmark for benchmarking.
|
||||
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
|
||||
- add_subdirectory("third_party/benchmark")
|
||||
+ # add_subdirectory("third_party/benchmark")
|
||||
endif(SNAPPY_BUILD_BENCHMARKS)
|
||||
|
||||
if(SNAPPY_FUZZING_BUILD)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
Binary file not shown.
BIN
snappy-1.1.9.tar.gz
Normal file
BIN
snappy-1.1.9.tar.gz
Normal file
Binary file not shown.
@ -1,12 +0,0 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -212,7 +212,7 @@
|
||||
"snappy-test.cc"
|
||||
)
|
||||
target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H)
|
||||
- target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES})
|
||||
+ target_link_libraries(snappy_unittest snappy ${GTEST_LIBRARIES} ${GFLAGS_LIBRARIES})
|
||||
|
||||
if(HAVE_LIBZ)
|
||||
target_link_libraries(snappy_unittest z)
|
||||
13
snappy.spec
13
snappy.spec
@ -1,16 +1,16 @@
|
||||
Name: snappy
|
||||
Version: 1.1.8
|
||||
Release: 2
|
||||
Version: 1.1.9
|
||||
Release: 1
|
||||
Summary: A fast compressor/decompressor
|
||||
License: BSD
|
||||
URL: https://github.com/google/snappy
|
||||
Source0: https://github.com/google/snappy/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
Source1: snappy.pc
|
||||
|
||||
Patch0: snappy-gtest.patch
|
||||
Patch1: add-testcases-and-delete-unnecessary-test-code-for-snappy.patch
|
||||
Patch0: remove-dependency-on-google-benchmark-and-gmock.patch
|
||||
Patch1: fix-the-AdvanceToNextTag-fails-to-be-compiled-without-inline.patch
|
||||
|
||||
BuildRequires: gcc-c++ automake autoconf gtest-devel cmake
|
||||
BuildRequires: gcc-c++ make gtest-devel cmake
|
||||
|
||||
%description
|
||||
Snappy is a compression/decompression library. It does not aim for maximum compression,
|
||||
@ -69,6 +69,9 @@ make test
|
||||
%doc NEWS README.md
|
||||
|
||||
%changelog
|
||||
* Fri Dec 24 2021 yuanxin<yuanxin24@huawei.com> - 1.1.9-1
|
||||
- update version to 1.1.9
|
||||
|
||||
* Thu Dec 2 2021 hanxinke<hanxinke@huawei.com> - 1.1.8-2
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user