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

os.Open API fixes for examplelib.

parent ffda34eb
...@@ -23,7 +23,7 @@ func TestMultiZipFs(t *testing.T) { ...@@ -23,7 +23,7 @@ func TestMultiZipFs(t *testing.T) {
go state.Loop(true) go state.Loop(true)
f, err := os.Open(mountPoint+"", os.O_RDONLY, 0) f, err := os.Open(mountPoint + "")
CheckSuccess(err) CheckSuccess(err)
names, err := f.Readdirnames(-1) names, err := f.Readdirnames(-1)
...@@ -35,16 +35,16 @@ func TestMultiZipFs(t *testing.T) { ...@@ -35,16 +35,16 @@ func TestMultiZipFs(t *testing.T) {
err = f.Close() err = f.Close()
CheckSuccess(err) CheckSuccess(err)
f, err = os.Open(mountPoint+"/random", os.O_WRONLY|os.O_CREATE, 0) f, err = os.Create(mountPoint + "/random")
if err == nil { if err == nil {
t.Error("Must fail writing in root.") t.Error("Must fail writing in root.")
} }
f, err = os.Open(mountPoint+"/config/zipmount", os.O_WRONLY, 0) f, err = os.OpenFile(mountPoint+"/config/zipmount", os.O_WRONLY, 0)
if err == nil { if err == nil {
t.Error("Must fail without O_CREATE") t.Error("Must fail without O_CREATE")
} }
f, err = os.Open(mountPoint+"/config/zipmount", os.O_WRONLY|os.O_CREATE, 0) f, err = os.Create(mountPoint + "/config/zipmount")
CheckSuccess(err) CheckSuccess(err)
// Directory exists, but is empty. // Directory exists, but is empty.
......
...@@ -76,7 +76,7 @@ func (me *stackFsTestCase) Cleanup() { ...@@ -76,7 +76,7 @@ func (me *stackFsTestCase) Cleanup() {
func (me *stackFsTestCase) testReaddir() { func (me *stackFsTestCase) testReaddir() {
fmt.Println("testReaddir... ") fmt.Println("testReaddir... ")
dir, err := os.Open(me.mountDir, os.O_RDONLY, 0) dir, err := os.Open(me.mountDir)
CheckSuccess(err) CheckSuccess(err)
infos, err := dir.Readdir(10) infos, err := dir.Readdir(10)
CheckSuccess(err) CheckSuccess(err)
...@@ -114,13 +114,13 @@ func (me *stackFsTestCase) testSubFs() { ...@@ -114,13 +114,13 @@ func (me *stackFsTestCase) testSubFs() {
mountFile := filepath.Join(mount, name) mountFile := filepath.Join(mount, name)
f, err := os.Open(mountFile, os.O_WRONLY, 0) f, err := os.OpenFile(mountFile, os.O_WRONLY, 0)
if err == nil { if err == nil {
me.tester.Errorf("Expected error for open write %v", name) me.tester.Errorf("Expected error for open write %v", name)
continue continue
} }
content1 := "booh!" content1 := "booh!"
f, err = os.Open(mountFile, os.O_WRONLY|os.O_CREATE, magicMode) f, err = os.Create(mountFile)
CheckSuccess(err) CheckSuccess(err)
f.Write([]byte(content1)) f.Write([]byte(content1))
...@@ -135,7 +135,7 @@ func (me *stackFsTestCase) testSubFs() { ...@@ -135,7 +135,7 @@ func (me *stackFsTestCase) testSubFs() {
me.tester.Errorf("Mode %o", fi.Mode) me.tester.Errorf("Mode %o", fi.Mode)
} }
g, err := os.Open(mountFile, os.O_RDONLY, 0) g, err := os.Open(mountFile)
CheckSuccess(err) CheckSuccess(err)
buf := make([]byte, 1024) buf := make([]byte, 1024)
...@@ -177,7 +177,7 @@ func (me *stackFsTestCase) testAddRemove() { ...@@ -177,7 +177,7 @@ func (me *stackFsTestCase) testAddRemove() {
if fs == nil { if fs == nil {
me.tester.Errorf("remove fail") me.tester.Errorf("remove fail")
} }
dir, err := os.Open(me.mountDir, os.O_RDONLY, 0) dir, err := os.Open(me.mountDir)
CheckSuccess(err) CheckSuccess(err)
infos, err := dir.Readdir(10) infos, err := dir.Readdir(10)
CheckSuccess(err) CheckSuccess(err)
...@@ -186,7 +186,7 @@ func (me *stackFsTestCase) testAddRemove() { ...@@ -186,7 +186,7 @@ func (me *stackFsTestCase) testAddRemove() {
} }
dir.Close() dir.Close()
_, err = os.Open(filepath.Join(me.mountDir, "third"), os.O_RDONLY, 0) _, err = os.Open(filepath.Join(me.mountDir, "third"))
if err == nil { if err == nil {
me.tester.Errorf("expect enoent %v", err) me.tester.Errorf("expect enoent %v", err)
} }
......
...@@ -19,7 +19,7 @@ func TestZipFs(t *testing.T) { ...@@ -19,7 +19,7 @@ func TestZipFs(t *testing.T) {
go state.Loop(false) go state.Loop(false)
d, err := os.Open(mountPoint, os.O_RDONLY, 0) d, err := os.Open(mountPoint)
CheckSuccess(err) CheckSuccess(err)
names, err := d.Readdirnames(-1) names, err := d.Readdirnames(-1)
...@@ -43,7 +43,7 @@ func TestZipFs(t *testing.T) { ...@@ -43,7 +43,7 @@ func TestZipFs(t *testing.T) {
t.Error("file type", fi) t.Error("file type", fi)
} }
f, err := os.Open(mountPoint+"/file.txt", os.O_RDONLY, 0) f, err := os.Open(mountPoint + "/file.txt")
CheckSuccess(err) CheckSuccess(err)
b := make([]byte, 1024) b := make([]byte, 1024)
......
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