mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-08 23:08:27 +00:00
lib/model: Remove some testing deadlocks (#6138)
This commit is contained in:
parent
88244b0c1f
commit
85e6a77f25
@ -253,8 +253,22 @@ func TestCopierFinder(t *testing.T) {
|
|||||||
|
|
||||||
f.handleFile(requiredFile, copyChan, dbUpdateChan)
|
f.handleFile(requiredFile, copyChan, dbUpdateChan)
|
||||||
|
|
||||||
pulls := []pullBlockState{<-pullChan, <-pullChan, <-pullChan, <-pullChan}
|
timeout := time.After(10 * time.Second)
|
||||||
finish := <-finisherChan
|
pulls := make([]pullBlockState, 4)
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
select {
|
||||||
|
case pulls[i] = <-pullChan:
|
||||||
|
case <-timeout:
|
||||||
|
t.Fatalf("Timed out before receiving all 4 states on pullChan (already got %v)", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var finish *sharedPullerState
|
||||||
|
select {
|
||||||
|
case finish = <-finisherChan:
|
||||||
|
case <-timeout:
|
||||||
|
t.Fatal("Timed out before receiving 4 states on pullChan")
|
||||||
|
}
|
||||||
|
|
||||||
defer cleanupSharedPullerState(finish)
|
defer cleanupSharedPullerState(finish)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@ -3224,7 +3224,7 @@ func TestRequestLimit(t *testing.T) {
|
|||||||
go func() {
|
go func() {
|
||||||
second, err := m.Request(device1, "default", file, 2000, 0, nil, 0, false)
|
second, err := m.Request(device1, "default", file, 2000, 0, nil, 0, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Second request failed: %v", err)
|
t.Errorf("Second request failed: %v", err)
|
||||||
}
|
}
|
||||||
close(returned)
|
close(returned)
|
||||||
second.Close()
|
second.Close()
|
||||||
|
@ -244,31 +244,37 @@ func TestRequestVersioningSymlinkAttack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fc.mut.Unlock()
|
fc.mut.Unlock()
|
||||||
|
|
||||||
|
waitForIdx := func() {
|
||||||
|
select {
|
||||||
|
case c := <-idx:
|
||||||
|
if c == 0 {
|
||||||
|
t.Fatal("Got empty index update")
|
||||||
|
}
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatal("timed out before receiving index update")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send an update for the test file, wait for it to sync and be reported back.
|
// Send an update for the test file, wait for it to sync and be reported back.
|
||||||
fc.addFile("foo", 0644, protocol.FileInfoTypeSymlink, []byte(tmpdir))
|
fc.addFile("foo", 0644, protocol.FileInfoTypeSymlink, []byte(tmpdir))
|
||||||
fc.sendIndexUpdate()
|
fc.sendIndexUpdate()
|
||||||
|
waitForIdx()
|
||||||
for updates := 0; updates < 1; updates += <-idx {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the symlink, hoping for it to get versioned
|
// Delete the symlink, hoping for it to get versioned
|
||||||
fc.deleteFile("foo")
|
fc.deleteFile("foo")
|
||||||
fc.sendIndexUpdate()
|
fc.sendIndexUpdate()
|
||||||
for updates := 0; updates < 1; updates += <-idx {
|
waitForIdx()
|
||||||
}
|
|
||||||
|
|
||||||
// Recreate foo and a file in it with some data
|
// Recreate foo and a file in it with some data
|
||||||
fc.updateFile("foo", 0755, protocol.FileInfoTypeDirectory, nil)
|
fc.updateFile("foo", 0755, protocol.FileInfoTypeDirectory, nil)
|
||||||
fc.addFile("foo/test", 0644, protocol.FileInfoTypeFile, []byte("testtesttest"))
|
fc.addFile("foo/test", 0644, protocol.FileInfoTypeFile, []byte("testtesttest"))
|
||||||
fc.sendIndexUpdate()
|
fc.sendIndexUpdate()
|
||||||
for updates := 0; updates < 1; updates += <-idx {
|
waitForIdx()
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the test file and see if it escaped
|
// Remove the test file and see if it escaped
|
||||||
fc.deleteFile("foo/test")
|
fc.deleteFile("foo/test")
|
||||||
fc.sendIndexUpdate()
|
fc.sendIndexUpdate()
|
||||||
for updates := 0; updates < 1; updates += <-idx {
|
waitForIdx()
|
||||||
}
|
|
||||||
|
|
||||||
path := filepath.Join(tmpdir, "test")
|
path := filepath.Join(tmpdir, "test")
|
||||||
if _, err := os.Lstat(path); !os.IsNotExist(err) {
|
if _, err := os.Lstat(path); !os.IsNotExist(err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user