-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a version of ReadFilesFromDirectory that allows filtering by file…
… name. Based on #1520. PiperOrigin-RevId: 719678199
- Loading branch information
1 parent
f96372c
commit eeb4a3d
Showing
17 changed files
with
284 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "./common/temp_dir.h" | ||
|
||
#include <filesystem> // NOLINT | ||
#include <system_error> | ||
|
||
#include "absl/log/check.h" | ||
|
||
namespace fuzztest::internal { | ||
|
||
namespace fs = std::filesystem; | ||
|
||
TempDir::TempDir() { | ||
std::error_code error; | ||
const fs::path path_template = | ||
std::filesystem::temp_directory_path(error) / "temp_dir_XXXXXX"; | ||
CHECK(!error) << "Failed to get the root temp directory path: " | ||
<< error.message(); | ||
path_ = mkdtemp(path_template.string().data()); | ||
CHECK(std::filesystem::is_directory(path_)); | ||
} | ||
|
||
TempDir::~TempDir() { | ||
std::error_code error; | ||
std::filesystem::remove_all(path_, error); | ||
CHECK(!error) << "Unable to clean up temporary dir " << path_ << ": " | ||
<< error.message(); | ||
} | ||
|
||
} // namespace fuzztest::internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef FUZZTEST_COMMON_TEMP_DIR_H_ | ||
#define FUZZTEST_COMMON_TEMP_DIR_H_ | ||
|
||
#include <filesystem> // NOLINT | ||
|
||
namespace fuzztest::internal { | ||
|
||
// A helper class for creating a temporary directory. Removes the directory | ||
// when it goes out of scope. | ||
class TempDir { | ||
public: | ||
explicit TempDir(); | ||
~TempDir(); | ||
|
||
TempDir(const TempDir& other) = delete; | ||
TempDir& operator=(const TempDir& other) = delete; | ||
|
||
const std::filesystem::path& path() const { return path_; } | ||
|
||
private: | ||
std::filesystem::path path_; | ||
}; | ||
|
||
} // namespace fuzztest::internal | ||
|
||
#endif // FUZZTEST_COMMON_TEMP_DIR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.