|
| uglyNames () |
|
void | execute (const std::vector< std::string > &remainingOptions) override |
|
| 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) |
|
Definition at line 737 of file fileOpsTests.cpp.
◆ uglyNames()
Definition at line 739 of file fileOpsTests.cpp.
740 "write files with ugly names", {
741 {
"dir",
"directory to create the files in"
◆ execute()
void uglyNames::execute |
( |
const std::vector< std::string > & |
remainingOptions | ) |
|
|
inlineoverridevirtual |
Implements baseTest.
Definition at line 744 of file fileOpsTests.cpp.
745 auto dir = remainingOptions.at(0);
746 auto dirfd =
throwcall::badval(open(dir.c_str(),O_PATH | O_DIRECTORY),-1,
"can't open ",dir);
747 std::list<std::string> names{
"name with spaces",
748 "name\nwith\nnewlines",
749 "name\rwith\rreturns",
750 "name\r\nwith\r\nCRLF",
751 "name_with_\033[91mred\033[0m_part",
752 "name_with_\xe2\x80\xadleft-to-right\xe2\x80\x8e_part",
753 "name_with_\xe2\x82\xac_euro",
754 "name_with_ɄɳɨȻʘΔε_unicode",
755 "name_with_🤔💩☢_emojis",
756 "name_with_䭫顙_more_unicode"
759 std::list<std::pair<std::string,unsigned char>> ControlChars{
760 {
"SOH", 001}, {
"STX", 002}, {
"ETX", 003}, {
"EOT", 004},
761 {
"ENQ", 005}, {
"ACK", 006},
789 for (
const auto& cc: ControlChars) {
790 std::string ugly(
"name_with_");
791 ugly.push_back(cc.second);
793 ugly+=std::to_string(cc.second);
796 names.push_back(ugly);
800 std::vector<std::pair<unsigned char, unsigned char>> ranges{{32,46},{58,63},{91,96},{123,126}};
801 for (
const auto& range: ranges) {
802 for (
unsigned char c=range.first; c<=range.second; c++) {
803 std::string ugly(
"name_with_");
806 ugly+=std::to_string(c);
807 names.push_back(ugly);
811 for (
unsigned char c=128; c!=0; c++) {
812 std::string ugly(
"name_with_");
815 ugly+=std::to_string(c);
816 names.push_back(ugly);
819 auto nameMax =
throwcall::badval(fpathconf(dirfd,_PC_NAME_MAX),-1,
"can't get max name length");
820 auto ugly = std::to_string(nameMax);
821 ugly.resize(nameMax,
'b');
822 names.push_back(ugly);
825 for (
const auto& ugly: names) {
826 std::string file(dir);
829 auto fd = openat(dirfd,ugly.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0744);
830 if (fd == -1 && errno == EINVAL) {
831 std::cerr <<
"illegal file name \" << ugly << \" tried: ";
832 for (
auto c : ugly) {
833 std::cerr << std::hex << std::setw(2) << c;
835 std::cerr << std::dec <<
"\n";
References throwcall::badval(), baseTest::createdFiles, baseTest::ensuredWrite(), and throwcall::good0().
The documentation for this class was generated from the following file:
T badval(T call, t badvalue, const Args &... args)
template function to wrap system calls that return a special bad value on failure