summaryrefslogtreecommitdiff
path: root/lib9p/tests/testclient-sess.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-15 01:03:39 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-15 01:03:39 -0600
commit0450e14b3a86e4448537c03253eeebf509f8909e (patch)
treec3a38f842b610d0f72b9e1c0aba45c186b443bf0 /lib9p/tests/testclient-sess.c
parentb1fcc4ac2f244dddd869054db5dc6753c099a3e0 (diff)
parentab99adc111425dd93a062e67b19943860296ecca (diff)
Merge branch 'lukeshu/9p-fixes'HEADmain
Diffstat (limited to 'lib9p/tests/testclient-sess.c')
-rw-r--r--lib9p/tests/testclient-sess.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/lib9p/tests/testclient-sess.c b/lib9p/tests/testclient-sess.c
index 437c489..ded70d1 100644
--- a/lib9p/tests/testclient-sess.c
+++ b/lib9p/tests/testclient-sess.c
@@ -15,7 +15,7 @@
#include <libmisc/assert.h>
#include <libmisc/endian.h>
-#include <lib9p/9p.h>
+#include <lib9p/core.h>
#define MAX_MSG_SIZE (8*1024)
@@ -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 */