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

Public Member Functions

 uglyPaths ()
 
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 848 of file fileOpsTests.cpp.

Constructor & Destructor Documentation

◆ uglyPaths()

uglyPaths::uglyPaths ( )
inline

Definition at line 850 of file fileOpsTests.cpp.

850  : baseTest("uglyPaths",
851  "write files in paths with ugly names", {
852  {"dir", "directory to create the paths in"
853  }
854  }) {};

Member Function Documentation

◆ execute()

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

Implements baseTest.

Definition at line 855 of file fileOpsTests.cpp.

855  {
856  auto dir = remainingOptions.at(0);
857  auto dirfd = throwcall::badval(open(dir.c_str(),O_PATH | O_DIRECTORY),-1,"can't open ",dir);
858  std::list<std::string> names{"path with spaces",
859  "path\nwith\nnewlines",
860  "path\rwith\rreturns",
861  "path\r\nwith\r\nCRLF",
862  "path_with_\033[91mred\033[0m_part",
863  "path_with_\xe2\x80\xadleft-to-right\xe2\x80\x8e_part",
864  "path_with_\xe2\x82\xac_euro",
865  "path_with_ɄɳɨȻʘΔε_unicode",
866  "path_with_🤔💩☢_emojis",
867  "path_with_䭫顙_more_unicode"
868  };
869  {
870  auto nameMax = throwcall::badval(fpathconf(dirfd,_PC_NAME_MAX),-1,"can't get max name length");
871  auto ugly = std::to_string(nameMax);
872  ugly.resize(nameMax,'b');
873  names.push_back(ugly);
874  }
875 
876  for (const auto& ugly: names) {
877  auto retval = mkdirat(dirfd,ugly.c_str(), 0777);
878  if (retval == -1 && errno == EINVAL) {
879  std::cerr << "illegal dir name \" << ugly << \" tried \n";
880  continue;
881  } else {
882  throwcall::badval(retval,-1, "mkdir ", ugly);
883  }
884  std::string file(ugly);
885  file += "/file";
886  auto fd = throwcall::badval(openat(dirfd, file.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0744),
887  -1, "open ", file);
888  ensuredWrite(fd, ugly);
889  throwcall::good0(close(fd), "close ", file);
890  createdFiles.emplace(dir + "/" + file);
891  }
892  };

References throwcall::badval(), baseTest::createdFiles, baseTest::ensuredWrite(), and throwcall::good0().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
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::createdFiles
std::set< std::string > createdFiles
Definition: fileOpsTests.cpp:42
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
baseTest::ensuredWrite
void ensuredWrite(int fd, const std::string &data)
Definition: fileOpsTests.cpp:106