@@ -163,4 +163,54 @@ void testQidSerialization() throws StyxException {
163163 buffer .get (data );
164164 assertArrayEquals (expected , data );
165165 }
166+
167+ @ Test
168+ void testSerializeStat () throws StyxException {
169+ StyxStat stat = new StyxStat (
170+ (short ) 1 ,
171+ 2 ,
172+ new StyxQID (QidType .QTFILE , 0x80 , 0x90 ),
173+ 0x01 ,
174+ new Date (1717171717L * 1000 ), // fixed date for reproducibility
175+ new Date (1717171717L * 1000 ),
176+ 0x123 ,
177+ "file" ,
178+ "user" ,
179+ "group" ,
180+ "editor"
181+ );
182+ BufferWriterImpl output = new BufferWriterImpl (8192 );
183+ serializer .serializeStat (stat , output );
184+
185+ // Validate buffer size and some expected values
186+ var buffer = output .getBuffer ();
187+ assertEquals (serializer .getStatSerializedSize (stat ), output .getPosition ());
188+
189+ byte [] expected = {
190+ 66 , 0x00 , // size - 2
191+ 1 , 0x00 , // type
192+ 0x02 , 0x00 , 0x00 , 0x00 , // dev
193+ (byte ) QidType .QTFILE ,
194+ (byte )0x80 , 0x00 , 0x00 , 0x00 , //9: qid.version[4]
195+ (byte )0x90 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , //13: qid.path[8] 0x12309E51049E5104L
196+ 0x01 , 0x00 , 0x00 , 0x00 , // mode
197+ 0x05 , (byte )0xF6 , 89 , 102 , // atime
198+ 0x05 , (byte )0xF6 , 89 , 102 , // mtime
199+ 0x23 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , // length
200+ 0x04 , 0x00 , // name length
201+ 'f' , 'i' , 'l' , 'e' , // name
202+ 0x04 , 0x00 , // uid length
203+ 'u' , 's' , 'e' , 'r' , // uid
204+ 0x05 , 0x00 , // gid length
205+ 'g' , 'r' , 'o' , 'u' , 'p' , // gid
206+ 0x06 , 0x00 , // muid length
207+ 'e' , 'd' , 'i' , 't' , 'o' , 'r' // muid
208+ };
209+
210+ buffer .flip ();
211+ byte [] data = new byte [buffer .limit ()];
212+ // buffer.position(0);
213+ buffer .get (data );
214+ assertArrayEquals (expected , data );
215+ }
166216}
0 commit comments