Harvey-OS / ninep

Package for implementing clients and servers of the 9P and 9P2000 distributed resource protocols in Go.
Other
39 stars 19 forks source link

filesystem: correctly return an error when a walk element fails. #15

Closed rminnich closed 8 years ago

rminnich commented 8 years ago

If a client walks a/b/c the server must return an array of QIDS for all three elements. If the walk fails at any point the server must return an error as well as an array of as many QIDS as it was able to walk.

Example: if only a/b exists, and the client tries to walk a/b/c, the server must return the QIDs for a and b as well as an error.

Somehow I forgot this. This fixes a problem we'd seen in harvey that was not a harvey problem. #294.

Signed-off-by: Ronald G. Minnich rminnich@gmail.com

harveybot commented 8 years ago

Please review this @hagna and @sevki

elbing commented 8 years ago

Marvelous, good catch,

hdonnay commented 8 years ago

fixed the test:

From 9efd5232e7101b86b023881e25c634e8ddeb6714 Mon Sep 17 00:00:00 2001
From: Hank Donnay <hdonnay@gmail.com>
Date: Mon, 19 Sep 2016 10:37:07 -0500
Subject: [PATCH] filesystem: fix test

Make sure an error is returned when walking to a nonexistent file.

Signed-off-by: Hank Donnay <hdonnay@gmail.com>
---
 filesystem/filesystem_test.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 2abb911..1cbc555 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -10,7 +10,7 @@ import (
    "strings"
    "testing"

-    "github.com/Harvey-OS/ninep/protocol"
+   "github.com/Harvey-OS/ninep/protocol"
 )

 func print(f string, args ...interface{}) {
@@ -106,8 +106,8 @@ func TestMount(t *testing.T) {

    t.Logf("Attach is %v", a)
    w, err := c.CallTwalk(0, 1, []string{"hi", "there"})
-   if err != nil {
-       t.Fatalf("CallTwalk(0,1,[\"hi\", \"there\"]): want nil, got %v", err)
+   if err == nil {
+       t.Fatalf("CallTwalk(0,1,[\"hi\", \"there\"]): want error, got nil")
    }
    if len(w) > 0 {
        t.Fatalf("CallTwalk(0,1,[\"hi\", \"there\"]): want 0 QIDs, got %v", w)
-- 
2.10.0
rminnich commented 8 years ago

Thanks hank! I did this on a crowded flight last night and just forgot to run the test.

rminnich commented 8 years ago

LGTM carrying forward from hank

Approved with PullApprove