tests: cover CLI prefix stripping, set-pin gate, paged reply bounds, and ACL write failures
Changelog: -
This commit is contained in:
1 parent
0dcc9c6e06
commit
5f31fc8e50
6 files changed
+192
-35
No files matched your search
@@ -18,11 +18,12 @@ class File {
|
||||
std::string _name;
|
||||
size_t _pos = 0;
|
||||
bool _write = false;
|
||||
size_t _short_write = 0;
|
||||
|
||||
public:
|
||||
File() = default;
|
||||
File(std::map<std::string, std::string>* files, const std::string& name, bool write)
|
||||
: _files(files), _name(name), _write(write) {
|
||||
File(std::map<std::string, std::string>* files, const std::string& name, bool write, size_t short_write = 0)
|
||||
: _files(files), _name(name), _write(write), _short_write(short_write) {
|
||||
if (write) (*_files)[name] = "";
|
||||
}
|
||||
explicit operator bool() const { return _files != nullptr; }
|
||||
@@ -34,8 +35,9 @@ public:
|
||||
return (int)n;
|
||||
}
|
||||
size_t write(const uint8_t* buf, size_t len) {
|
||||
(*_files)[_name].append((const char*)buf, len);
|
||||
return len;
|
||||
size_t n = (_short_write > 0 && _short_write < len) ? _short_write : len;
|
||||
(*_files)[_name].append((const char*)buf, n);
|
||||
return n;
|
||||
}
|
||||
void close() {}
|
||||
};
|
||||
@@ -46,14 +48,22 @@ class Adafruit_LittleFS {
|
||||
public:
|
||||
std::map<std::string, std::string> files;
|
||||
int writes = 0;
|
||||
bool fail_next_write_open = false;
|
||||
size_t short_next_write = 0;
|
||||
|
||||
bool exists(const char* name) { return files.count(name) > 0; }
|
||||
bool remove(const char* name) { return files.erase(name) > 0; }
|
||||
bool mkdir(const char*) { return true; }
|
||||
Adafruit_LittleFS_Namespace::File open(const char* name, uint8_t mode = FILE_O_READ) {
|
||||
if (mode == FILE_O_WRITE) {
|
||||
if (fail_next_write_open) {
|
||||
fail_next_write_open = false;
|
||||
return Adafruit_LittleFS_Namespace::File();
|
||||
}
|
||||
writes++;
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, true);
|
||||
size_t sw = short_next_write;
|
||||
short_next_write = 0;
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, true, sw);
|
||||
}
|
||||
if (!exists(name)) return Adafruit_LittleFS_Namespace::File();
|
||||
return Adafruit_LittleFS_Namespace::File(&files, name, false);
|
||||
|
||||
Reference in new issue
Block a user