Skip to content

Commit

Permalink
Fix Random UT Failure: PosixFile (nasa#2835)
Browse files Browse the repository at this point in the history
 * Fix additional issue where randomly generate file name may be
   too large for POSIX.
  • Loading branch information
rlcheng committed Sep 5, 2024
1 parent 9a19414 commit 2e39bf6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Os/Posix/test/ut/PosixFileTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ bool check_permissions(const char* path, int permission) {
//!
std::shared_ptr<std::string> get_test_filename(bool random) {
const char* filename = TEST_FILE;
char full_buffer[PATH_MAX];
char buffer[PATH_MAX - sizeof(BASE_PATH)];
char full_buffer[_POSIX_PATH_MAX];
char buffer[_POSIX_PATH_MAX - sizeof(BASE_PATH)];
// When random, select random characters
if (random) {
filename = buffer;
Expand All @@ -47,7 +47,7 @@ std::shared_ptr<std::string> get_test_filename(bool random) {
}
buffer[i] = 0; // Terminate random string
}
(void) snprintf(full_buffer, PATH_MAX, "%s/%s", BASE_PATH, filename);
(void) snprintf(full_buffer, _POSIX_PATH_MAX, "%s/%s", BASE_PATH, filename);
// Create a shared pointer wrapping our filename buffer
std::shared_ptr<std::string> pointer(new std::string(full_buffer), std::default_delete<std::string>());
return pointer;
Expand Down

0 comments on commit 2e39bf6

Please sign in to comment.