-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
tests/by-util/test_df.rs uses a very naive way of calculating computed_percentage, essentially adding the reported_used to reported_avail to get the total memory to calculate the percentage used.
This leads to this particular test failing on some machines depending on their settings / disk space usage, like:
$ df --total --block-size=1
Filesystem 1B-blocks Used Available Use% Mounted on
efivarfs 253852 164372 84360 67% /sys/firmware/efi/efivarsWe can plainly see that this would give us ~64.75%, not 67%.
As explained in Coreutils FAQ, the tool is not intended to work this way (thanks to @cakebaker for pointing this out!):
The most natural thing in the world is to add the values of Used plus Available and expect to have a result that equals Size. But as we see here 35847132 plus 2651768 is not equal to 40559188 and is missing aproximately 2G of disk. Where did it go?
This data is in the minfree percentage of reserved filesystem disk blocks. A typical filesystem value for minfree is 5% reserved to superuser processes. Root can make use of all of the disk space but non-root processes will be restricted by the minfree value. If a user or user process fills up a partition the root user can still create files within the provided space.
We will need to rewrite this test to account for the minfree behavior. I should be able to do that either today or tomorrow.