1.1 --- a/tests/dstest_file_monitor.cc Thu Sep 01 21:40:39 2022 +0200
1.2 +++ b/tests/dstest_file_monitor.cc Thu Sep 01 21:52:41 2022 +0200
1.3 @@ -34,6 +34,12 @@
1.4
1.5
1.6
1.7 +/* Number of files to open in the test. */
1.8 +
1.9 +static const int FILES_TO_OPEN = 10;
1.10 +
1.11 +
1.12 +
1.13 /* Open files in the directory given by filename. */
1.14
1.15 static void open_files(const char *filename)
1.16 @@ -46,7 +52,7 @@
1.17 return;
1.18 }
1.19
1.20 - for (int i = 0; i < 10; i++)
1.21 + for (int i = 0; i < FILES_TO_OPEN; i++)
1.22 {
1.23 sprintf(buffer, "%s/file%02d", filename, i);
1.24
1.25 @@ -67,7 +73,9 @@
1.26 return;
1.27 }
1.28
1.29 - while (1)
1.30 + int expected;
1.31 +
1.32 + for (expected = FILES_TO_OPEN; expected; expected--)
1.33 {
1.34 /* Wait for notification of content. */
1.35
1.36 @@ -81,6 +89,8 @@
1.37
1.38 printf("Notified with conditions:%s\n", directory->notifications & NOTIFY_FILE_OPENED ? " file opened" : "");
1.39 }
1.40 +
1.41 + printf("Notified for all expected files: %s\n", expected ? "False" : "True");
1.42 }
1.43
1.44
1.45 @@ -99,8 +109,9 @@
1.46
1.47 file_t *directory = client_open(filename, O_DIRECTORY);
1.48
1.49 - if (directory == NULL)
1.50 + if (!client_opened(directory))
1.51 {
1.52 + client_close(directory);
1.53 printf("Could not open directory.\n");
1.54 return 1;
1.55 }
1.56 @@ -115,6 +126,8 @@
1.57 for (int i = 0; i < 2; i++)
1.58 activities[i]->join();
1.59
1.60 + printf("Expected %d 'file opened' notifications.\n", FILES_TO_OPEN);
1.61 + printf("End of test.\n");
1.62 return 0;
1.63 }
1.64