[PATCH 1/5] Add internal <file_change_detection.h> header file

Adhemerval Zanella adhemerval.zanella@linaro.org
Mon Feb 10 20:57:00 GMT 2020



On 10/02/2020 16:57, Florian Weimer wrote:
> 
>>> +  /* Wait for a file change.  Depending on file system time stamp
>>> +     resolution, this subtest blocks for a while.  */
>>> +  for (int use_stdio = 0; use_stdio < 2; ++use_stdio)
>>> +    {
>>> +      struct file_change_detection initial;
>>> +      TEST_VERIFY (file_change_detection_for_path (&initial, path_file1));
>>> +      while (true)
>>> +        {
>>> +          support_write_file_string (path_file1, "line\n");
>>> +          struct file_change_detection current;
>>> +          if (use_stdio)
>>> +            TEST_VERIFY (file_change_detection_for_fp (&current, fp_file1));
>>> +          else
>>> +            TEST_VERIFY (file_change_detection_for_path (&current, path_file1));
>>> +          if (!file_is_unchanged (&initial, &current))
>>> +            break;
>>> +          /* Wait for a bit to reduce system load.  */
>>> +          usleep (100 * 1000);
>>> +        }
>>> +    }
>>
>> Ok, although the usleep seems excessive large (the testing will most likely
>> timeout prior usleep return).
> 
> Hmm, I thought that this would wait 100 milliseconds?  So the loop
> should exit in a second or two with low-resolution timestamps in the
> file system.
> 

Right, it should be ok then.



More information about the Libc-alpha mailing list