From: Florin Coras Date: Thu, 27 Jun 2019 04:11:26 +0000 (-0700) Subject: svm: improve fifo segment test X-Git-Tag: v20.01-rc0~305 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F20378%2F4;p=vpp.git svm: improve fifo segment test Type: feature Try to also catch weirdness when running tests on arm cpus. Change-Id: I45ab7c225f43623447271e67ebf37f94236a288f Signed-off-by: Florin Coras --- diff --git a/src/plugins/unittest/svm_fifo_test.c b/src/plugins/unittest/svm_fifo_test.c index a8f83faa586..bf633b78c22 100644 --- a/src/plugins/unittest/svm_fifo_test.c +++ b/src/plugins/unittest/svm_fifo_test.c @@ -1954,7 +1954,7 @@ sfifo_test_fifo_segment_fifo_grow (int verbose) clib_memset (a, 0, sizeof (*a)); a->segment_name = "fifo-test1"; /* size chosen to be able to force multi chunk allocation lower */ - a->segment_size = 208 << 10; + a->segment_size = 256 << 10; /* fifo allocation allocates chunks in batch */ n_batch = FIFO_SEGMENT_ALLOC_BATCH_SIZE; @@ -1978,6 +1978,7 @@ sfifo_test_fifo_segment_fifo_grow (int verbose) SFIFO_TEST (rv == (n_batch - 1) * fifo_size, "free chunk bytes %u " "expected %u", rv, (n_batch - 1) * fifo_size); + /* Grow by preallocated fifo_size chunk */ fifo_segment_grow_fifo (fs, f, fifo_size); SFIFO_TEST (f->size == 2 * fifo_size, "fifo size should be %u is %u", 2 * fifo_size, f->size); @@ -1989,6 +1990,11 @@ sfifo_test_fifo_segment_fifo_grow (int verbose) SFIFO_TEST (rv == (n_batch - 2) * fifo_size, "free chunk bytes %u " "expected %u", rv, (n_batch - 2) * fifo_size); + /* Grow by a size not preallocated but first make sure there's space */ + rv = fifo_segment_free_bytes (fs); + SFIFO_TEST (rv > 16 * fifo_size, "free bytes %u more than %u", rv, + 16 * fifo_size); + fifo_segment_grow_fifo (fs, f, 16 * fifo_size); SFIFO_TEST (f->size == 18 * fifo_size, "fifo size should be %u is %u", 18 * fifo_size, f->size); @@ -2068,6 +2074,12 @@ sfifo_test_fifo_segment_fifo_grow (int verbose) * Force multi chunk fifo allocation */ + /* Check that we can force multi chunk allocation. Note that fifo size + * rounded up to power of 2, i.e., 17 becomes 32 */ + rv = fifo_segment_free_bytes (fs); + SFIFO_TEST (rv < 32 * fifo_size, "free bytes %u less than %u", rv, + 32 * fifo_size); + f = fifo_segment_alloc_fifo (fs, 17 * fifo_size, FIFO_SEGMENT_RX_FIFO); rv = fifo_segment_fl_chunk_bytes (fs);