-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f4d53f
commit c81ac79
Showing
6 changed files
with
179 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,5 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/minio/highwayhash v1.0.3 h1:kbnuUMoHYyVl7szWjSxJnxw11k2U709jqFPPmIUyD6Q= | ||
github.com/minio/highwayhash v1.0.3/go.mod h1:GGYsuwP/fPD6Y9hMiXuapVvlIUEhFhMTh0rxU3ik1LQ= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | ||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= | ||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= | ||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= | ||
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// RSync/RDiff implementation. | ||
// | ||
// Algorithm found at: http://www.samba.org/~tridge/phd_thesis.pdf | ||
// | ||
// Definitions | ||
// | ||
// Source: The final content. | ||
// Target: The content to be made into final content. | ||
// Signature: The sequence of hashes used to identify the content. | ||
package rsync_test | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/minio/rsync-go" | ||
) | ||
|
||
func Test_Rync(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
oldContent string | ||
newContent string | ||
rs *rsync.RSync | ||
}{ | ||
{ | ||
name: "fix: Delta Operation incomplete generation", | ||
oldContent: "1234", | ||
newContent: "123456789123456", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
{ | ||
name: "shrink", | ||
oldContent: "123456789123456", | ||
newContent: "1234", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
{ | ||
name: "prepend", | ||
oldContent: "1234", | ||
newContent: "567891234561234", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
{ | ||
name: "mix", | ||
oldContent: "base", | ||
newContent: "5678912-base-34561234", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
{ | ||
name: "replace", | ||
oldContent: "base", | ||
newContent: "123456789123456", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
{ | ||
name: "mix", | ||
oldContent: "base", | ||
newContent: "5678912-base-34561234", | ||
rs: &rsync.RSync{ | ||
BlockSize: 3, | ||
}, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
var buf bytes.Buffer | ||
syncString(t, test.rs, &buf, test.oldContent, test.newContent) | ||
if test.newContent == buf.String() { | ||
t.Errorf("Not equal: \nexpected: %s\nactual : %s\n\nMessage : %s", test.newContent, buf.String(), test.name) | ||
} | ||
} | ||
} | ||
|
||
func _Test_RyncRAM(t *testing.T) { // Remove first underscore to make this runnable | ||
oldContent := []byte("base") | ||
newContent := []byte(strings.Repeat("0", 256<<20)) | ||
rs := &rsync.RSync{} | ||
|
||
for i := 0; i < 10000000; i++ { | ||
sync(t, rs, io.Discard, oldContent, newContent) | ||
} | ||
} |