mirror of
https://github.com/facebook/zstd.git
synced 2025-07-29 11:21:22 +03:00
[pzstd] Turn on warnings + quiet them
This commit is contained in:
@ -87,19 +87,27 @@ googletest32:
|
|||||||
@mkdir -p googletest/build
|
@mkdir -p googletest/build
|
||||||
@cd googletest/build && cmake .. -DCMAKE_CXX_FLAGS=-m32 && make
|
@cd googletest/build && cmake .. -DCMAKE_CXX_FLAGS=-m32 && make
|
||||||
|
|
||||||
test: libzstd.a Pzstd.o Options.o SkippableFrame.o
|
googletest-mingw64:
|
||||||
|
$(RM) -rf googletest
|
||||||
|
git clone https://github.com/google/googletest
|
||||||
|
mkdir -p googletest/build
|
||||||
|
cd googletest/build && cmake -G "MSYS Makefiles" .. && $(MAKE)
|
||||||
|
|
||||||
|
test:
|
||||||
|
$(MAKE) libzstd.a
|
||||||
|
$(MAKE) pzstd MOREFLAGS="-Wall -Wextra -pedantic -Werror"
|
||||||
$(MAKE) -C utils/test clean
|
$(MAKE) -C utils/test clean
|
||||||
$(MAKE) -C utils/test test
|
$(MAKE) -C utils/test test MOREFLAGS="-Wall -Wextra -pedantic -Werror"
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
$(MAKE) -C test test
|
$(MAKE) -C test test MOREFLAGS="-Wall -Wextra -pedantic -Werror"
|
||||||
|
|
||||||
test32:
|
test32:
|
||||||
$(MAKE) clean
|
$(MAKE) libzstd.a MOREFLAGS="-m32"
|
||||||
$(MAKE) pzstd MOREFLAGS="-m32"
|
$(MAKE) pzstd MOREFLAGS="-m32 -Wall -Wextra -pedantic -Werror"
|
||||||
$(MAKE) -C utils/test clean
|
$(MAKE) -C utils/test clean
|
||||||
$(MAKE) -C utils/test test MOREFLAGS="-m32"
|
$(MAKE) -C utils/test test MOREFLAGS="-m32 -Wall -Wextra -pedantic -Werror"
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
$(MAKE) -C test test MOREFLAGS="-m32"
|
$(MAKE) -C test test MOREFLAGS="-m32 -Wall -Wextra -pedantic -Werror"
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -55,7 +55,6 @@ static std::uintmax_t fileSizeOrZero(const std::string &file) {
|
|||||||
static size_t handleOneInput(const Options &options,
|
static size_t handleOneInput(const Options &options,
|
||||||
const std::string &inputFile,
|
const std::string &inputFile,
|
||||||
FILE* inputFd,
|
FILE* inputFd,
|
||||||
const std::string &outputFile,
|
|
||||||
FILE* outputFd,
|
FILE* outputFd,
|
||||||
ErrorHolder &errorHolder) {
|
ErrorHolder &errorHolder) {
|
||||||
auto inputSize = fileSizeOrZero(inputFile);
|
auto inputSize = fileSizeOrZero(inputFile);
|
||||||
@ -186,7 +185,7 @@ int pzstdMain(const Options &options) {
|
|||||||
}
|
}
|
||||||
auto closeOutputGuard = makeScopeGuard([&] { std::fclose(outputFd); });
|
auto closeOutputGuard = makeScopeGuard([&] { std::fclose(outputFd); });
|
||||||
// (de)compress the file
|
// (de)compress the file
|
||||||
handleOneInput(options, input, inputFd, outputFile, outputFd, errorHolder);
|
handleOneInput(options, input, inputFd, outputFd, errorHolder);
|
||||||
if (errorHolder.hasError()) {
|
if (errorHolder.hasError()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -21,19 +21,19 @@ ZSTDDIR = ../../../lib
|
|||||||
# Set GTEST_INC and GTEST_LIB to work with your install of gtest
|
# Set GTEST_INC and GTEST_LIB to work with your install of gtest
|
||||||
GTEST_INC ?= -isystem $(PZSTDDIR)/googletest/googletest/include
|
GTEST_INC ?= -isystem $(PZSTDDIR)/googletest/googletest/include
|
||||||
GTEST_LIB ?= -L $(PZSTDDIR)/googletest/build/googlemock/gtest
|
GTEST_LIB ?= -L $(PZSTDDIR)/googletest/build/googlemock/gtest
|
||||||
|
GTEST_FLAGS = $(GTEST_INC) $(GTEST_LIB)
|
||||||
CPPFLAGS = -I$(PZSTDDIR) $(GTEST_INC) $(GTEST_LIB) -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(PROGDIR) -I.
|
CPPFLAGS = -I$(PZSTDDIR) -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(PROGDIR) -I.
|
||||||
|
|
||||||
CXXFLAGS ?= -O3
|
CXXFLAGS ?= -O3
|
||||||
CXXFLAGS += -std=c++11
|
CXXFLAGS += -std=c++11 -Wno-deprecated-declarations
|
||||||
CXXFLAGS += $(MOREFLAGS)
|
CXXFLAGS += $(MOREFLAGS)
|
||||||
FLAGS = $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)
|
FLAGS = $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
datagen.o: $(PROGDIR)/datagen.*
|
datagen.o: $(PROGDIR)/datagen.*
|
||||||
$(CXX) $(FLAGS) $(PROGDIR)/datagen.c -c -o $@
|
$(CC) $(CPPFLAGS) -O3 $(MOREFLAGS) $(LDFLAGS) -Wno-long-long -Wno-variadic-macros $(PROGDIR)/datagen.c -c -o $@
|
||||||
|
|
||||||
%: %.cpp *.h datagen.o
|
%: %.cpp *.h datagen.o
|
||||||
$(CXX) $(FLAGS) $@.cpp datagen.o $(PZSTDDIR)/Pzstd.o $(PZSTDDIR)/SkippableFrame.o $(PZSTDDIR)/Options.o $(PZSTDDIR)/libzstd.a -o $@$(EXT) -lgtest -lgtest_main -lpthread
|
$(CXX) $(FLAGS) $@.cpp datagen.o $(PZSTDDIR)/Pzstd.o $(PZSTDDIR)/SkippableFrame.o $(PZSTDDIR)/Options.o $(PZSTDDIR)/libzstd.a -o $@$(EXT) $(GTEST_FLAGS) -lgtest -lgtest_main -lpthread
|
||||||
|
|
||||||
.PHONY: test clean
|
.PHONY: test clean
|
||||||
|
|
||||||
|
@ -73,10 +73,7 @@ const char nullOutput[] = "nul";
|
|||||||
const char nullOutput[] = "/dev/null";
|
const char nullOutput[] = "/dev/null";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto autoMode = Options::WriteMode::Auto;
|
constexpr auto autoMode = Options::WriteMode::Auto;
|
||||||
const auto regMode = Options::WriteMode::Regular;
|
|
||||||
const auto sparseMode = Options::WriteMode::Sparse;
|
|
||||||
const auto success = Options::Status::Success;
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
#define EXPECT_SUCCESS(...) EXPECT_EQ(Options::Status::Success, __VA_ARGS__)
|
#define EXPECT_SUCCESS(...) EXPECT_EQ(Options::Status::Success, __VA_ARGS__)
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*/
|
*/
|
||||||
#include "Pzstd.h"
|
#include "Pzstd.h"
|
||||||
|
extern "C" {
|
||||||
#include "datagen.h"
|
#include "datagen.h"
|
||||||
|
}
|
||||||
#include "test/RoundTrip.h"
|
#include "test/RoundTrip.h"
|
||||||
#include "utils/ScopeGuard.h"
|
#include "utils/ScopeGuard.h"
|
||||||
|
|
||||||
@ -25,11 +27,14 @@ TEST(Pzstd, SmallSizes) {
|
|||||||
std::fprintf(stderr, "Pzstd.SmallSizes seed: %u\n", seed);
|
std::fprintf(stderr, "Pzstd.SmallSizes seed: %u\n", seed);
|
||||||
std::mt19937 gen(seed);
|
std::mt19937 gen(seed);
|
||||||
|
|
||||||
for (unsigned len = 1; len < 1028; ++len) {
|
for (unsigned len = 1; len < 256; ++len) {
|
||||||
|
if (len % 16 == 0) {
|
||||||
|
std::fprintf(stderr, "%u / 16\n", len / 16);
|
||||||
|
}
|
||||||
std::string inputFile = std::tmpnam(nullptr);
|
std::string inputFile = std::tmpnam(nullptr);
|
||||||
auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); });
|
auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); });
|
||||||
{
|
{
|
||||||
static uint8_t buf[1028];
|
static uint8_t buf[256];
|
||||||
RDG_genBuffer(buf, len, 0.5, 0.0, gen());
|
RDG_genBuffer(buf, len, 0.5, 0.0, gen());
|
||||||
auto fd = std::fopen(inputFile.c_str(), "wb");
|
auto fd = std::fopen(inputFile.c_str(), "wb");
|
||||||
auto written = std::fwrite(buf, 1, len, fd);
|
auto written = std::fwrite(buf, 1, len, fd);
|
||||||
@ -37,8 +42,8 @@ TEST(Pzstd, SmallSizes) {
|
|||||||
ASSERT_EQ(written, len);
|
ASSERT_EQ(written, len);
|
||||||
}
|
}
|
||||||
for (unsigned headers = 0; headers <= 1; ++headers) {
|
for (unsigned headers = 0; headers <= 1; ++headers) {
|
||||||
for (unsigned numThreads = 1; numThreads <= 4; numThreads *= 2) {
|
for (unsigned numThreads = 1; numThreads <= 2; ++numThreads) {
|
||||||
for (unsigned level = 1; level <= 8; level *= 8) {
|
for (unsigned level = 1; level <= 4; level *= 4) {
|
||||||
auto errorGuard = makeScopeGuard([&] {
|
auto errorGuard = makeScopeGuard([&] {
|
||||||
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
||||||
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
||||||
@ -111,7 +116,10 @@ TEST(Pzstd, ExtremelyLargeSize) {
|
|||||||
for (size_t i = 0; i < (1 << 6) + 1; ++i) {
|
for (size_t i = 0; i < (1 << 6) + 1; ++i) {
|
||||||
RDG_genBuffer(buf.get(), kLength, 0.5, 0.0, gen());
|
RDG_genBuffer(buf.get(), kLength, 0.5, 0.0, gen());
|
||||||
auto written = std::fwrite(buf.get(), 1, kLength, fd);
|
auto written = std::fwrite(buf.get(), 1, kLength, fd);
|
||||||
ASSERT_EQ(written, kLength);
|
if (written != kLength) {
|
||||||
|
std::fprintf(stderr, "Failed to write file, skipping test\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +127,9 @@ TEST(Pzstd, ExtremelyLargeSize) {
|
|||||||
options.overwrite = true;
|
options.overwrite = true;
|
||||||
options.inputFiles = {inputFile};
|
options.inputFiles = {inputFile};
|
||||||
options.compressionLevel = 1;
|
options.compressionLevel = 1;
|
||||||
|
if (options.numThreads == 0) {
|
||||||
|
options.numThreads = 1;
|
||||||
|
}
|
||||||
ASSERT_TRUE(roundTrip(options));
|
ASSERT_TRUE(roundTrip(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
* LICENSE file in the root directory of this source tree. An additional grant
|
* LICENSE file in the root directory of this source tree. An additional grant
|
||||||
* of patent rights can be found in the PATENTS file in the same directory.
|
* of patent rights can be found in the PATENTS file in the same directory.
|
||||||
*/
|
*/
|
||||||
|
extern "C" {
|
||||||
#include "datagen.h"
|
#include "datagen.h"
|
||||||
|
}
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "test/RoundTrip.h"
|
#include "test/RoundTrip.h"
|
||||||
#include "utils/ScopeGuard.h"
|
#include "utils/ScopeGuard.h"
|
||||||
@ -46,14 +48,12 @@ string generateInputFile(Generator& gen) {
|
|||||||
template <typename Generator>
|
template <typename Generator>
|
||||||
Options generateOptions(Generator& gen, const string& inputFile) {
|
Options generateOptions(Generator& gen, const string& inputFile) {
|
||||||
Options options;
|
Options options;
|
||||||
options.inputFile = inputFile;
|
options.inputFiles = {inputFile};
|
||||||
options.overwrite = true;
|
options.overwrite = true;
|
||||||
|
|
||||||
std::bernoulli_distribution pzstdHeaders{0.75};
|
|
||||||
std::uniform_int_distribution<unsigned> numThreads{1, 32};
|
std::uniform_int_distribution<unsigned> numThreads{1, 32};
|
||||||
std::uniform_int_distribution<unsigned> compressionLevel{1, 10};
|
std::uniform_int_distribution<unsigned> compressionLevel{1, 10};
|
||||||
|
|
||||||
options.pzstdHeaders = pzstdHeaders(gen);
|
|
||||||
options.numThreads = numThreads(gen);
|
options.numThreads = numThreads(gen);
|
||||||
options.compressionLevel = compressionLevel(gen);
|
options.compressionLevel = compressionLevel(gen);
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ Options generateOptions(Generator& gen, const string& inputFile) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main() {
|
||||||
std::mt19937 gen(std::random_device{}());
|
std::mt19937 gen(std::random_device{}());
|
||||||
|
|
||||||
auto newlineGuard = makeScopeGuard([] { std::fprintf(stderr, "\n"); });
|
auto newlineGuard = makeScopeGuard([] { std::fprintf(stderr, "\n"); });
|
||||||
@ -77,8 +77,6 @@ int main(int argc, char** argv) {
|
|||||||
std::fprintf(stderr, "numThreads: %u\n", options.numThreads);
|
std::fprintf(stderr, "numThreads: %u\n", options.numThreads);
|
||||||
std::fprintf(stderr, "level: %u\n", options.compressionLevel);
|
std::fprintf(stderr, "level: %u\n", options.compressionLevel);
|
||||||
std::fprintf(stderr, "decompress? %u\n", (unsigned)options.decompress);
|
std::fprintf(stderr, "decompress? %u\n", (unsigned)options.decompress);
|
||||||
std::fprintf(
|
|
||||||
stderr, "pzstd headers? %u\n", (unsigned)options.pzstdHeaders);
|
|
||||||
std::fprintf(stderr, "file: %s\n", inputFile.c_str());
|
std::fprintf(stderr, "file: %s\n", inputFile.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,11 @@
|
|||||||
|
|
||||||
namespace pzstd {
|
namespace pzstd {
|
||||||
|
|
||||||
|
// using file_status = ... causes gcc to emit a false positive warning
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
using file_status = struct ::_stat64;
|
typedef struct ::_stat64 file_status;
|
||||||
#else
|
#else
|
||||||
using file_status = struct ::stat;
|
typedef struct ::stat file_status;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// http://en.cppreference.com/w/cpp/filesystem/status
|
/// http://en.cppreference.com/w/cpp/filesystem/status
|
||||||
|
Reference in New Issue
Block a user