From: Alexander Turenko <alexander.turenko@tarantool.org> To: "Alexander V. Tikhonov" <avtikhon@tarantool.org>, Kirill Yukhin <kyukhin@tarantool.org> Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v4] lua/key_def: fix compare_with_key() part count check Date: Thu, 24 Dec 2020 01:49:49 +0300 [thread overview] Message-ID: <20201223224949.hpd5qm7b4fj3d4lh@tkn_work_nb> (raw) In-Reply-To: <20201222082806.779193-1-void@tarantool.org> > Issue: https://github.com/tarantool/tarantool/issues/5307 > Branch: https://github.com/tarantool/tarantool/tree/void234/gh-5307-fix-key_def-part-count-check-v4 LGTM. I left several style / taste comments regarding the test. It is just for you. I think they don't worth one more review iteration. Alexander Ti., please, approve the push from the QA team side. Kirill, please, push to master and cherry-pick to 2.6 and 2.5. Changelog entry ('Lua' section): * Fixed a segfault in `key_def.compare_with_key()` on an invalid key (gh-5307). WBR, Alexander Turenko. ---- > diff --git a/test/box-tap/gh-5307-key_def-part-count-check.test.lua b/test/box-tap/gh-5307-key_def-part-count-check.test.lua > new file mode 100755 > index 000000000..d9458c95a > --- /dev/null > +++ b/test/box-tap/gh-5307-key_def-part-count-check.test.lua > @@ -0,0 +1,26 @@ > +#!/usr/bin/env tarantool > + > +local tap = require('tap') > +local mytest = tap.test('key_def part count tests') > + > +mytest:plan(3) Usually 'test'. > + > +local key_def = require('key_def') Usually all requires are go first, when possible. > +local kd = key_def.new({{fieldno = 1, type = 'unsigned'}}) > +local ok, res > + > +-- Should succeed We trying to write comments in the same style: start with a capital letter, end with a period. > +ok, res = pcall(kd.compare_with_key, kd, {1}, {1}) > +mytest:ok(ok and res == 0, "Simple equality") In my personal taste, it is good to use the same quotes (single or double) when possible within at least a file. (I prefer single ones, but without any reason, just get into the habit.) > + > +-- Should succeed > +ok, res = pcall(kd.compare_with_key, kd, {1}, {2}) > +mytest:ok(ok and res < 0, "Simple inequality") > + > +-- Should fail > +local exp_err = "Invalid key part count (expected [0..1], got 9)" > +ok, res = pcall(kd.compare_with_key, kd, {1}, {1, 2, 3, 4, 5, 6, 7, 8, 9}) > +mytest:is_deeply({ok, tostring(res)}, {false, exp_err}, > + "Invalid key part count") > + > +os.exit(mytest:check() and 0 or 1) > -- > 2.25.1 >
next prev parent reply other threads:[~2020-12-23 22:49 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-12-22 8:28 Sergey Nikiforov 2020-12-22 14:28 ` Vladislav Shpilevoy 2020-12-23 22:49 ` Alexander Turenko [this message] 2020-12-24 18:07 ` Kirill Yukhin 2020-12-24 18:18 ` Alexander Turenko 2020-12-24 18:19 ` 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=20201223224949.hpd5qm7b4fj3d4lh@tkn_work_nb \ --to=alexander.turenko@tarantool.org \ --cc=avtikhon@tarantool.org \ --cc=kyukhin@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4] lua/key_def: fix compare_with_key() part count check' \ /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