MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_cirbuf_align_right

Function test_cirbuf_align_right

dpdk/app/test/test_cmdline_cirbuf.c:989–1177  ·  view source on GitHub ↗

test right alignment */

Source from the content-addressed store, hash-verified

987
988/* test right alignment */
989static int
990test_cirbuf_align_right(void)
991{
992#define END_OFFSET CMDLINE_TEST_BUFSIZE - 1
993 struct cirbuf cb;
994 char buf[CMDLINE_TEST_BUFSIZE];
995 char tmp[CMDLINE_TEST_BUFSIZE];
996 unsigned i;
997
998
999 /*
1000 * align right when start < end and start in left half
1001 */
1002
1003 /*
1004 * initialize circular buffer
1005 */
1006 memset(buf, 0, sizeof(buf));
1007 if (cirbuf_init(&cb, buf, 0, sizeof(buf)) < 0) {
1008 printf("Error: failed to initialize circular buffer!\n");
1009 return -1;
1010 }
1011
1012 /* push end into left half */
1013 for (i = 0; i < HALF_OFFSET - 1; i++)
1014 cirbuf_add_tail_safe(&cb, 't');
1015
1016 /* push start into left half < end */
1017 for (i = 0; i < SMALL_OFFSET; i++)
1018 cirbuf_del_head_safe(&cb);
1019
1020 /* align */
1021 cirbuf_align_right(&cb);
1022
1023 /* verify result */
1024 if (cb.start != END_OFFSET || cb.len != LEN1 || cb.end != cb.len - 2) {
1025 printf("Error: buffer alignment is wrong!\n");
1026 return -1;
1027 }
1028
1029 /*
1030 * align right when start > end and start in left half
1031 */
1032
1033 /*
1034 * reinitialize circular buffer
1035 */
1036 memset(buf, 0, sizeof(buf));
1037 if (cirbuf_init(&cb, buf, 0, sizeof(buf)) < 0) {
1038 printf("Error: failed to reinitialize circular buffer!\n");
1039 return -1;
1040 }
1041
1042 /* push start into left half */
1043 for (i = 0; i < HALF_OFFSET + 2; i++)
1044 cirbuf_add_head_safe(&cb, 'h');
1045
1046 /* push end into left half > start */

Callers 1

test_cirbuf_alignFunction · 0.85

Calls 13

memsetFunction · 0.85
cirbuf_initFunction · 0.85
cirbuf_add_tail_safeFunction · 0.85
cirbuf_del_head_safeFunction · 0.85
cirbuf_align_rightFunction · 0.85
cirbuf_add_head_safeFunction · 0.85
cirbuf_del_tail_safeFunction · 0.85
cirbuf_add_buf_tailFunction · 0.85
cirbuf_add_buf_headFunction · 0.85
cirbuf_get_buf_headFunction · 0.85
strncmpFunction · 0.85
cirbuf_get_buf_tailFunction · 0.85

Tested by

no test coverage detected