(t *testing.T, cacheMode vfscommon.CacheMode, open bool, write bool)
| 89 | } |
| 90 | |
| 91 | func testFileSetModTime(t *testing.T, cacheMode vfscommon.CacheMode, open bool, write bool) { |
| 92 | if !canSetModTimeValue { |
| 93 | t.Skip("can't set mod time") |
| 94 | } |
| 95 | r, vfs, file, file1 := fileCreate(t, cacheMode) |
| 96 | if !canSetModTime(t, r) { |
| 97 | t.Skip("can't set mod time") |
| 98 | } |
| 99 | |
| 100 | var ( |
| 101 | err error |
| 102 | fd Handle |
| 103 | contents = "file1 contents" |
| 104 | ) |
| 105 | if open { |
| 106 | // Open with write intent |
| 107 | if cacheMode != vfscommon.CacheModeOff { |
| 108 | fd, err = file.Open(os.O_WRONLY) |
| 109 | if write { |
| 110 | contents = "hello contents" |
| 111 | } |
| 112 | } else { |
| 113 | // Can't write without O_TRUNC with CacheMode Off |
| 114 | fd, err = file.Open(os.O_WRONLY | os.O_TRUNC) |
| 115 | if write { |
| 116 | contents = "hello" |
| 117 | } else { |
| 118 | contents = "" |
| 119 | } |
| 120 | } |
| 121 | require.NoError(t, err) |
| 122 | |
| 123 | // Write some data |
| 124 | if write { |
| 125 | _, err = fd.WriteString("hello") |
| 126 | require.NoError(t, err) |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | err = file.SetModTime(t2) |
| 131 | require.NoError(t, err) |
| 132 | |
| 133 | if open { |
| 134 | require.NoError(t, fd.Close()) |
| 135 | vfs.WaitForWriters(waitForWritersDelay) |
| 136 | } |
| 137 | |
| 138 | file1 = fstest.NewItem(file1.Path, contents, t2) |
| 139 | r.CheckRemoteItems(t, file1) |
| 140 | |
| 141 | vfs.Opt.ReadOnly = true |
| 142 | err = file.SetModTime(t2) |
| 143 | assert.Equal(t, EROFS, err) |
| 144 | } |
| 145 | |
| 146 | // Test various combinations of setting mod times with and |
| 147 | // without the cache and with and without opening or writing |
no test coverage detected
searching dependent graphs…