Pure Erlang implementation of 9p2000 protocol
filesystem fs 9p2000 erlang 9p

Fix tests to fixed decoders

hauleth.dev c7f912d2 7c355cef

verified
+32 -9
+2 -1
src/e9p_msg.erl
··· 166 166 do_parse(Type, Data) -> 167 167 {error, {invalid_message, Type, Data}}. 168 168 169 - parse_stat(<<Type:2/?int, 169 + parse_stat(<<_Size:2/?int, 170 + Type:2/?int, 170 171 Dev:4/?int, 171 172 QID:13/binary, 172 173 Mode:4/?int,
+21 -2
test/e9p_msg_SUITE.erl
··· 11 11 -include_lib("stdlib/include/assert.hrl"). 12 12 -include_lib("common_test/include/ct.hrl"). 13 13 14 - all() -> [stat_encode_decode]. 14 + all() -> [stat_encode_decode, rstat_encode_decode]. 15 15 16 16 stat_encode_decode(_Conf) -> 17 17 Stat = #{ ··· 27 27 gid => <<>>, 28 28 muid => <<>> 29 29 }, 30 - <<Len:?len, Out:Len/binary>> = iolist_to_binary(e9p_msg:encode_stat(Stat)), 30 + Out = iolist_to_binary(e9p_msg:encode_stat(Stat)), 31 31 Decoded = e9p_msg:parse_stat(Out), 32 32 ?assertEqual({ok, Stat}, Decoded). 33 33 34 + rstat_encode_decode(_Conf) -> 35 + Stat = #{ 36 + type => 0, 37 + dev => 0, 38 + qid => e9p:make_qid(directory, 0, 0, []), 39 + mode => 0, 40 + atime => 0, 41 + mtime => 0, 42 + length => 0, 43 + name => <<>>, 44 + uid => <<>>, 45 + gid => <<>>, 46 + muid => <<>> 47 + }, 48 + Msg = #rstat{stat = Stat}, 49 + Tag = 1, 50 + Out = e9p_msg:encode(Tag, Msg), 51 + Decoded = e9p_msg:parse(iolist_to_binary(Out)), 52 + ?assertEqual({ok, Tag, Msg}, Decoded).
+9 -6
test/prop_e9p_msg.erl
··· 15 15 16 16 afid() -> int(2). 17 17 18 + bin_str() -> ?LET({Charlist}, {string()}, 19 + unicode:characters_to_binary(Charlist)). 20 + 18 21 prop_can_decode_encoded_tversion() -> 19 - ?FORALL({Version, MPS}, {binary(), afid()}, 22 + ?FORALL({Version, MPS}, {bin_str(), afid()}, 20 23 begin 21 24 enc_dec(#tversion{version = Version, max_packet_size = MPS}) 22 25 end). 23 26 24 27 prop_can_decode_encoded_rversion() -> 25 - ?FORALL({Version, MPS}, {binary(), afid()}, 28 + ?FORALL({Version, MPS}, {bin_str(), afid()}, 26 29 begin 27 30 enc_dec(#rversion{version = Version, max_packet_size = MPS}) 28 31 end). 29 32 30 33 prop_can_decode_encoded_tauth() -> 31 - ?FORALL({Afid, Uname, Aname}, {afid(), binary(), binary()}, 34 + ?FORALL({Afid, Uname, Aname}, {afid(), bin_str(), bin_str()}, 32 35 begin 33 36 enc_dec(#tauth{afid = Afid, uname = Uname, aname = Aname}) 34 37 end). 35 38 36 39 prop_can_decode_encoded_rerror() -> 37 - ?FORALL({Msg}, {binary()}, 40 + ?FORALL({Msg}, {bin_str()}, 38 41 begin 39 42 enc_dec(#rerror{msg = Msg}) 40 43 end). 41 44 42 45 prop_can_decode_encoded_rstat() -> 43 46 ?FORALL({Type, Dev, Mode, Atime, Mtime, Len, Name, Uid, Gid, Muid}, 44 - {int(2), int(2), int(4), int(4), int(4), int(8), binary(), binary(), 45 - binary(), binary()}, 47 + {int(2), int(2), int(4), int(4), int(4), int(8), bin_str(), bin_str(), 48 + bin_str(), bin_str()}, 46 49 begin 47 50 enc_dec(#rstat{ 48 51 stat = #{