Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, "Мерген Имеев" <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v7 1/1] box: create bigrefs for tuples
Date: Sun, 10 Jun 2018 00:22:33 +0300	[thread overview]
Message-ID: <6c43e17e-55aa-e3d5-914b-cd03056becdf@tarantool.org> (raw)
In-Reply-To: <1528569664.354142726@f492.i.mail.ru>

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 ***

      reply	other threads:[~2018-06-09 21:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-09 14:40 [tarantool-patches] " imeevma
2018-06-09 15:15 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-09 18:41   ` [tarantool-patches] " Мерген Имеев
2018-06-09 21:22     ` Vladislav Shpilevoy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c43e17e-55aa-e3d5-914b-cd03056becdf@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v7 1/1] box: create bigrefs for tuples' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox