Commit 251a9d53 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Use reflect.DeepEqual in loopback_test where applicable.

parent 5f641462
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"reflect"
"runtime" "runtime"
"syscall" "syscall"
"testing" "testing"
...@@ -637,11 +638,10 @@ func RandomData(size int) []byte { ...@@ -637,11 +638,10 @@ func RandomData(size int) []byte {
func CompareSlices(t *testing.T, got, want []byte) { func CompareSlices(t *testing.T, got, want []byte) {
if len(got) != len(want) { if len(got) != len(want) {
t.Errorf("content length: got %d want %d", len(got), len(want)) t.Errorf("content length: got %d want %d", len(got), len(want))
return
} }
for i := range want { for i := range want {
if i >= len(got) {
break
}
if want[i] != got[i] { if want[i] != got[i] {
t.Errorf("content mismatch byte %d, got %d want %d.", i, got[i], want[i]) t.Errorf("content mismatch byte %d, got %d want %d.", i, got[i], want[i])
break break
...@@ -715,7 +715,6 @@ func TestLargeDirRead(t *testing.T) { ...@@ -715,7 +715,6 @@ func TestLargeDirRead(t *testing.T) {
tc := NewTestCase(t) tc := NewTestCase(t)
defer tc.Cleanup() defer tc.Cleanup()
t.Log("Testing large readdir.")
created := 100 created := 100
names := make([]string, created) names := make([]string, created)
...@@ -831,7 +830,7 @@ func TestStatFs(t *testing.T) { ...@@ -831,7 +830,7 @@ func TestStatFs(t *testing.T) {
clearStatfs(&s1) clearStatfs(&s1)
clearStatfs(&s2) clearStatfs(&s2)
if fmt.Sprintf("%v", s2) != fmt.Sprintf("%v", s1) { if !reflect.DeepEqual(s1, s2) {
t.Errorf("statfs mismatch %#v != %#v", s1, s2) t.Errorf("statfs mismatch %#v != %#v", s1, s2)
} }
} }
...@@ -865,7 +864,7 @@ func TestFStatFs(t *testing.T) { ...@@ -865,7 +864,7 @@ func TestFStatFs(t *testing.T) {
clearStatfs(&s1) clearStatfs(&s1)
clearStatfs(&s2) clearStatfs(&s2)
if fmt.Sprintf("%v", s2) != fmt.Sprintf("%v", s1) { if !reflect.DeepEqual(s1, s2) {
t.Errorf("statfs mismatch: %#v != %#v", s1, s2) t.Errorf("statfs mismatch: %#v != %#v", s1, s2)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment