[tarantool-patches] Re: [PATCH v7 1/1] box: create bigrefs for tuples

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Jun 10 00:22:33 MSK 2018


Hello. Thanks for the fixes!

I have force pushed my new fixes for the test. They
are about unit.h usage. With plan() + header() you can create
enclosed tests, so in a unit test you would not use
printf() directly.

Now the patch LGTM to me again. Please, send a new version
to Vladimir.

diff --git a/test/unit/tuple_bigref.c b/test/unit/tuple_bigref.c
index 154c10ac1..973bf924a 100644
--- a/test/unit/tuple_bigref.c
+++ b/test/unit/tuple_bigref.c
@@ -43,9 +43,10 @@ create_tuple()
   * consistently.
   */
  static void
-test_bigrefs_1()
+test_bigrefs_overall()
  {
-	printf("Test1: Overall check of bigrefs.\n");
+	header();
+	plan(3);
  	uint16_t counter = 0;
  	struct tuple **tuples = (struct tuple **) malloc(BIGREF_CAPACITY *
  							 sizeof(*tuples));
@@ -74,6 +75,8 @@ test_bigrefs_1()
  	}
  	is(counter, BIGREF_CAPACITY, "All tuples were deleted.");
  	free(tuples);
+	footer();
+	check_plan();
  }
  
  /**
@@ -81,9 +84,10 @@ test_bigrefs_1()
   * created and destroyed 2 times.
   */
  static void
-test_bigrefs_2()
+test_bigrefs_create_destroy()
  {
-	printf("Test 2: Create/destroy test.\n");
+	header();
+	plan(2);
  	struct tuple *tuple = create_tuple();
  	for(int j = 1; j < BIGREF_COUNT; ++j)
  		tuple_ref(tuple);
@@ -98,6 +102,8 @@ test_bigrefs_2()
  	for(int j = 1; j < BIGREF_COUNT; ++j)
  		tuple_unref(tuple);
  	tuple_unref(tuple);
+	footer();
+	check_plan();
  }
  
  /**
@@ -105,15 +111,16 @@ test_bigrefs_2()
   * intended.
   */
  static void
-test_bigrefs_3()
+test_bigrefs_non_consistent()
  {
-	printf("Test3: Non-consistent indexes test.\n");
+	header();
+	plan(3);
  	uint16_t counter = 0;
  	uint16_t max_index = BIGREF_CAPACITY / BIGREF_DIFF;
  	struct tuple **tuples = (struct tuple **) malloc(BIGREF_CAPACITY *
  							 sizeof(*tuples));
-	uint16_t *indexes = (uint16_t *) malloc (sizeof(*indexes) *
-		(max_index + 1));
+	uint16_t *indexes = (uint16_t *) malloc(sizeof(*indexes) *
+						(max_index + 1));
  	for(int i = 0; i < BIGREF_CAPACITY; ++i)
  		tuples[i] = create_tuple();
  	for(int i = 0; i < BIGREF_CAPACITY; ++i) {
@@ -151,13 +158,15 @@ test_bigrefs_3()
  	}
  	free(indexes);
  	free(tuples);
+	footer();
+	check_plan();
  }
  
  int
  main()
  {
  	header();
-	plan(9);
+	plan(3);
  
  	memory_init();
  	fiber_init(fiber_c_invoke);
@@ -166,9 +175,9 @@ main()
  	tuple_end = mp_encode_array(tuple_end, 1);
  	tuple_end = mp_encode_uint(tuple_end, 2);
  
-	test_bigrefs_1();
-	test_bigrefs_2();
-	test_bigrefs_3();
+	test_bigrefs_overall();
+	test_bigrefs_create_destroy();
+	test_bigrefs_non_consistent();
  
  	tuple_free();
  	fiber_free();
diff --git a/test/unit/tuple_bigref.result b/test/unit/tuple_bigref.result
index 7e8694e15..74da2d559 100644
--- a/test/unit/tuple_bigref.result
+++ b/test/unit/tuple_bigref.result
@@ -1,15 +1,23 @@
-# Looks like you planned 9 tests but ran 8.
  	*** main ***
-1..9
-Test1: Overall check of bigrefs.
-ok 1 - All tuples have refs == 1.
-ok 2 - All tuples have bigrefs.
-ok 3 - All tuples were deleted.
-Test 2: Create/destroy test.
-ok 4 - Tuple becomes bigref first time with ref_index == 0.
-ok 5 - Tuple becomes bigref second time with ref_index == 0.
-Test3: Non-consistent indexes test.
-ok 6 - All tuples have bigrefs.
-ok 7 - 11 tuples don't have bigrefs and all other tuples have
-ok 8 - All tuples have bigrefs and their indexes are in right order.
+1..3
+	*** test_bigrefs_overall ***
+    1..3
+    ok 1 - All tuples have refs == 1.
+    ok 2 - All tuples have bigrefs.
+    ok 3 - All tuples were deleted.
+	*** test_bigrefs_overall: done ***
+ok 1 - subtests
+	*** test_bigrefs_create_destroy ***
+    1..2
+    ok 1 - Tuple becomes bigref first time with ref_index == 0.
+    ok 2 - Tuple becomes bigref second time with ref_index == 0.
+	*** test_bigrefs_create_destroy: done ***
+ok 2 - subtests
+	*** test_bigrefs_non_consistent ***
+    1..3
+    ok 1 - All tuples have bigrefs.
+    ok 2 - 11 tuples don't have bigrefs and all other tuples have
+    ok 3 - All tuples have bigrefs and their indexes are in right order.
+	*** test_bigrefs_non_consistent: done ***
+ok 3 - subtests
  	*** main: done ***





More information about the Tarantool-patches mailing list