diff --git a/test/testing_scripts/creat_test.cpp b/test/testing_scripts/creat_test.cpp index 2a9d9324ad4e897ec0ab3edf6d9f95e4aaed7371..6289f2ccdc1ecb74984361d541a35b557f92381d 100644 --- a/test/testing_scripts/creat_test.cpp +++ b/test/testing_scripts/creat_test.cpp @@ -30,6 +30,10 @@ int main(int argc, char *argv[]) { auto filepath = path + filename; unsigned int length = atoi(argv[3]); + bool flush_files = false; + + std::cout << "Flushing? " << std::to_string(flush_files) << std::endl; + srand(666); char *data = (char *)malloc((length) * sizeof(char)); @@ -58,10 +62,12 @@ int main(int argc, char *argv[]) { if (write_rc != length) { std::cout << "write() call returned wrong value rc=" << std::to_string(write_rc) << std::endl; } else { - if (fsync(fd) != 0) { - std::cout << "write's fsync() failed errno=" << std::to_string(errno) << std::endl; + if (flush_files) { + if (fsync(fd) != 0) { + std::cout << "write's fsync() failed errno=" << std::to_string(errno) << std::endl; + } + close(fd); } - close(fd); std::cout << "sys open / write ran without failure" << std::endl; } } @@ -79,10 +85,12 @@ int main(int argc, char *argv[]) { std::cout << "fwrite() call returned wrong value rc=" << std::to_string(fwrite_rc) << std::endl; } else { - if (fflush(stream_file) != 0) { - std::cout << "fwrite's fflush() failed with errno=" << std::to_string(errno) << std::endl; + if (flush_files) { + if (fflush(stream_file) != 0) { + std::cout << "fwrite's fflush() failed with errno=" << std::to_string(errno) << std::endl; + } + fclose(stream_file); } - fclose(stream_file); std::cout << "fopen / fwrite ran without failure" << std::endl; } } @@ -101,6 +109,7 @@ int main(int argc, char *argv[]) { std::cout << "[MMAP] Error! Memory mapping unsuccessful. errno=" << std::to_string(errno) << std::endl; } else { memcpy(buf, data, length); + if (munmap(buf, length) < 0) { std::cout << "[MMAP FAILED] errno=" << std::to_string(errno) << std::endl; } else {