-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix few Filesystem tests on FreeBSD #65059
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThe To ignore that, macOS has case insensitive filesystem by default but default filesystem (zfs) on FreeBSD is case sensitive. Some other tests they fail with
In that regard, FreeBSD is like macOS e.g. parameters for macOS
FreeBSD
The zfs shows one block used even if the file itself is empty. I did quick check and solaris seems to follow Linux e.g. "%b %B" and updated code should still work. cc: @Thefrank @rootwyrm @emaste
|
@wfurt, I think it depends on filesystem and flavor of tool. e.g. on illumos / OpenIndiana, the primary file system is zFS (supports sparse files, with holes). Running under vagrant+virtualbox, I get this: # create/touch empty files on zFS and vbox/vagrant filesystems
$ touch $HOME/foo
$ touch /vagrant/foo
# stat is preinstalled (from GNU coreutils)
$ stat -c "%b %B" $HOME/foo
1 512
$ stat -c "%b %B" /vagrant/foo
0 512
# but using the built-in du -A (apparent size)
$ du -A $HOME/foo
0 /export/home/vagrant/foo
$ du -A /vagrant/foo
0 /vagrant/foo zFS is also available on FreeBSD and Linux. |
I'm curious what the test is actually trying to check here - perhaps it is trying to test some option for creation that is just not applicable here? |
@emaste, it is calculating file size using stat(1) (num of blocks x block size). Then it is using that information in assertions during the FileStream APIs tests, that support "preallocation" (fallocate / F_ALLOCATEALL) feature. There are tests like these, which shell out the command to known system utilities (stat(1) in this case). If there is no utility we can use, we resort to C implementation (currently there are very few FFI calls for test-only cases but it is possible). In this case, I think it makes sense to exec the known command line utility, because that is how user will typically compare the size and expects certain result which these tests ensure. |
To clarify, the default filesystem on FreeBSD is not ZFS, it is UFS2. And within pipelines you should not have ZFS; it should be UFS2 + soft journalling.
Realistically we should break out this test into UFS, UFS2, and ZFS tests which pivot around fstyp or local equivalent checks. Solaris derivatives have UFS, FreeBSD from 3.0 has UFS2, Indiana has ZFS, and FreeBSD and Linux may have ZFS but do not use ZFS by default. And said ZFS may or may not be case sensitive and may or may not be doing sparse or zero. To be entirely clear, this does in fact mean that multiple OSes may have wildly different root file systems which are partially or fully supported despite being non-default. Honestly, this test always kind of bugged me, because it doesn't really have a way to pivot around non-default filesystems or non-default filesystem configurations and non-standard handling (i.e. OS X treats exFAT as case sensitive, even though that's not how FAT works.) |
src/libraries/System.IO.FileSystem/tests/FileStream/ctor_options.Unix.cs
Outdated
Show resolved
Hide resolved
I'm not sure how I end up with As far as the allocation: should we try to use |
We have initially used |
Awareness / capability absolutely should still be in there looking at the |
I did more testing on UFS and the current Many tests still fail here with
I'm inclined to open separate issue and disable failing tests agains it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @wfurt !
I was hoping to fix it with #47994. From the information that you have provided it seems that unlocking does not work as expected? The test is doing sth like this:
@wfurt is there any chance you could take a quick look and see what sys-calls are being performed for the following: using FileStream fs1 = File.Open(path, FileMode.Open, fileAccess, FileShare.ReadWrite);
fs1.Lock(0, 100);
fs1.Unlock(0, 100);
fs1.Lock(0, 100); |
I did what @adamsitnik asked for and I get:
from man page:
I did isolate the sequence as small repro: #include <sys/file.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main(int argc, char** argv)
{
struct flock fl;
int fd= open("/tmp/foo", O_RDWR|O_CLOEXEC);
int ret = lseek(fd, 0, SEEK_SET);
printf("Opened as %d\n", fd);
if (argc > 1) {
ret = flock(fd, LOCK_SH|LOCK_NB);
printf("flock finished with %d\n", ret);
}
fl.l_start = 0;
fl.l_len = 100;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
ret = fcntl(fd, F_SETLK, &fl);
printf("fcntl finished with %d and errno %d (%s)\n", ret, errno, strerror(errno));
return 0;
} if we skip the I noticed |
I open #65831 for further discussion about |
The
MoveDirectory_FailToMoveLowerCaseDirectoryWhenUpperCaseDirectoryExists
is technically wrong on Unix IMHO.The case sensitivity is determined by given filesystem not by the OS itself.
To ignore that, macOS has case insensitive filesystem by default but default filesystem (zfs) on FreeBSD is case sensitive.
This seems like old oversight assuming (somewhat correctly) similarity between FreeBSD and macOS
Some other tests they fail with
In that regard, FreeBSD is like macOS e.g. parameters for
stat
are the same. I assumed easy fix but I was wrong.The behavior is somewhat different.
macOS
FreeBSD
The zfs shows one block used even if the file itself is empty.
To fix that I decided to use %z that simply returns allocated size on both macOS and FreeBSD
I did quick check and solaris seems to follow Linux e.g. "%b %B" and updated code should still work.
cc: @am11
cc: @Thefrank @rootwyrm @emaste