diff --git a/testing/test_bins/create_rename_delete_file.c b/testing/test_bins/create_rename_delete_file.c index f98a8418..fc13b692 100644 --- a/testing/test_bins/create_rename_delete_file.c +++ b/testing/test_bins/create_rename_delete_file.c @@ -7,6 +7,7 @@ * License 2.0. */ +#include #include #include #include @@ -25,9 +26,9 @@ int main() printf("{ \"pid_info\": %s, \"filename_orig\": \"%s\", \"filename_new\": \"%s\"}\n", pid_info, filename_orig, filename_new); - FILE *f; + int fd; // create - CHECK(f = fopen(filename_orig, "w"), NULL); + CHECK(fd = open(filename_orig, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR), -1); // rename CHECK(rename(filename_orig, filename_new), -1); @@ -35,10 +36,8 @@ int main() // modify(permissions) CHECK(chmod(filename_new, S_IRWXU | S_IRWXG | S_IRWXO), -1); - int fd = fileno(f); - // modify(content) - CHECK(write(fd, "test", 4), -1); + write(fd, "test", 4); // modify(content) struct iovec iov[2]; @@ -46,12 +45,12 @@ int main() iov[0].iov_len = 5; iov[1].iov_base = "test3"; iov[1].iov_len = 5; - CHECK(writev(fd, iov, 2), -1); + writev(fd, iov, 2); // modify(content) CHECK(ftruncate(fd, 0), -1); - CHECK(fclose(f), EOF); + close(fd); // delete CHECK(unlink(filename_new), -1); diff --git a/testing/testrunner/tests.go b/testing/testrunner/tests.go index a8a45710..b30dd3b3 100644 --- a/testing/testrunner/tests.go +++ b/testing/testrunner/tests.go @@ -405,6 +405,7 @@ func TestFileModify(et *EventsTraceInstance) { events := make([]FileModifyEvent, 0, eventsCount) for { var event FileModifyEvent + fmt.Println("GREPME", len(events), events) line := et.GetNextEventJson("FILE_MODIFY") if err := json.Unmarshal([]byte(line), &event); err != nil { TestFail("failed to unmarshal JSON: ", err)