Commit e3aa8032 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: use writeOrig

parent 962c5624
...@@ -172,9 +172,7 @@ func TestFileTruncate(t *testing.T) { ...@@ -172,9 +172,7 @@ func TestFileTruncate(t *testing.T) {
content := []byte("hello world") content := []byte("hello world")
if err := ioutil.WriteFile(tc.origDir+"/file", content, 0755); err != nil { tc.writeOrig("file", string(content), 0755)
t.Fatalf("WriteFile: %v", err)
}
f, err := os.OpenFile(tc.mntDir+"/file", os.O_RDWR, 0644) f, err := os.OpenFile(tc.mntDir+"/file", os.O_RDWR, 0644)
if err != nil { if err != nil {
...@@ -206,11 +204,7 @@ func TestFileFdLeak(t *testing.T) { ...@@ -206,11 +204,7 @@ func TestFileFdLeak(t *testing.T) {
} }
}() }()
content := []byte("hello world") tc.writeOrig("file", "hello world", 0755)
if err := ioutil.WriteFile(tc.origDir+"/file", content, 0755); err != nil {
t.Fatalf("WriteFile: %v", err)
}
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {
if _, err := ioutil.ReadFile(tc.mntDir + "/file"); err != nil { if _, err := ioutil.ReadFile(tc.mntDir + "/file"); err != nil {
...@@ -264,14 +258,10 @@ func testRenameOverwrite(t *testing.T, destExists bool) { ...@@ -264,14 +258,10 @@ func testRenameOverwrite(t *testing.T, destExists bool) {
if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil { if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil {
t.Fatalf("Mkdir: %v", err) t.Fatalf("Mkdir: %v", err)
} }
if err := ioutil.WriteFile(tc.origDir+"/file", []byte("hello"), 0644); err != nil { tc.writeOrig("file", "hello", 0644)
t.Fatalf("WriteFile: %v", err)
}
if destExists { if destExists {
if err := ioutil.WriteFile(tc.origDir+"/dir/renamed", []byte("xx"), 0644); err != nil { tc.writeOrig("/dir/renamed", "xx", 0644)
t.Fatalf("WriteFile: %v", err)
}
} }
st := syscall.Stat_t{} st := syscall.Stat_t{}
...@@ -311,12 +301,8 @@ func TestRenameNoOverwrite(t *testing.T) { ...@@ -311,12 +301,8 @@ func TestRenameNoOverwrite(t *testing.T) {
if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil { if err := os.Mkdir(tc.origDir+"/dir", 0755); err != nil {
t.Fatalf("Mkdir: %v", err) t.Fatalf("Mkdir: %v", err)
} }
if err := ioutil.WriteFile(tc.origDir+"/file", []byte("hello"), 0644); err != nil { tc.writeOrig("file", "hello", 0644)
t.Fatalf("WriteFile: %v", err) tc.writeOrig("dir/file", "x", 0644)
}
if err := ioutil.WriteFile(tc.origDir+"/dir/file", []byte("x"), 0644); err != nil {
t.Fatalf("WriteFile: %v", err)
}
f1, err := syscall.Open(tc.mntDir+"/", syscall.O_DIRECTORY, 0) f1, err := syscall.Open(tc.mntDir+"/", syscall.O_DIRECTORY, 0)
if err != nil { if err != nil {
...@@ -463,9 +449,7 @@ func TestNotifyEntry(t *testing.T) { ...@@ -463,9 +449,7 @@ func TestNotifyEntry(t *testing.T) {
orig := tc.origDir + "/file" orig := tc.origDir + "/file"
fn := tc.mntDir + "/file" fn := tc.mntDir + "/file"
if err := ioutil.WriteFile(orig, []byte("hello"), 0644); err != nil { tc.writeOrig("file", "hello", 0644)
t.Fatalf("WriteFile: %v", err)
}
st := syscall.Stat_t{} st := syscall.Stat_t{}
if err := syscall.Lstat(fn, &st); err != nil { if err := syscall.Lstat(fn, &st); err != nil {
...@@ -514,9 +498,7 @@ func TestReadDir(t *testing.T) { ...@@ -514,9 +498,7 @@ func TestReadDir(t *testing.T) {
// 4096 page. // 4096 page.
nm := fmt.Sprintf("file%036x", i) nm := fmt.Sprintf("file%036x", i)
want[nm] = true want[nm] = true
if err := ioutil.WriteFile(tc.origDir+"/"+nm, []byte("hello"), 0644); err != nil { tc.writeOrig(nm, "hello", 0644)
t.Fatalf("WriteFile: %v", err)
}
} }
names, err := f.Readdirnames(-1) names, err := f.Readdirnames(-1)
......
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