bugfindutils - Bugs: bug #65337, Unexepected results from complete...

 
 

bug #65337: Unexepected results from complete tests on -mtime/-mmin/-daystart

Submitter:  None
Submitted:  Tue 20 Feb 2024 04:58:22 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Test suite failure Status:  None
Privacy:  Public Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  4.9.0
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 20 Feb 2024 06:21:21 PM UTC, comment #2: 

Sorry error sign in the creation times, the correction is:

  • x0 modified at T0 - epsi0         => AGE = epsi0/P
  • x1 modified at T0 - P/2 - epsi1   => AGE = 1/2 + epsi1/P
  • x2 modified at T0 - P - epsi2     => AGE = 1 + epsi2/P
  • x3 modified at T0 - 3/2 P - epsi3 => AGE = 3/2 + epsi3/P
  • x4 modified at T0 - 2 P - epsi4   => AGE = 2 + epsi4/P
  • x5 modified at T0 - 5/2 P - epsi5 => AGE = 5/2 + epsi5/P


I attached a schematic plot to clarify.

(file #55725)

Anonymous
Tue 20 Feb 2024 05:02:01 PM UTC, comment #1: 

Sorry my email was cut during submission: -email is unavailable-

Anonymous
Tue 20 Feb 2024 04:58:22 PM UTC, original submission:  

1 the version of findutils you are using (e.g. run "find --version" and include the output)
findutils 4.9.0

2  what you were trying to do
Making precise checks to try to understand the precise tests associated to the primaries -mtime -mmin, -daystart

3 the exact command line that you used
 See attached file find-time-tests-.bash

4 what you expected to happen
5 precisely what did happen.
 See discussion below, the attached file find-time-tests.out and the table in find-time-tests-results.md (Markdown)

-------------------------------------------------------------------
Dear maintainers of findutis

I would like to report the results of some tests I did (with findutils 4.9.0) on the behavior of find with the primaries -mtime -mmin and with or without -daystart.

My motivation was to understand the precise tests associated to the primaries -mtime -mmin, -daystart because I found the docs incomplete/unclear [1]

I found a few unexpected results, I honestly do not know if these can be qualified as bug(s) or as "well known features" not enough described in the documentation to reach my comprehension (in which case you might want to consider improving the documentation).

notations


To talk precisely about the expected behavior of find, let me first introduce some definitions. (Please stay with me!)

Independently of the details of the internal code, the possible cases can be treated by defining the AGE of a file and its rounded version RAGE as:

AGE:= (T0 - TM) / P
RAGE:= Floor[(T0 - TM) / P]

where:

  • TM is the modification time
  • T0 is "NOW" (execution time of find) or TOMORROW at 00:00
  • P is the period or window
  • all the times are measured in seconds.


Note that, according to the properties of Floor-rounding [2], for any integer n the following holds. (Equivalence does not hold with the > sign!)

AGE < n is equivalent to RAGE < n
RAGE > n implies AGE > n
AGE > n implies RAGE >= n
AGE >= n implies RAGE >= n


To approach the current implementation, it is useful to remark that

(R)AGE < n is equivalent to T0 - n P < TM
(R)AGE >= n is equivalent to T0 - n P >= TM
AGE > n is equivalent to T0 - n P > TM


expectations


Now, what to expect from find with the primaries -mtime -mmin and -daystart?

  • POSIX [3] states clearly that the primary -mtime n with n an unsigned integer should be true if, with P=86400 T0=NOW, RAGE = n


The rest is not POSIX; from the docs [1]  I understand:

  • -daystart -mtime n should be true if, with P=86400 T0=TOMORROW at 00:00, RAGE = n


  • For -mmin n  with n an unsigned integer true if, with P=60 T0=NOW, RAGE = n


  • For -daystart -mmin n  with n an unsigned integer true if, with P=60 T0=TOMORROW at 00:00, RAGE = n


When signed numbers +n /-n are used (age ranges) I would expect something like:

  • A test -mtime/-mmin +n is true if AGE>n with P=86400/60 and T0=TOMORROW 00:00 or NOW according to if -startday is used or not. (Note that it is not clear from the docs if RAGE > n should be used instead here : as stated the two conditions are not equivalent)


  • A test -mtime/-mmin -n is true if AGE < n with P=86400/60 and T0=TOMORROW 00:00 or NOW according to if -startday is used or not. (Note that RAGE < n is  equivalent to AGE <n, so no ambiguity here)


test setup


To test my expectations I created the following files

  • x0 modified at T0 + epsi0
  • x1 modified at T0 - P/2 + epsi1
  • x2 modified at T0 - P + epsi2
  • x3 modified at T0 - 3/2 P + epsi3
  • x4 modified at T0 - 2 P + epsi4
  • x5 modified at T0 - 5/2 P + epsi5


with P=86400 for -mtime and P=60 for -mmin and I run the attached test (bash script).

The epsiN  are small "errors", ideally zero but positive in practice. They are due to the flow of time (find is executed after the execution of the commands that create the files). The epsiN are larger when -daystart is not used: they seem to have an effect in this case.

results


A Markdown file with a summary of the results is attached, but summarizing the summary:

1) '-mmin n' and '-daystart -mmin n' with n unsigned gave UNEXPECTED results (compatible with a one-minute left shift error in the definition of T0).

2) '-daystart -mtime -2' and '-mtime -2' finds x4,x3,x2,x1,x0 instead of x3,x2,x1,x0. UNEXPECTED because AGE(x4) = 2 + epsilon

3) Similarly '-daystart -mtime -1' and '-mtime -1' finds x2,x1,x0 instead of x1,x0. UNEXPECTED because AGE(x2) = 1 + epsilon

4) '-mtime -2 -mtime +1' finds x4 instead of x3: UNEXPECTED

5) '-mtime +2' finds x5, x4 instead of x5 but this could be due to the fact that AGE(x4) is not precisely 2 due  to the flow of time in setup.

All the rest agreed with my expectation stated above.

Hope this can help in some way.

Sorry if I missed some important point (hope my report could convince to improve the related docs, anyway).

[1] https://www.gnu.org/software/findutils/manual/html_mono
[2] https://en.wikipedia.org/wiki/Floor_and_ceiling_functions
[3] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/find.html

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55725:  test-setup.pdf added by None (112KiB - application/pdf)
file #55722:  find-time-tests.bash added by None (5KiB - application/octet-stream)
file #55723:  summary-find-time-tests-results.md added by None (2KiB - text/markdown)
file #55724:  find-time-tests.out added by None (11KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-02-20 None Attached File- Added test-setup.pdf, #55725
    2024-02-20 None Attached File- Added find-time-tests.bash, #55722
        Attached File- Added summary-find-time-tests-results.md, #55723
        Attached File- Added find-time-tests.out, #55724

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code