Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Ilya Markov <imarkov@tarantool.org>,
	Kirill Yukhin <kyukhin@tarantool.org>
Cc: Alexander Turenko <alexander.turenko@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] [PATCH] Add test case for fiber safety of digest.pbkdf2
Date: Tue, 15 May 2018 14:04:21 +0300	[thread overview]
Message-ID: <ec9ec9466c943e943fabe52f58906f4dd4beac64.1526381634.git.alexander.turenko@tarantool.org> (raw)

Follows up #3396.
---

branch: Totktonada/gh-3396-fiber-safe-pbkdf2-test
travis-ci: https://travis-ci.org/tarantool/tarantool/builds/379156714

 test/app/digest.result   | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/app/digest.test.lua | 19 +++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/test/app/digest.result b/test/app/digest.result
index bf1815136..d41efde3f 100644
--- a/test/app/digest.result
+++ b/test/app/digest.result
@@ -5,6 +5,9 @@ test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua:<line>\"]: '")
 ---
 - true
 ...
+fiber = require('fiber')
+---
+...
 digest = require('digest')
 ---
 ...
@@ -576,3 +579,60 @@ test_run:cmd("clear filter")
 ---
 - true
 ...
+-- gh-3396: fiber-safe pbkdf2
+res = {}
+---
+...
+sentry = fiber.channel()
+---
+...
+_ = test_run:cmd("setopt delimiter ';'")
+---
+...
+function test_pbkdf2()
+    local digest = require('digest')
+    for i = 1, 10 do
+        table.insert(res, digest.pbkdf2('', 'salt', 100, 32):hex())
+    end
+    sentry:put(fiber.id())
+end;
+---
+...
+_ = test_run:cmd("setopt delimiter ''");
+---
+...
+_ = fiber.create(test_pbkdf2)
+---
+...
+_ = fiber.create(test_pbkdf2)
+---
+...
+_ = sentry:get()
+---
+...
+_ = sentry:get()
+---
+...
+res
+---
+- - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+  - bafac115a0022b2894f2983b5b5102455bdd3ba7cfbeb09f219a9fde8f3ee6a9
+...
diff --git a/test/app/digest.test.lua b/test/app/digest.test.lua
index 3134efc92..7ecda91bc 100644
--- a/test/app/digest.test.lua
+++ b/test/app/digest.test.lua
@@ -1,6 +1,7 @@
 test_run = require('test_run').new()
 test_run:cmd("push filter ".."'\\.lua.*:[0-9]+: ' to '.lua:<line>\"]: '")
 
+fiber = require('fiber')
 digest = require('digest')
 type(digest)
 
@@ -184,3 +185,21 @@ s
 err:match("number")
 digest = nil
 test_run:cmd("clear filter")
+
+-- gh-3396: fiber-safe pbkdf2
+res = {}
+sentry = fiber.channel()
+_ = test_run:cmd("setopt delimiter ';'")
+function test_pbkdf2()
+    local digest = require('digest')
+    for i = 1, 10 do
+        table.insert(res, digest.pbkdf2('', 'salt', 100, 32):hex())
+    end
+    sentry:put(fiber.id())
+end;
+_ = test_run:cmd("setopt delimiter ''");
+_ = fiber.create(test_pbkdf2)
+_ = fiber.create(test_pbkdf2)
+_ = sentry:get()
+_ = sentry:get()
+res
-- 
2.15.1

             reply	other threads:[~2018-05-15 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 11:04 Alexander Turenko [this message]
2018-05-15 13:34 ` [tarantool-patches] " Kirill Yukhin

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=ec9ec9466c943e943fabe52f58906f4dd4beac64.1526381634.git.alexander.turenko@tarantool.org \
    --to=alexander.turenko@tarantool.org \
    --cc=imarkov@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH] Add test case for fiber safety of digest.pbkdf2' \
    /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