commit c4940a901baabebaf4c171089a7e66fbfe197b8a from: Omar Polo date: Sat Aug 07 17:37:16 2021 UTC reorganize tests commit - 02fc4f5177135ba8a95b49b15bdc23d4480a9f61 commit + c4940a901baabebaf4c171089a7e66fbfe197b8a blob - 4df7427c5e3c0df79d7fb71e690a7aa2f7b5a0ca blob + 6063b75eeec9eb313d715b82a8cf28792d58816d --- regress/lib.9ps +++ regress/lib.9ps @@ -1,11 +1,5 @@ -# constants +include "consts.9ps" -const notag = -1:u16 -const msize = 4194304:u32 # 4*1024*1024 -const np2000 = "9P2000" - - - # 9p protocol proc version(msize, version) { @@ -17,7 +11,7 @@ proc attach(fid, afid, uname, aname) { } proc walk(fid, newfid, ...) { - send(Twalk, iota(), fid:u32, newfid:u32, ...:str) + send(Twalk, iota(), fid:u32, newfid:u32, ...) } @@ -29,7 +23,7 @@ proc mount(fid, path) { m = recv() assert ( - m.type == Tversion + m.type == Rversion m.tag == notag m.msize == msize m.version == version @@ -44,7 +38,7 @@ proc mount(fid, path) { ) } -proc should-fail() { +proc expect-error() { m = recv() assert m.type == Rerror debug("got expected error", m) blob - /dev/null blob + 02c0f1056e32015f8c1c76e21286a2684cc3d2dd (mode 644) --- /dev/null +++ regress/consts.9ps @@ -0,0 +1,39 @@ +const ( + np2000 = "9P2000" + msize = 4194304:u32 # 4*1024*1024 + notag = -1:u16 + nofid = -1:u32 + + QTDIR = 0x80 + # ... + QTFILE = 0x0 + + Tversion = 100:u8 + Rversion = 101:u8 + Tauth = 102:u8 + Rauth = 103:u8 + Tattach = 104:u8 + Rattach = 105:u8 + Terror = 106:u8 # illegal + Rerror = 107:u8 + Tflush = 108:u8 + Rflush = 109:u8 + Twalk = 110:u8 + Rwalk = 111:u8 + Topen = 112:u8 + Ropen = 113:u8 + Tcreate = 114:u8 + Rcreate = 115:u8 + Tread = 116:u8 + Rread = 117:u8 + Twrite = 118:u8 + Rwrite = 119:u8 + Tclunk = 120:u8 + Rclunk = 121:u8 + Tremove = 122:u8 + Rremove = 123:u8 + Tstat = 124:u8 + Rstat = 125:u8 + Twstat = 126:u8 + Rwstat = 127:u8 +) blob - 55f350600c185c6570a39049b569f214bf21baa0 (mode 644) blob + /dev/null --- regress/super-simple.9ps +++ /dev/null @@ -1,26 +0,0 @@ -const ( - version = "9P2000" - msize = 4194304:u32 - notag = -1:u16 - - Tversion = 100:u8 - Rversion = 101:u8 -) - -testing "if version works" dir "./root" { - send(Tversion, notag, msize, version) - m = recv() - assert m.type == Rversion - # print("the response is", m) -} - -testing "fails when sending a R-message" dir "./root" should-fail { - send(Rversion, notag, msize, version) - # the client should close the connection - recv() -} - -testing "fails when sending a R-message (second try)" dir "./root" { - send(Rversion, notag, msize, version) - should-fail recv() : "the client should have closed the connection" -} blob - 3fd99676b0c179ef7cde6e3ffe3ddcb79e79b845 blob + 9f275e57f40e47cba532eb8ec571300063fb4000 --- regress/t.9ps +++ regress/t.9ps @@ -1,29 +1,33 @@ include "lib.9ps" -testing "walk with invalid fid" dir "./root" { - mount(0, "/") - walk(1, 2) - should-fail() +testing "if version works" dir "./root" { + send(Tversion, notag, msize, np2000) + m = recv() + assert m.type == Rversion } -testing "walk with invalid fid (multiple times)" dir "./root" { - mount(0, "/") - - repeat 10 { - walk(1, 2) - should-fail() - } +testing "fails when sending a R-message" dir "./root" { + send(Rversion, notag, msize, np2000) + should-fail recv() : "the connection should have been closed" } testing "walk to a directory" dir "./root" { + skip() # we can't parse Rwalks yet + mount(0, "/") walk(0, 1, "dir", "subdir") m = recv() - assert( - m.type == Rwalk, - m.nwqid == 2, - m.wqid.0.type == QTDIR, - m.wqid.1.type == QTDIR, + assert ( + m.type == Rwalk + m.nwqid == 2 + m.wqid.0.type == QTDIR + m.wqid.1.type == QTDIR ) } + +testing "walk with invalid fid" dir "./root" { + mount(0, "/") + walk(1, 2) + expect-error() +} blob - 6b74c0e607b64670f039d7d916f54619ee76c462 blob + c8fd066261c5e2830e8bf437cdc901ba21ddd9cd --- run-tests.sh +++ run-tests.sh @@ -6,4 +6,4 @@ set -e cd regress -./../ninepscript super-simple.9ps +./../ninepscript t.9ps