summaryrefslogtreecommitdiff
path: root/lib9p/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/tests')
-rw-r--r--lib9p/tests/testclient-sess.c50
-rw-r--r--lib9p/tests/testclient-sess.explog49
2 files changed, 99 insertions, 0 deletions
diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c
index 764168d..ded70d1 100644
--- a/lib9p/tests/testclient-sess.c
+++ b/lib9p/tests/testclient-sess.c
@@ -112,6 +112,56 @@ int main(int argc, char *argv[]) {
send9p(Tread, .tag=0, .fid=3, .offset=0, .count=100);
recv9p(); /* Rread */
+ /* walk ***************************************************************/
+ send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000"));
+ recv9p(); /* Rversion */
+ ctx.version = LIB9P_VER_9P2000;
+ send9p(Tattach, .tag=0, .fid=0, .afid=LIB9P_FID_NOFID, .uname=lib9p_str("nobody"), .aname=lib9p_str(""));
+ recv9p(); /* Rattach */
+
+ /* dup */
+ send9p(Twalk, .tag=0, .fid=0, .newfid=1, .nwname=0);
+ recv9p(); /* Rwalk */
+
+ /* "The walk request carries as arguments an existing fid"... */
+ send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=0);
+ recv9p(); /* Rerror */
+
+ /* ..."and a proposed newfid"... */
+ send9p(Twalk, .tag=0, .fid=1, .newfid=0xffffffff, .nwname=0);
+ recv9p(); /* Rerror */
+
+ /* ..."(which must not be in use"... */
+ send9p(Twalk, .tag=0, .fid=1, .newfid=0, .nwname=0);
+ recv9p(); /* Rerror */
+
+ /* ..."unless it is the same as fid)"... */
+ send9p(Twalk, .tag=0, .fid=1, .newfid=1, .nwname=0);
+ recv9p(); /* Rwalk */
+
+ /* ... "that the client wishes to associate with the result of
+ * traversing the directory hierarchy by `walking' the heierarchy using
+ * the successive path name elements wname."... */
+
+ /* ..."The fid must represent a directory"... */
+ wname[0] = lib9p_str("README.md"); send9p(Twalk, .tag=0, .fid=1, .newfid=2, .nwname=1, .wname=wname);
+ recv9p(); /* Rwalk */
+ wname[0] = lib9p_str(".."); send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=1, .wname=wname);
+ recv9p(); /* Rerror */
+
+ /* ..."unless zero path name elements are specified." */
+ send9p(Twalk, .tag=0, .fid=2, .newfid=3, .nwname=0);
+ recv9p(); /* Rwalk */
+
+ /* "The fid must be valid in the current session" (tested above)... */
+
+ /* ..."and must not have been opened for I/O by an open or create
+ * message."... */
+ send9p(Topen, .tag=0, .fid=3, .mode=LIB9P_O_MODE_READ);
+ recv9p(); /* Ropen */
+ send9p(Twalk, .tag=0, .fid=3, .newfid=4, .nwname=0);
+ recv9p(); /* Rerror */
+
/* flush **************************************************************/
send9p(Tversion, .tag=0, .max_msg_size=(8*1024), .version=lib9p_str("9P2000"));
recv9p(); /* Rversion */
diff --git a/lib9p/tests/testclient-sess.explog b/lib9p/tests/testclient-sess.explog
index 268da72..3e2209a 100644
--- a/lib9p/tests/testclient-sess.explog
+++ b/lib9p/tests/testclient-sess.explog
@@ -31,6 +31,55 @@
> Tread { tag=0 fid=3 offset=0 count=100 }
< Rread { tag=0 count=9 data="1001 bob\n" }
+# walk #########################################################################
+> Tversion { tag=0 max_msg_size=8192 version="9P2000" }
+< Rversion { tag=0 max_msg_size=4120 version="9P2000" }
+> Tattach { tag=0 fid=0 afid=NOFID uname="nobody" aname="" n_uid=0 }
+< Rattach { tag=0 qid={ type=(DIR) vers=1 path=1 } }
+
+# dup
+> Twalk { tag=0 fid=0 newfid=1 nwname=0 wname=[ ] }
+< Rwalk { tag=0 nwqid=0 wqid=[ ] }
+
+# "The walk request carries as arguments an existing fid"...
+> Twalk { tag=0 fid=2 newfid=3 nwname=0 wname=[ ] }
+< Rerror { tag=0 errstr="bad file number 2" errnum=L_EBADF }
+
+# ..."and a proposed newfid"...
+> Twalk { tag=0 fid=1 newfid=NOFID nwname=0 wname=[ ] }
+< Rerror { tag=0 errstr="cannot assign to NOFID" errnum=L_EBADF }
+
+# ..."(which must not be in use"...
+> Twalk { tag=0 fid=1 newfid=0 nwname=0 wname=[ ] }
+< Rerror { tag=0 errstr="FID already in use" errnum=L_EBADF }
+
+# ..."unless it is the same as fid)"...
+> Twalk { tag=0 fid=1 newfid=1 nwname=0 wname=[ ] }
+< Rwalk { tag=0 nwqid=0 wqid=[ ] }
+
+# ... "that the client wishes to associate with the result of
+# traversing the directory hierarchy by `walking' the heierarchy using
+# the successive path name elements wname."...
+
+# ..."The fid must represent a directory"...
+> Twalk { tag=0 fid=1 newfid=2 nwname=1 wname=[ "README.md" ] }
+< Rwalk { tag=0 nwqid=1 wqid=[ { type=(0) vers=1 path=4 } ] }
+> Twalk { tag=0 fid=2 newfid=3 nwname=1 wname=[ ".." ] }
+< Rerror { tag=0 errstr="not a directory" errnum=L_ENOTDIR }
+
+# ..."unless zero path name elements are specified."
+> Twalk { tag=0 fid=2 newfid=3 nwname=0 wname=[ ] }
+< Rwalk { tag=0 nwqid=0 wqid=[ ] }
+
+# "The fid must be valid in the current session" (tested above)...
+
+# ..."and must not have been opened for I/O by an open or create
+# message."...
+> Topen { tag=0 fid=3 mode=(MODE_READ) }
+< Ropen { tag=0 qid={ type=(0) vers=1 path=4 } iounit=0 }
+> Twalk { tag=0 fid=3 newfid=4 nwname=0 wname=[ ] }
+< Rerror { tag=0 errstr="cannot walk on FID open for I/O" errnum=L_EALREADY }
+
# flush ########################################################################
> Tversion { tag=0 max_msg_size=8192 version="9P2000" }
< Rversion { tag=0 max_msg_size=4120 version="9P2000" }