aboutsummaryrefslogtreecommitdiffstats
path: root/sys/fuchsia/test/stream
blob: ed4b1cbe7894c665c2a707445213616ba9929977 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
zx_vmo_create(0x100, 0x0, &AUTO=<r0=>0x0)

# Create a read/write stream and initialize the seek offset to 0.

zx_stream_create(0x3, r0, 0x0, &AUTO=<r1=>0x0)

# Write to the stream, first in write mode, then in append mode.

zx_stream_writev(r1, 0x0, &AUTO=[{&AUTO='abcd', 0x4}, {&AUTO='efg', 0x3}], 0x2, &AUTO)
zx_stream_writev(r1, 0x1, &AUTO=[{&AUTO='hi', 0x2}], 0x1, &AUTO)

# Attempt to write with an invalid input pointer.

zx_stream_writev(r1, 0x1, 0x0, 0x1, &AUTO) # ZX_ERR_INVALID_ARGS

# Read from the stream.

zx_stream_readv(r1, 0x0, &AUTO, 0x1, &AUTO)

# Move the cursor back to the beginning of the stream.
# Seek forward 1 byte from the current position in the stream.
# Seeking fails if the offset (after wrapping around) falls before the beginning of the stream.
# Seek to an offset past the current end of the stream.

zx_stream_seek(r1, 0x0, 0x0, &AUTO)
zx_stream_seek(r1, 0x1, 0x1, &AUTO)
zx_stream_seek(r1, 0x0, 0xffffffffffffffff, &AUTO) # ZX_ERR_INVALID_ARGS
zx_stream_seek(r1, 0x1, 0xfffffffffffffffe, &AUTO) # ZX_ERR_INVALID_ARGS
zx_stream_seek(r1, 0x2, 0x1, &AUTO=<r2=>0x0)

# With the cursor after the end of the stream, read and write some bytes.

zx_stream_readv_at(r1, 0x0, r2, &AUTO, 0x1, &AUTO)
zx_stream_writev_at(r1, 0x0, r2, &AUTO=[{&AUTO='jk', 0x2}], 0x1, &AUTO)