ewmscp  ..
Public Member Functions | Static Public Member Functions | Static Protected Attributes | List of all members
copyRequest::checksumTest Class Reference

class for checking if checksums match expectations Extends the copyRequest::base class with new printResults function that checks if sums match expected values and prints results in a way compatible with e.g. More...

Inheritance diagram for copyRequest::checksumTest:
[legend]
Collaboration diagram for copyRequest::checksumTest:
[legend]

Public Member Functions

 checksumTest (const std::string &aSource, std::unique_ptr< const genericStat > &aStat, inputHandler::base *aInputHandler)
 
void printResults (std::ostream &, std::ostream &logStream) override
 
- Public Member Functions inherited from copyRequest::base
const genericStatgetInitialStat () const
 
const std::string & getSource () const
 
clock_type::duration getAdvisedDelay () const
 returns the advised delay More...
 
void registerIterator (decltype(filesInWorkIterator) iter)
 
decltype(filesInWorkIteratorgetFilesInWorkIteraror () const
 
fileInWork::slotTypes getSlotType () const
 
void changeRequestType (stateBitType newType)
 
 base (inputHandler::base *InputHandler, const std::string &aSource, const std::string &aDestination, std::unique_ptr< const genericStat > &aStat, const singleMap &aMapEntry, bool remove, clock_type::time_point timestamp)
 constructor for copy,link and remove requests. More...
 
 base (inputHandler::base *InputHandler, const std::string &aSource, const std::string &aDestination, const singleMap &aMapEntry, bool remove, clock_type::time_point timestamp)
 constructor for copy,link and remove requests. More...
 
 base (inputHandler::base *InputHandler, const std::string &aSource, const std::string &aDestination, const std::string &aMoveSource, const std::string &aOrigSource, const singleMap &aMapEntry, clock_type::time_point timestamp)
 constructor for rename requests only. More...
 
virtual ~base () noexcept(false)
 
virtual void process (perThreadData &threadData)
 
const std::string & getSuffix () const
 
void addExpectedChecksumResult (const std::string &checkSumType, const std::string &expectedValue)
 
void kw_size (std::string &value) const
 
void kw_mtime (std::string &value) const
 
void kw_inow (std::string &value) const
 
void kw_now (std::string &value) const
 
void kw_version (std::string &value) const
 
void kw_commit (std::string &value) const
 
void kw_prefix (std::string &value) const
 
void kw_reason (std::string &value) const
 
void kw_state (std::string &value) const
 
void kw_finishtime (std::string &value) const
 

Static Public Member Functions

static void printFinalLine (std::ostream &stream)
 
static void prepareStatPrint ()
 setup statPrinter to print the final line for compatibiity mith eg. md5sum More...
 
- Static Public Member Functions inherited from copyRequest::base
static std::map< std::string, void(base::*)(std::string &) const > & keywordMap ()
 
static bool adviseDelay (clock_type::duration dt, const std::string &suffix)
 update the advised delay in the map. More...
 
static void printStats (std::ostream &stream)
 
static void resetStats ()
 
static bool retry (std::unique_ptr< base > &request, timedQueue &delayedRequests)
 
static void waitForAllInstancesGone ()
 
static bool checkForInstances ()
 
static std::function< void(std::ostream &)> & getStatPrinter ()
 we can't have static functions virtual, so we explicitly use a function to give us the proper print function, which can be changed in derived classes. More...
 
static void setStatPrinter (void(*f)(std::ostream &))
 
static void processQueue (simpleQueue &queue, simpleQueue &resultQueue, timedQueue &delayedRequests)
 
static void getSuffix (const std::string &path, std::string &suffix)
 

Static Protected Attributes

static options::single< bool > exitOnMismatch
 
static unsigned int numberOfMismatches
 
static singleMap mapEntry
 
- Static Protected Attributes inherited from copyRequest::base
static statCollector::typed< decltype(tWorkDone - tInotify) > tTotalStat
 
static statCollector::typed< decltype(tWorkDone - tInotify) > tTotal2Stat
 
static statCollector::typed< decltype(tWorkDone - tInotify) > tInotifyStat
 
static statCollector::typed< decltype(tEnqueue - tInotify) > tPipeStat
 
static statCollector::typed< decltype(tWorkStart - tEnqueue) > tWaitStat
 
static statCollector::typed< decltype(tWorkDone - tWorkStart) > tCopyStat
 
static statCollector::typed< decltype(readInitialStat->size) > bytesStat
 
static statCollector::typed< double > speedStat
 
static clock_type::time_point tProgramStart
 
static std::atomic< unsigned int > nConcurrentProcesses
 
static options::single< double > maxDelayTime
 
static std::function< void(std::ostream &)> statPrinter
 

Additional Inherited Members

- Public Attributes inherited from copyRequest::base
decltype(fileInWork::filesInWork.begin()) filesInWorkIterator = fileInWork::filesInWork.end()
 
- Static Public Attributes inherited from copyRequest::base
static options::single< bool > setAttributesAfterClose
 
static options::single< bool > perFileThreads
 
static options::single< size_t > userWriteBlockSize
 
static options::single< size_t > userReadBlockSize
 
static options::single< size_t > maxMemoryBlockSize
 
static options::single< size_t > minMemoryBlockSize
 
static statCollector::typed< copyRequest::clock_type::duration > tEnqueueStat
 
static std::vector< std::atomic< unsigned int > > * processMultiplicities
 
- Protected Member Functions inherited from copyRequest::base
void adviseDelay (clock_type::duration dt=clock_type::duration::zero())
 
- Protected Attributes inherited from copyRequest::base
std::unique_ptr< const genericStatreadInitialStat
 
std::list< checksum::base * > checkSums
 
perThreadDatathreadData
 
stateType state
 
std::string errorMessage
 
const std::string source
 
const std::string destination
 
const std::string moveSource
 
const std::string origSource
 
const singleMapmapEntry
 
std::string suffix
 
std::string prefix
 
size_t memoryBlockSize
 
clock_type::time_point tInotify
 
clock_type::time_point tEnqueue
 
clock_type::time_point tWorkStart
 
clock_type::time_point tWorkDone
 
unsigned retries
 

Detailed Description

class for checking if checksums match expectations Extends the copyRequest::base class with new printResults function that checks if sums match expected values and prints results in a way compatible with e.g.

md5sum command.

Definition at line 31 of file checksumTestRequestProvider.cpp.

Constructor & Destructor Documentation

◆ checksumTest()

copyRequest::checksumTest::checksumTest ( const std::string &  aSource,
std::unique_ptr< const genericStat > &  aStat,
inputHandler::base aInputHandler 
)
inline

Definition at line 37 of file checksumTestRequestProvider.cpp.

39  :
40  base(aInputHandler, aSource, "", aStat, mapEntry, false, copyRequest::clock_type::now()) {}

Member Function Documentation

◆ prepareStatPrint()

static void copyRequest::checksumTest::prepareStatPrint ( )
inlinestatic

setup statPrinter to print the final line for compatibiity mith eg. md5sum

Definition at line 69 of file checksumTestRequestProvider.cpp.

69  {
71  }

References printFinalLine(), and copyRequest::base::statPrinter.

Referenced by checksumTestRequestProvider::processSource().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printFinalLine()

static void copyRequest::checksumTest::printFinalLine ( std::ostream &  stream)
inlinestatic

Definition at line 59 of file checksumTestRequestProvider.cpp.

59  {
60  if (numberOfMismatches != 0) {
61  stream << numberOfMismatches << " computed checksum" << (numberOfMismatches > 1 ? "s" : "")
62  << " did NOT match\n";
63  if (exitOnMismatch) {
64  throw std::runtime_error("bad checksums found");
65  }
66  }
67  }

References exitOnMismatch, and numberOfMismatches.

Referenced by prepareStatPrint().

Here is the caller graph for this function:

◆ printResults()

void copyRequest::checksumTest::printResults ( std::ostream &  ,
std::ostream &  logStream 
)
inlineoverridevirtual

Reimplemented from copyRequest::base.

Definition at line 41 of file checksumTestRequestProvider.cpp.

42  {
43  static auto escaper = escapism::newEscaper("C");
44  bool matchesInAllSums = true;
45  for (const auto& sum : checkSums) {
46  if (!sum->getExpectedResult().empty()) {
47  matchesInAllSums &= sum->checkExpectation();
48  if (!quiet || sum->checkExpectation() == false) {
49  std::string name;
50  escaper->escape(source, name);
51  logStream << name << (sum->checkExpectation() ? ": OK\n" : ": FAILED\n");
52  }
53  }
54  }
55  if (! matchesInAllSums) {
57  }
58  }

References copyRequest::base::checkSums, escapism::newEscaper(), numberOfMismatches, quiet, and copyRequest::base::source.

Here is the call graph for this function:

Member Data Documentation

◆ exitOnMismatch

options::single<bool> copyRequest::checksumTest::exitOnMismatch
staticprotected

Definition at line 33 of file checksumTestRequestProvider.cpp.

Referenced by printFinalLine().

◆ mapEntry

singleMap copyRequest::checksumTest::mapEntry
staticprotected

Definition at line 35 of file checksumTestRequestProvider.cpp.

◆ numberOfMismatches

unsigned int copyRequest::checksumTest::numberOfMismatches
staticprotected

Definition at line 34 of file checksumTestRequestProvider.cpp.

Referenced by printFinalLine(), and printResults().


The documentation for this class was generated from the following file:
copyRequest::checksumTest::mapEntry
static singleMap mapEntry
Definition: checksumTestRequestProvider.cpp:35
copyRequest::checksumTest::exitOnMismatch
static options::single< bool > exitOnMismatch
Definition: checksumTestRequestProvider.cpp:33
copyRequest::checksumTest::printFinalLine
static void printFinalLine(std::ostream &stream)
Definition: checksumTestRequestProvider.cpp:59
escapism::newEscaper
static const escapism * newEscaper(const std::string &name)
Definition: escapism.cpp:25
copyRequest::base::source
const std::string source
Definition: copyRequest.h:284
copyRequest::base::statPrinter
static std::function< void(std::ostream &)> statPrinter
Definition: copyRequest.h:330
quiet
static options::single< bool > quiet('q', "quiet", "be quiet, no prefix to output lines")
copyRequest::base::base
base(inputHandler::base *InputHandler, const std::string &aSource, const std::string &aDestination, std::unique_ptr< const genericStat > &aStat, const singleMap &aMapEntry, bool remove, clock_type::time_point timestamp)
constructor for copy,link and remove requests.
Definition: copyRequest.cpp:1517
copyRequest::base::checkSums
std::list< checksum::base * > checkSums
Definition: copyRequest.h:277
copyRequest::checksumTest::numberOfMismatches
static unsigned int numberOfMismatches
Definition: checksumTestRequestProvider.cpp:34