svm: improve fifo segment test 78/20378/4
authorFlorin Coras <fcoras@cisco.com>
Thu, 27 Jun 2019 04:11:26 +0000 (21:11 -0700)
committerDave Barach <openvpp@barachs.net>
Thu, 27 Jun 2019 15:57:59 +0000 (15:57 +0000)
Type: feature

Try to also catch weirdness when running tests on arm cpus.

Change-Id: I45ab7c225f43623447271e67ebf37f94236a288f
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/plugins/unittest/svm_fifo_test.c

index a8f83fa..bf633b7 100644 (file)
@@ -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);