Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mmat11 committed Jan 11, 2024
1 parent c550ab7 commit ab65046
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions testing/test_bins/create_rename_delete_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License 2.0.
*/

#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
Expand All @@ -25,33 +26,31 @@ 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);

// 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];
iov[0].iov_base = "test2";
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);
Expand Down
1 change: 1 addition & 0 deletions testing/testrunner/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ab65046

Please sign in to comment.