Clean imports and shorten tests

This commit is contained in:
Nick Terrell 2017-01-26 20:47:59 -08:00
parent 9c018cc140
commit 58f499c41e
4 changed files with 32 additions and 43 deletions

View File

@ -37,8 +37,8 @@ class Logger {
return level <= level_; return level <= level_;
} }
template <typename... Args> template <typename String, typename... Args>
void operator()(int level, const char *fmt, Args... args) { void operator()(int level, String fmt, Args... args) {
if (level > level_) { if (level > level_) {
return; return;
} }

View File

@ -7,6 +7,7 @@
* 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 "Options.h" #include "Options.h"
#include "util.h"
#include "utils/ScopeGuard.h" #include "utils/ScopeGuard.h"
#include <algorithm> #include <algorithm>
@ -15,7 +16,6 @@
#include <cstring> #include <cstring>
#include <iterator> #include <iterator>
#include <thread> #include <thread>
#include <util.h>
#include <vector> #include <vector>
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || \ #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || \

View File

@ -9,11 +9,6 @@
#include "ErrorHolder.h" #include "ErrorHolder.h"
#include "Options.h" #include "Options.h"
#include "Pzstd.h" #include "Pzstd.h"
#include "utils/FileSystem.h"
#include "utils/Range.h"
#include "utils/ScopeGuard.h"
#include "utils/ThreadPool.h"
#include "utils/WorkQueue.h"
using namespace pzstd; using namespace pzstd;

View File

@ -41,23 +41,20 @@ TEST(Pzstd, SmallSizes) {
std::fclose(fd); std::fclose(fd);
ASSERT_EQ(written, len); ASSERT_EQ(written, len);
} }
for (unsigned headers = 0; headers <= 1; ++headers) { for (unsigned numThreads = 1; numThreads <= 2; ++numThreads) {
for (unsigned numThreads = 1; numThreads <= 2; ++numThreads) { for (unsigned level = 1; level <= 4; level *= 4) {
for (unsigned level = 1; level <= 4; level *= 4) { auto errorGuard = makeScopeGuard([&] {
auto errorGuard = makeScopeGuard([&] { std::fprintf(stderr, "# threads: %u\n", numThreads);
std::fprintf(stderr, "pzstd headers: %u\n", headers); std::fprintf(stderr, "compression level: %u\n", level);
std::fprintf(stderr, "# threads: %u\n", numThreads); });
std::fprintf(stderr, "compression level: %u\n", level); Options options;
}); options.overwrite = true;
Options options; options.inputFiles = {inputFile};
options.overwrite = true; options.numThreads = numThreads;
options.inputFiles = {inputFile}; options.compressionLevel = level;
options.numThreads = numThreads; options.verbosity = 1;
options.compressionLevel = level; ASSERT_TRUE(roundTrip(options));
options.verbosity = 1; errorGuard.dismiss();
ASSERT_TRUE(roundTrip(options));
errorGuard.dismiss();
}
} }
} }
} }
@ -79,29 +76,26 @@ TEST(Pzstd, LargeSizes) {
std::fclose(fd); std::fclose(fd);
ASSERT_EQ(written, len); ASSERT_EQ(written, len);
} }
for (unsigned headers = 0; headers <= 1; ++headers) { for (unsigned numThreads = 1; numThreads <= 16; numThreads *= 4) {
for (unsigned numThreads = 1; numThreads <= 16; numThreads *= 4) { for (unsigned level = 1; level <= 4; level *= 4) {
for (unsigned level = 1; level <= 4; level *= 2) { auto errorGuard = makeScopeGuard([&] {
auto errorGuard = makeScopeGuard([&] { std::fprintf(stderr, "# threads: %u\n", numThreads);
std::fprintf(stderr, "pzstd headers: %u\n", headers); std::fprintf(stderr, "compression level: %u\n", level);
std::fprintf(stderr, "# threads: %u\n", numThreads); });
std::fprintf(stderr, "compression level: %u\n", level); Options options;
}); options.overwrite = true;
Options options; options.inputFiles = {inputFile};
options.overwrite = true; options.numThreads = std::min(numThreads, options.numThreads);
options.inputFiles = {inputFile}; options.compressionLevel = level;
options.numThreads = std::min(numThreads, options.numThreads); options.verbosity = 1;
options.compressionLevel = level; ASSERT_TRUE(roundTrip(options));
options.verbosity = 1; errorGuard.dismiss();
ASSERT_TRUE(roundTrip(options));
errorGuard.dismiss();
}
} }
} }
} }
} }
TEST(Pzstd, ExtremelyLargeSize) { TEST(Pzstd, DISABLED_ExtremelyLargeSize) {
unsigned seed = std::random_device{}(); unsigned seed = std::random_device{}();
std::fprintf(stderr, "Pzstd.ExtremelyLargeSize seed: %u\n", seed); std::fprintf(stderr, "Pzstd.ExtremelyLargeSize seed: %u\n", seed);
std::mt19937 gen(seed); std::mt19937 gen(seed);