ewmscp  ..
Public Member Functions | List of all members
mmapRead Class Reference
Inheritance diagram for mmapRead:
[legend]
Collaboration diagram for mmapRead:
[legend]

Public Member Functions

 mmapRead ()
 
void execute (const std::vector< std::string > &remainingOptions) override
 
- Public Member Functions inherited from baseTest
 baseTest (const std::string &aName, const std::string &aDescription, const decltype(parameters)&aParameters, const decltype(options)&aOptions={})
 
void ensuredWrite (int fd, const std::string &data)
 
void ensuredRead (int fd, std::string &data)
 
void Execute (const std::vector< std::string > &remainingOptions)
 

Additional Inherited Members

- Static Public Member Functions inherited from baseTest
static std::map< std::string, baseTest * > & getList ()
 
static void setUpOptions ()
 
static const std::string & getDescriptions ()
 
- Protected Attributes inherited from baseTest
std::string name
 
std::string description
 
std::list< std::pair< std::string, std::string > > parameters
 
std::list< std::pair< options::base &, std::string > > options
 
std::set< std::string > createdFiles
 
- Static Protected Attributes inherited from baseTest
static options::single< unsigned int > repeat
 
static options::single< bool > cleanup
 
static options::single< bool > urandom
 
static options::single< bool > einsZweiDrei
 
static options::single< std::string > contentFile
 
static options::single< size_t > size
 
static options::single< unsigned int > blocks
 
static options::single< std::string > content
 
static options::single< bool > truncate
 
static options::single< std::chrono::duration< double > > time
 
static options::single< unsigned long > syncus
 
static options::single< unsigned long > skewus
 
static std::string descriptions = "\npossible actions and their parameters:\n"
 

Detailed Description

Definition at line 673 of file fileOpsTests.cpp.

Constructor & Destructor Documentation

◆ mmapRead()

mmapRead::mmapRead ( )
inline

Definition at line 675 of file fileOpsTests.cpp.

675  : baseTest("mmapRead",
676  "read file via mmap() and compare to content", {
677  {"file", "path to file"
678  }
679  }) {};

Member Function Documentation

◆ execute()

void mmapRead::execute ( const std::vector< std::string > &  remainingOptions)
inlineoverridevirtual

Implements baseTest.

Definition at line 680 of file fileOpsTests.cpp.

680  {
681  auto file = remainingOptions.at(0);
682  auto fd = throwcall::badval(open(file.c_str(), O_RDONLY), -1, "open ", file);
683  auto map = throwcall::badval(mmap(nullptr, content.size(),
684  PROT_READ, MAP_PRIVATE | MAP_POPULATE,
685  fd, 0),
686  MAP_FAILED,
687  "mmap ", content.size(), " bytes from ", file);
688  auto data = static_cast<const char *>(map);
689  if (content.compare(0, content.size(), data, content.size()) != 0) {
690  std::cout << "difference betwen content and file found\n";
691  }
692  throwcall::good0(munmap(map, content.size()), "unmap ", file);
693  throwcall::good0(close(fd), "close ", file);
694  };

References throwcall::badval(), baseTest::content, and throwcall::good0().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
baseTest::content
static options::single< std::string > content
Definition: fileOpsTests.cpp:51
throwcall::badval
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure
Definition: throwcall.h:54
baseTest::baseTest
baseTest(const std::string &aName, const std::string &aDescription, const decltype(parameters)&aParameters, const decltype(options)&aOptions={})
Definition: fileOpsTests.cpp:68
throwcall::good0
void good0(T call, const Args &... args)
template function to wrap system calls that return 0 on success
Definition: throwcall.h:40