From 727f0968003459c994d03efd2539362eaf786dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20=C8=98endroiu?= Date: Thu, 7 Apr 2022 15:36:14 +0300 Subject: [PATCH 1/2] 2-stdio/checker: fix argument handling in test_fwrite_huge_chunked and test_fread_huge_chunked --- .../_test/src/test_fread_huge_chunked.c | 17 ++++++++--------- .../_test/src/test_fwrite_huge_chunked.c | 17 ++++++++--------- .../_test/src/test_fread_huge_chunked.c | 17 ++++++++--------- .../_test/src/test_fwrite_huge_chunked.c | 17 ++++++++--------- 4 files changed, 32 insertions(+), 36 deletions(-) diff --git a/assignments/2-stdio/checker-lin/_test/src/test_fread_huge_chunked.c b/assignments/2-stdio/checker-lin/_test/src/test_fread_huge_chunked.c index 8ce40388..7b097757 100644 --- a/assignments/2-stdio/checker-lin/_test/src/test_fread_huge_chunked.c +++ b/assignments/2-stdio/checker-lin/_test/src/test_fread_huge_chunked.c @@ -52,15 +52,14 @@ int main(int argc, char *argv[]) install_hooks("libso_stdio.so", hooks, 1); - if (argc == 2) - test_work_dir = argv[1]; - else - test_work_dir = "_test"; - - if (argc == 3) - size_member = atoi(argv[2]); - else - size_member = 1; + test_work_dir = "_test"; + size_member = 1; + + if (argc >= 2) + test_work_dir = argv[1]; + + if (argc == 3) + size_member = atoi(argv[2]); sprintf(fpath, "%s/huge_file", test_work_dir); diff --git a/assignments/2-stdio/checker-lin/_test/src/test_fwrite_huge_chunked.c b/assignments/2-stdio/checker-lin/_test/src/test_fwrite_huge_chunked.c index 8c02b94f..9c86599b 100644 --- a/assignments/2-stdio/checker-lin/_test/src/test_fwrite_huge_chunked.c +++ b/assignments/2-stdio/checker-lin/_test/src/test_fwrite_huge_chunked.c @@ -48,15 +48,14 @@ int main(int argc, char *argv[]) install_hooks("libso_stdio.so", hooks, 1); - if (argc == 2) - test_work_dir = argv[1]; - else - test_work_dir = "_test"; - - if (argc == 3) - size_member = atoi(argv[2]); - else - size_member = 1; + test_work_dir = "_test"; + size_member = 1; + + if (argc >= 2) + test_work_dir = argv[1]; + + if (argc == 3) + size_member = atoi(argv[2]); sprintf(fpath, "%s/huge_file", test_work_dir); diff --git a/assignments/2-stdio/checker-win/_test/src/test_fread_huge_chunked.c b/assignments/2-stdio/checker-win/_test/src/test_fread_huge_chunked.c index c57c6e95..119c4fa4 100644 --- a/assignments/2-stdio/checker-win/_test/src/test_fread_huge_chunked.c +++ b/assignments/2-stdio/checker-win/_test/src/test_fread_huge_chunked.c @@ -53,15 +53,14 @@ int main(int argc, char *argv[]) install_hooks("so_stdio.dll", hooks, 1); - if (argc == 2) - test_work_dir = argv[1]; - else - test_work_dir = "_test"; - - if (argc == 3) - size_member = atoi(argv[2]); - else - size_member = 1; + test_work_dir = "_test"; + size_member = 1; + + if (argc >= 2) + test_work_dir = argv[1]; + + if (argc == 3) + size_member = atoi(argv[2]); sprintf(fpath, "%s/huge_file", test_work_dir); diff --git a/assignments/2-stdio/checker-win/_test/src/test_fwrite_huge_chunked.c b/assignments/2-stdio/checker-win/_test/src/test_fwrite_huge_chunked.c index af9c45aa..d719558a 100644 --- a/assignments/2-stdio/checker-win/_test/src/test_fwrite_huge_chunked.c +++ b/assignments/2-stdio/checker-win/_test/src/test_fwrite_huge_chunked.c @@ -49,15 +49,14 @@ int main(int argc, char *argv[]) install_hooks("so_stdio.dll", hooks, 1); - if (argc == 2) - test_work_dir = argv[1]; - else - test_work_dir = "_test"; - - if (argc == 3) - size_member = atoi(argv[2]); - else - size_member = 1; + test_work_dir = "_test"; + size_member = 1; + + if (argc >= 2) + test_work_dir = argv[1]; + + if (argc == 3) + size_member = atoi(argv[2]); sprintf(fpath, "%s/huge_file", test_work_dir); From aff73fc514d67081815683d97c558f43b224a068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20=C8=98endroiu?= Date: Thu, 7 Apr 2022 15:37:39 +0300 Subject: [PATCH 2/2] 2-stdio/checker: fix typo in test_fflush --- assignments/2-stdio/checker-lin/_test/src/test_fflush.c | 2 +- assignments/2-stdio/checker-win/_test/src/test_fflush.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assignments/2-stdio/checker-lin/_test/src/test_fflush.c b/assignments/2-stdio/checker-lin/_test/src/test_fflush.c index bca61303..6111e37f 100644 --- a/assignments/2-stdio/checker-lin/_test/src/test_fflush.c +++ b/assignments/2-stdio/checker-lin/_test/src/test_fflush.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) FAIL_IF(ret != 0, "Incorrect return value for so_fflush, got %d, expected %d\n", ret, 0); // one write syscall - FAIL_IF(num_sys_write != 1, "Incorrect number of write syscalls: got %d, expected %d\n", num_sys_write, 0); + FAIL_IF(num_sys_write != 1, "Incorrect number of write syscalls: got %d, expected %d\n", num_sys_write, 1); // data should be in the file FAIL_IF(!compare_file(fpath, buf, 2048), "Incorrect data in file\n"); diff --git a/assignments/2-stdio/checker-win/_test/src/test_fflush.c b/assignments/2-stdio/checker-win/_test/src/test_fflush.c index 5424e745..4a392f6f 100644 --- a/assignments/2-stdio/checker-win/_test/src/test_fflush.c +++ b/assignments/2-stdio/checker-win/_test/src/test_fflush.c @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) FAIL_IF(ret != 0, "Incorrect return value for so_fflush, got %d, expected %d\n", ret, 0); // one write syscall - FAIL_IF(num_WriteFile != 1, "Incorrect number of write syscalls: got %d, expected %d\n", num_WriteFile, 0); + FAIL_IF(num_WriteFile != 1, "Incorrect number of write syscalls: got %d, expected %d\n", num_WriteFile, 1); // data should be in the file FAIL_IF(!compare_file(fpath, buf, 2048), "Incorrect data in file\n");