Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
270c526
Implement most of the fix for #38824
hamarb123 May 12, 2021
50d0b47
Merge remote-tracking branch 'upstream/main' into fixfor38824
hamarb123 Oct 20, 2021
952a168
Most of the code for PR #52639 to fix #38824
hamarb123 Oct 20, 2021
abdbbcb
Remove additional FILE_FLAG_OPEN_REPARSE_POINT
hamarb123 Oct 21, 2021
7dc1875
Add missing override keywords
hamarb123 Oct 21, 2021
41d23e2
Fix access modifiers
hamarb123 Oct 21, 2021
f603c3c
Merge remote-tracking branch 'upstream/main' into fixfor38824
hamarb123 Oct 21, 2021
0a87835
Add more symlink tests, rearrange files
hamarb123 Oct 26, 2021
606130b
Merge remote-tracking branch 'upstream/main' into fixfor38824
hamarb123 Oct 26, 2021
f8c4fd6
Fix return type of CreateSymlink in File/GetSetTimes.cs
hamarb123 Oct 26, 2021
060bf1c
Remove browser from new symlink tests as it doesn't support creation …
hamarb123 Oct 26, 2021
f4bac0c
Use lutimes, improve code readability, simplify tests
hamarb123 Oct 28, 2021
97d1ed3
Change year in test to 2014 to reduce diff
hamarb123 Oct 28, 2021
fd9d2d5
Rename symlink tests, use 1 core symlink times function, and check th…
hamarb123 Oct 28, 2021
1b7b868
Inline RunSymlinkTestPart 'function'
hamarb123 Oct 28, 2021
b8460ff
Share CreateSymlinkToItem call in tests and update comment for clarity
hamarb123 Oct 28, 2021
9bf86db
Update symlink time tests
hamarb123 Oct 29, 2021
5713e27
Remove unnecessary Assert.All
hamarb123 Oct 29, 2021
d50be1b
Changes to SettingUpdatesPropertiesOnSymlink test
hamarb123 Oct 30, 2021
d61060b
Merge remote-tracking branch 'upstream/main' into fixfor38824
hamarb123 Oct 30, 2021
a894d87
Remove unnecessary fsi.Refresh()
hamarb123 Oct 31, 2021
d8bff21
Updates to test and pal_time.c
hamarb123 Nov 5, 2021
3b37666
Merge remote-tracking branch 'upstream/main' into fixfor38824
hamarb123 Nov 5, 2021
569a24f
Remove trailing space
hamarb123 Nov 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updates to test and pal_time.c
• Remove targetIsRelative cases
• Multi-line if statement
• Combine HAVE_LUTIMES and #else conditions to allow more code charing
  • Loading branch information
hamarb123 committed Nov 5, 2021
commit d8bff217d3282b32875d0966fd64e3af9618b98d
16 changes: 7 additions & 9 deletions src/libraries/Native/Unix/System.Native/pal_time.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ int32_t SystemNative_UTimensat(const char* path, TimeSpec* times)
updatedTimes[1].tv_sec = (time_t)times[1].tv_sec;
updatedTimes[1].tv_nsec = (long)times[1].tv_nsec;
while (CheckInterrupted(result = utimensat(AT_FDCWD, path, updatedTimes, AT_SYMLINK_NOFOLLOW)));
#elif HAVE_LUTIMES
struct timeval updatedTimes[2];
updatedTimes[0].tv_sec = (long)times[0].tv_sec;
updatedTimes[0].tv_usec = (int)times[0].tv_nsec / 1000;

updatedTimes[1].tv_sec = (long)times[1].tv_sec;
updatedTimes[1].tv_usec = (int)times[1].tv_nsec / 1000;
while (CheckInterrupted(result = lutimes(path, updatedTimes)));
#else
struct timeval updatedTimes[2];
updatedTimes[0].tv_sec = (long)times[0].tv_sec;
updatedTimes[0].tv_usec = (int)times[0].tv_nsec / 1000;

updatedTimes[1].tv_sec = (long)times[1].tv_sec;
updatedTimes[1].tv_usec = (int)times[1].tv_nsec / 1000;
while (CheckInterrupted(result = utimes(path, updatedTimes)));
while (CheckInterrupted(result =
#if HAVE_LUTIMES
lutimes
#else
utimes
#endif
(path, updatedTimes)));
#endif

return result;
Expand Down
26 changes: 12 additions & 14 deletions src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public abstract class BaseGetSetTimes<T> : FileSystemTest

protected abstract T CreateSymlink(string path, string pathToTarget);

protected T CreateSymlinkToItem(T item, bool isRelative)
protected T CreateSymlinkToItem(T item)
{
// Creates a Symlink to 'item' (may or may not exist) that is optionally
// a relative path rather than an absolute path.
// Creates a Symlink to 'item' (target may or may not exist)
string itemPath = GetItemPath(item);
string target = isRelative ? Path.GetFileName(itemPath) : itemPath;
return CreateSymlink(itemPath + ".link", target);
return CreateSymlink(path: itemPath + ".link", pathToTarget: itemPath);
}

protected abstract string GetItemPath(T item);
Expand Down Expand Up @@ -88,26 +86,23 @@ public void SettingUpdatesProperties()

[Theory]
[PlatformSpecific(~TestPlatforms.Browser)] // Browser is excluded as it doesn't support symlinks
[InlineData(false, false)]
[InlineData(false, true)]
[InlineData(true, false)]
[InlineData(true, true)]
public void SettingUpdatesPropertiesOnSymlink(bool targetIsRelative, bool targetExists)
[InlineData(false)]
[InlineData(true)]
public void SettingUpdatesPropertiesOnSymlink(bool targetExists)
{
// This test is in this class since it needs all of the time functions.
// This test makes sure that the times are set on the symlink itself.
// It is needed as on OSX for example, the default for most APIs is
// to follow the symlink to completion and set the time on that entry
// instead (eg. the setattrlist will do this without the flag set).
// It is also the same case on unix, with the utimensat function.
// It is a theory since there are variants which have a relative target
// or absolute target, and whether the target exists or not.
// It is a theory since we test both the target existing and missing.

T target = targetExists ? GetExistingItem() : GetMissingItem();

// When the target exists, we want to verify that its times don't change.

T link = CreateSymlinkToItem(target, targetIsRelative);
T link = CreateSymlinkToItem(target);
if (!targetExists)
{
SettingUpdatesPropertiesCore(link);
Expand All @@ -121,7 +116,10 @@ public void SettingUpdatesPropertiesOnSymlink(bool targetIsRelative, bool target
SettingUpdatesPropertiesCore(link);

// Ensure that we have the latest times.
if (target is FileSystemInfo fsi) fsi.Refresh();
if (target is FileSystemInfo fsi)
{
fsi.Refresh();
}

// Ensure the target's times haven't changed.
DateTime[] updatedTimes = timeFunctions.Select((funcs) => funcs.Getter(target)).ToArray();
Expand Down