Lines Matching +full:commit +full:- +full:message

4  * SPDX-License-Identifier: Apache-2.0
17 * 212 - sizeof(struct spsc_pbuf) - 1 = 199.
18 * -1 because internal rd/wr_idx is reserved to mean the buffer is empty.
30 static uint8_t message[20] = {'a'}; in test_spsc_pbuf_flags() local
35 (sizeof(memory_area) - offsetof(struct spsc_pbuf, ext.cache.data)) : in test_spsc_pbuf_flags()
36 (sizeof(memory_area) - offsetof(struct spsc_pbuf, ext.nocache.data))) - in test_spsc_pbuf_flags()
46 zassert_equal(rlen, -EINVAL); in test_spsc_pbuf_flags()
48 zassert_equal(rlen, -EINVAL); in test_spsc_pbuf_flags()
52 zassert_equal(rlen, -ENOMEM); in test_spsc_pbuf_flags()
59 wlen = spsc_pbuf_write(ib, message, sizeof(message)); in test_spsc_pbuf_flags()
60 zassert_equal(wlen, sizeof(message)); in test_spsc_pbuf_flags()
63 zassert_equal(rlen, sizeof(message)); in test_spsc_pbuf_flags()
68 int repeat = capacity / (sizeof(message) + sizeof(uint32_t)); in test_spsc_pbuf_flags()
71 wlen = spsc_pbuf_write(ib, message, sizeof(message)); in test_spsc_pbuf_flags()
72 zassert_equal(wlen, sizeof(message)); in test_spsc_pbuf_flags()
75 wlen = spsc_pbuf_write(ib, message, sizeof(message)); in test_spsc_pbuf_flags()
76 zassert_equal(wlen, -ENOMEM); in test_spsc_pbuf_flags()
78 /* Test reading with buf == NULL, should return len of the next message to read. */ in test_spsc_pbuf_flags()
80 zassert_equal(rlen, sizeof(message)); in test_spsc_pbuf_flags()
84 zassert_equal(rlen, -ENOMEM); in test_spsc_pbuf_flags()
89 zassert_equal(wlen, sizeof(message)); in test_spsc_pbuf_flags()
96 /* Write message that would be wrapped around. */ in test_spsc_pbuf_flags()
97 wlen = spsc_pbuf_write(ib, message, sizeof(message)); in test_spsc_pbuf_flags()
98 zassert_equal(wlen, sizeof(message)); in test_spsc_pbuf_flags()
100 /* Read wrapped message. */ in test_spsc_pbuf_flags()
102 zassert_equal(rlen, sizeof(message)); in test_spsc_pbuf_flags()
103 zassert_equal(message[0], 'a'); in test_spsc_pbuf_flags()
120 return -EINVAL; in check_buffer()
189 PACKET_WRITE(pb, 0, 0, 0, -EINVAL); in ZTEST()
192 PACKET_WRITE(pb, SPSC_PBUF_MAX_LEN, 0, 0, capacity - sizeof(uint32_t)); in ZTEST()
194 len1 = capacity - 8 - 2 * sizeof(uint32_t); in ZTEST()
198 len2 = capacity - TLEN(len1) - HDR_LEN; in ZTEST()
220 len1 = capacity - 10 - sizeof(uint16_t); in ZTEST()
221 PACKET_WRITE(pb, len1, len1 - 5, 0, len1); in ZTEST()
223 len2 = 10 - sizeof(uint16_t) - 1; in ZTEST()
227 PACKET_CONSUME(pb, len1 - 5, 0); in ZTEST()
242 len2 = capacity - TLEN(len1) - 10; in ZTEST()
258 len2 = len1 + len2 - sizeof(uint16_t); in ZTEST()
275 /* Commit 5 byte packet. */ in ZTEST()
283 uint16_t exp_len2 = capacity - TLEN(len1) - HDR_LEN; in ZTEST()
309 /* Commit 16 byte packet. */ in ZTEST()
314 len2 = capacity - TLEN(len1) - HDR_LEN - 5; in ZTEST()
333 uint16_t exp_len = capacity - TLEN(len1) - HDR_LEN; in ZTEST()
353 len2 = capacity - TLEN(len1) - TLEN(10); in ZTEST()
358 PACKET_WRITE(pb, SPSC_PBUF_MAX_LEN - 1, 0, 1, 12); in ZTEST()
367 len2 = capacity - TLEN(len1) - TLEN(12); in ZTEST()
370 PACKET_WRITE(pb, SPSC_PBUF_MAX_LEN - 1, 0, 1, 12); in ZTEST()
384 zassert_equal(spsc_pbuf_get_utilization(pb), -ENOTSUP); in ZTEST()
404 len3 = capacity - TLEN(len1) - TLEN(len2); in ZTEST()
430 len = spsc_pbuf_read(ctx->pbuf, buf, (uint16_t)sizeof(buf)); in stress_read()
436 zassert_true(false, "Unexpected error: %d, cnt:%d", len, ctx->read_cnt); in stress_read()
439 zassert_ok(check_buffer(buf, len, ctx->read_cnt)); in stress_read()
440 ctx->read_cnt++; in stress_read()
450 uint16_t len = 1 + (sys_rand16_get() % (ctx->capacity / 4)); in stress_write()
453 zassert_true(len < sizeof(buf), "len:%d %d", len, ctx->capacity); in stress_write()
456 memset(buf, (uint8_t)ctx->write_cnt, len); in stress_write()
457 if (spsc_pbuf_write(ctx->pbuf, buf, len) == len) { in stress_write()
458 ctx->write_cnt++; in stress_write()
460 ctx->wr_err++; in stress_write()
496 len = spsc_pbuf_claim(ctx->pbuf, &buf); in stress_claim_free()
502 zassert_ok(check_buffer(buf, len, ctx->read_cnt)); in stress_claim_free()
504 spsc_pbuf_free(ctx->pbuf, len); in stress_claim_free()
506 ctx->read_cnt++; in stress_claim_free()
516 uint16_t len = 1 + (rnd % (ctx->capacity / 4)); in stress_alloc_commit()
522 err = spsc_pbuf_alloc(ctx->pbuf, len, &buf); in stress_alloc_commit()
528 memset(buf, (uint8_t)ctx->write_cnt, len); in stress_alloc_commit()
530 spsc_pbuf_commit(ctx->pbuf, len); in stress_alloc_commit()
531 ctx->write_cnt++; in stress_alloc_commit()