[Tarantool-patches] [PATCH v21 6/6] test: add box.lib test

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Apr 11 18:43:02 MSK 2021


Thanks for the patch!

See below 4 comments, my diff in the end of the email, and on
the branch in a separate commit.

> diff --git a/test/box/lib.result b/test/box/lib.result
> new file mode 100644
> index 000000000..2986df049
> --- /dev/null
> +++ b/test/box/lib.result
> @@ -0,0 +1,527 @@

<...>

> +
> +-- Cleanup new module data.
> +new_cfunc_nop:unload()
> + | ---
> + | - true
> + | ...
> +new_cfunc_multireturn:unload()
> + | ---
> + | - true
> + | ...
> +new_cfunc_fetch_seq_evens:unload()
> + | ---
> + | - true
> + | ...
> +new_cfunc_args:unload()
> + | ---
> + | - true
> + | ...
> +new_cfunc_sum:unload()
> + | ---
> + | - true
> + | ...
> +new_module:unload()
> + | ---
> + | - true
> + | ...
> +
> +-- Cleanup the generated symlink.
> +_ = pcall(fio.unlink(cfunc_path))
> + | ---
> + | ...
> +
> +-- Test double hashing: create function
> +-- in box.schema.fun so that it should
> +-- appear in box.lib hash.
> +fio.symlink(cfunc3_path, cfunc_path)
> + | ---
> + | - true
> + | ...
> +box.schema.func.create('cfunc.cfunc_add', {language = "C"})
> + | ---
> + | ...
> +box.schema.user.grant('guest', 'execute', 'function', 'cfunc.cfunc_add')
> + | ---
> + | ...
> +box.func['cfunc.cfunc_add']:call({1,2})
> + | ---
> + | - 3
> + | ...
> +
> +old_module = box.lib.load('cfunc')
> + | ---
> + | ...
> +assert(old_module['debug_refs'] == 3) -- box.lib + 2 box.schema.func

1. Why +2? There is only one function loaded from that module in
box.schema.func.

> + | ---
> + | - true
> + | ...
> +old_func = old_module:load('cfunc_add')
> + | ---
> + | ...
> +assert(old_module['debug_refs'] == 4) -- plus function instance
> + | ---
> + | - true
> + | ...
> +old_func(1,2)
> + | ---
> + | - 3
> + | ...
> +
> +-- Now update on disk and reload the module.
> +_ = pcall(fio.unlink(cfunc_path))
> + | ---
> + | ...
> +fio.symlink(cfunc4_path, cfunc_path)
> + | ---
> + | - true
> + | ...
> +
> +box.schema.func.reload("cfunc")
> + | ---
> + | ...
> +box.func['cfunc.cfunc_add']:call({1,2})
> + | ---
> + | - 13
> + | ...
> +
> +-- The box.lib instance should carry own
> +-- references to the module and old
> +-- function. And reloading must not
> +-- affect old functions. Thus one for
> +-- box.lib and one for box.lib function.

2. What do you mean "one for box.lib"?

> +assert(old_module['debug_refs'] == 2)
> + | ---
> + | - true
> + | ...
> +old_func(1,2)
> + | ---
> + | - 3
> + | ...
> +old_func:unload()
> + | ---
> + | - true
> + | ...
> +old_module:unload()
> + | ---
> + | - true
> + | ...
> +
> +-- Same time the reload should update
> +-- low level module cache, thus two
> +-- for box and box function plus one

3. The same question. What is "for box"?
What exactly keeps these references?

> +-- new box.lib.
> +new_module = box.lib.load('cfunc')
> + | ---
> + | ...
> +assert(new_module['debug_refs'] == 3)
> + | ---
> + | - true
> + | ...
> +

4. In the previous review I asked you to add tests
for automatic unload via GC. Please, add them.

You can use collectgarbage('collect') functions,
and setmetatable(..., {__mode = 'v'}) if it will
help with anything.

See below my review fixes and on the branch in a
separate commit.

====================

diff --git a/test/box/cfunc1.c b/test/box/cfunc1.c
index f6829372a..2ab0e8d78 100644
--- a/test/box/cfunc1.c
+++ b/test/box/cfunc1.c
@@ -1,7 +1,3 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <msgpuck.h>
-
 #include "module.h"
 
 /*
@@ -15,44 +11,17 @@
 int
 cfunc_nop(box_function_ctx_t *ctx, const char *args, const char *args_end)
 {
-	(void)ctx;
-	(void)args;
-	(void)args_end;
-	return 0;
-}
-
-int
-cfunc_fetch_seq_evens(box_function_ctx_t *ctx, const char *args, const char *args_end)
-{
-	(void)ctx;
-	(void)args;
-	(void)args_end;
-	return 0;
-}
-
-int
-cfunc_multireturn(box_function_ctx_t *ctx, const char *args, const char *args_end)
-{
-	(void)ctx;
-	(void)args;
-	(void)args_end;
 	return 0;
 }
 
 int
-cfunc_args(box_function_ctx_t *ctx, const char *args, const char *args_end)
+cfunc_echo(box_function_ctx_t *ctx, const char *args, const char *args_end)
 {
-	(void)ctx;
-	(void)args;
-	(void)args_end;
 	return 0;
 }
 
 int
 cfunc_sum(box_function_ctx_t *ctx, const char *args, const char *args_end)
 {
-	(void)ctx;
-	(void)args;
-	(void)args_end;
 	return 0;
 }
diff --git a/test/box/cfunc2.c b/test/box/cfunc2.c
index 8c583e993..6de40b866 100644
--- a/test/box/cfunc2.c
+++ b/test/box/cfunc2.c
@@ -1,7 +1,6 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <msgpuck.h>
====================

As I said earlier, for non-system headers we use "", not <>.

====================
+#include <stdlib.h>
 
+#include "msgpuck.h"
 #include "module.h"
 
 /*
@@ -10,9 +9,6 @@
 int
 cfunc_nop(box_function_ctx_t *ctx, const char *args, const char *args_end)
 {
-	(void)ctx;
-	(void)args;
-	(void)args_end;
 	return 0;
 }
 
@@ -21,99 +17,22 @@ cfunc_nop(box_function_ctx_t *ctx, const char *args, const char *args_end)
  * arguments is not screwed).
  */
 int
-cfunc_fetch_seq_evens(box_function_ctx_t *ctx, const char *args, const char *args_end)
-{
====================

After more thinkning I still couldn't find a reason why this
function has to be so complex. Why not solve an integral equation
then? Or calculcate Fibonachi numbers? For your purpose a simple
'echo' function would solve both the arguments sanity check, and
the miltireturn check.

====================
-	int arg_count = mp_decode_array(&args);
-	if (arg_count != 1) {
-		return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s",
-				     "invalid argument count");
-	}
-	int field_count = mp_decode_array(&args);
-	if (field_count < 1) {
-		return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s",
-				     "invalid array size");
-	}
-
-	/*
-	 * We expect even numbers sequence here. The idea is
-	 * to test invalid data an issue an error from inside
-	 * of C function.
-	 */
-	for (int i = 1; i <= field_count; i++) {
-		int val = mp_decode_uint(&args);
-		int needed = 2 * i;
-		if (val != needed) {
-			char res[128];
-			snprintf(res, sizeof(res), "%s %d != %d",
-				 "invalid argument", val, needed);
-			return box_error_set(__FILE__, __LINE__,
-					     ER_PROC_C, "%s", res);
-		}
-	}
-
-	return 0;
-}
-
-/*
- * Return one element array twice.
- */
-int
-cfunc_multireturn(box_function_ctx_t *ctx, const char *args, const char *args_end)
-{
-	char tuple_buf[512];
-	char *d = tuple_buf;
-	d = mp_encode_array(d, 1);
-	d = mp_encode_uint(d, 1);
-	assert(d <= tuple_buf + sizeof(tuple_buf));
-
-	box_tuple_format_t *fmt = box_tuple_format_default();
-	box_tuple_t *tuple_a = box_tuple_new(fmt, tuple_buf, d);
-	if (tuple_a == NULL)
-		return -1;
-	int rc = box_return_tuple(ctx, tuple_a);
-	if (rc == 0)
-		return box_return_tuple(ctx, tuple_a);
-	return rc;
-}
-
-/*
- * Encode int + string pair back.
- */
-int
-cfunc_args(box_function_ctx_t *ctx, const char *args, const char *args_end)
+cfunc_echo(box_function_ctx_t *ctx, const char *args, const char *args_end)
 {
+	const char *pos = args;
+	if (mp_check(&pos, args_end) != 0)
+		abort();
+	if (mp_typeof(*args) != MP_ARRAY)
+		abort();
 	uint32_t arg_count = mp_decode_array(&args);
-	if (arg_count != 2) {
-		return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s",
-				     "invalid argument count");
+	for (uint32_t i = 0; i < arg_count; ++i) {
+		pos = args;
+		mp_next(&pos);
+		if (box_return_mp(ctx, args, pos) != 0)
+			return -1;
+		args = pos;
 	}
-
-	if (mp_typeof(*args) != MP_UINT) {
-		return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s",
-				     "tuple field must be uint");
-	}
-	uint32_t num = mp_decode_uint(&args);
-
-	if (mp_typeof(*args) != MP_STR) {
-		return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s",
-				     "tuple field must be string");
-	}
-	const char *str = args;
-	uint32_t len = mp_decode_strl(&str);
-
-	char tuple_buf[512];
-	char *d = tuple_buf;
-	d = mp_encode_array(d, 2);
-	d = mp_encode_uint(d, num);
-	d = mp_encode_str(d, str, len);
-	assert(d <= tuple_buf + sizeof(tuple_buf));
-
-	box_tuple_format_t *fmt = box_tuple_format_default();
-	box_tuple_t *tuple = box_tuple_new(fmt, tuple_buf, d);
-	if (tuple == NULL)
-		return -1;
-
-	return box_return_tuple(ctx, tuple);
+	return 0;
 }
 
 /*
diff --git a/test/box/cfunc3.c b/test/box/cfunc3.c
index 668790fbf..71fe2717a 100644
--- a/test/box/cfunc3.c
+++ b/test/box/cfunc3.c
@@ -1,7 +1,4 @@
-#include <stdio.h>
-#include <stdbool.h>
-#include <msgpuck.h>
-
+#include "msgpuck.h"
 #include "module.h"
 
 /*
diff --git a/test/box/cfunc4.c b/test/box/cfunc4.c
index cc079b335..a03a23026 100644
--- a/test/box/cfunc4.c
+++ b/test/box/cfunc4.c
@@ -1,7 +1,4 @@
-#include <stdio.h>
-#include <stdbool.h>
 #include <msgpuck.h>
-
 #include "module.h"
 
 /*
diff --git a/test/box/lib.result b/test/box/lib.result
index 2986df049..58acb9c06 100644
--- a/test/box/lib.result
+++ b/test/box/lib.result
@@ -82,19 +82,13 @@ assert(old_module['debug_refs'] == 1)
 old_cfunc_nop = old_module:load('cfunc_nop')
  | ---
  | ...
-old_cfunc_fetch_seq_evens = old_module:load('cfunc_fetch_seq_evens')
- | ---
- | ...
-old_cfunc_multireturn = old_module:load('cfunc_multireturn')
- | ---
- | ...
-old_cfunc_args = old_module:load('cfunc_args')
+old_cfunc_echo = old_module:load('cfunc_echo')
  | ---
  | ...
 old_cfunc_sum = old_module:load('cfunc_sum')
  | ---
  | ...
-assert(old_module['debug_refs'] == 6)
+assert(old_module['debug_refs'] == 4)
  | ---
  | - true
  | ...
@@ -112,13 +106,7 @@ assert(err ~= nil)
 old_cfunc_nop()
  | ---
  | ...
-old_cfunc_fetch_seq_evens()
- | ---
- | ...
-old_cfunc_multireturn()
- | ---
- | ...
-old_cfunc_args()
+old_cfunc_echo()
  | ---
  | ...
 old_cfunc_sum()
@@ -133,20 +121,14 @@ old_module:unload()
  | - true
  | ...
 -- Test refs via function name.
-assert(old_cfunc_nop['debug_module_refs'] == 5)
+assert(old_cfunc_nop['debug_module_refs'] == 3)
  | ---
  | - true
  | ...
 old_cfunc_nop()
  | ---
  | ...
-old_cfunc_fetch_seq_evens()
- | ---
- | ...
-old_cfunc_multireturn()
- | ---
- | ...
-old_cfunc_args()
+old_cfunc_echo()
  | ---
  | ...
 old_cfunc_sum()
@@ -170,15 +152,7 @@ old_cfunc_nop:unload()
  | ---
  | - true
  | ...
-old_cfunc_fetch_seq_evens:unload()
- | ---
- | - true
- | ...
-old_cfunc_multireturn:unload()
- | ---
- | - true
- | ...
-old_cfunc_args:unload()
+old_cfunc_echo:unload()
  | ---
  | - true
  | ...
@@ -239,13 +213,7 @@ assert(old_module_ptr ~= new_module_ptr)
 old_cfunc_nop = old_module:load('cfunc_nop')
  | ---
  | ...
-old_cfunc_fetch_seq_evens = old_module:load('cfunc_fetch_seq_evens')
- | ---
- | ...
-old_cfunc_multireturn = old_module:load('cfunc_multireturn')
- | ---
- | ...
-old_cfunc_args = old_module:load('cfunc_args')
+old_cfunc_echo = old_module:load('cfunc_echo')
  | ---
  | ...
 old_cfunc_sum = old_module:load('cfunc_sum')
@@ -255,15 +223,7 @@ assert(old_cfunc_nop['debug_module_ptr'] == old_module_ptr)
  | ---
  | - true
  | ...
-assert(old_cfunc_fetch_seq_evens['debug_module_ptr'] == old_module_ptr)
- | ---
- | - true
- | ...
-assert(old_cfunc_multireturn['debug_module_ptr'] == old_module_ptr)
- | ---
- | - true
- | ...
-assert(old_cfunc_args['debug_module_ptr'] == old_module_ptr)
+assert(old_cfunc_echo['debug_module_ptr'] == old_module_ptr)
  | ---
  | - true
  | ...
@@ -271,7 +231,7 @@ assert(old_cfunc_sum['debug_module_ptr'] == old_module_ptr)
  | ---
  | - true
  | ...
-assert(old_module['debug_refs'] == 6)
+assert(old_module['debug_refs'] == 4)
  | ---
  | - true
  | ...
@@ -280,13 +240,7 @@ assert(old_module['debug_refs'] == 6)
 new_cfunc_nop = new_module:load('cfunc_nop')
  | ---
  | ...
-new_cfunc_fetch_seq_evens = new_module:load('cfunc_fetch_seq_evens')
- | ---
- | ...
-new_cfunc_multireturn = new_module:load('cfunc_multireturn')
- | ---
- | ...
-new_cfunc_args = new_module:load('cfunc_args')
+new_cfunc_echo = new_module:load('cfunc_echo')
  | ---
  | ...
 new_cfunc_sum = new_module:load('cfunc_sum')
@@ -296,15 +250,7 @@ assert(new_cfunc_nop['debug_module_ptr'] == new_module_ptr)
  | ---
  | - true
  | ...
-assert(new_cfunc_fetch_seq_evens['debug_module_ptr'] == new_module_ptr)
- | ---
- | - true
- | ...
-assert(new_cfunc_multireturn['debug_module_ptr'] == new_module_ptr)
- | ---
- | - true
- | ...
-assert(new_cfunc_args['debug_module_ptr'] == new_module_ptr)
+assert(new_cfunc_echo['debug_module_ptr'] == new_module_ptr)
  | ---
  | - true
  | ...
@@ -312,7 +258,7 @@ assert(new_cfunc_sum['debug_module_ptr'] == new_module_ptr)
  | ---
  | - true
  | ...
-assert(new_module['debug_refs'] == 6)
+assert(new_module['debug_refs'] == 4)
  | ---
  | - true
  | ...
@@ -321,13 +267,7 @@ assert(new_module['debug_refs'] == 6)
 old_cfunc_nop()
  | ---
  | ...
-old_cfunc_fetch_seq_evens()
- | ---
- | ...
-old_cfunc_multireturn()
- | ---
- | ...
-old_cfunc_args()
+old_cfunc_echo()
  | ---
  | ...
 old_cfunc_sum()
@@ -338,27 +278,21 @@ old_cfunc_sum()
 new_cfunc_nop()
  | ---
  | ...
-new_cfunc_multireturn()
+new_cfunc_echo({1, 2, 3})
  | ---
- | - [1]
- | - [1]
+ | - [1, 2, 3]
  | ...
-new_cfunc_fetch_seq_evens({2,4,6})
+new_cfunc_echo(1, 2, 3)
  | ---
- | ...
-new_cfunc_fetch_seq_evens({1,2,3})  -- error, odd numbers sequence
- | ---
- | - error: invalid argument 1 != 2
- | ...
-new_cfunc_args(1, "hello")
- | ---
- | - [1, 'hello']
+ | - 1
+ | - 2
+ | - 3
  | ...
 new_cfunc_sum(1) -- error, one arg passed
  | ---
  | - error: invalid argument count
  | ...
-new_cfunc_sum(1,2)
+new_cfunc_sum(1, 2)
  | ---
  | - 3
  | ...
@@ -368,15 +302,7 @@ old_cfunc_nop:unload()
  | ---
  | - true
  | ...
-old_cfunc_fetch_seq_evens:unload()
- | ---
- | - true
- | ...
-old_cfunc_multireturn:unload()
- | ---
- | - true
- | ...
-old_cfunc_args:unload()
+old_cfunc_echo:unload()
  | ---
  | - true
  | ...
@@ -394,15 +320,7 @@ new_cfunc_nop:unload()
  | ---
  | - true
  | ...
-new_cfunc_multireturn:unload()
- | ---
- | - true
- | ...
-new_cfunc_fetch_seq_evens:unload()
- | ---
- | - true
- | ...
-new_cfunc_args:unload()
+new_cfunc_echo:unload()
  | ---
  | - true
  | ...
@@ -433,7 +351,7 @@ box.schema.func.create('cfunc.cfunc_add', {language = "C"})
 box.schema.user.grant('guest', 'execute', 'function', 'cfunc.cfunc_add')
  | ---
  | ...
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
  | ---
  | - 3
  | ...
@@ -452,7 +370,7 @@ assert(old_module['debug_refs'] == 4) -- plus function instance
  | ---
  | - true
  | ...
-old_func(1,2)
+old_func(1, 2)
  | ---
  | - 3
  | ...
@@ -469,7 +387,7 @@ fio.symlink(cfunc4_path, cfunc_path)
 box.schema.func.reload("cfunc")
  | ---
  | ...
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
  | ---
  | - 13
  | ...
@@ -483,7 +401,7 @@ assert(old_module['debug_refs'] == 2)
  | ---
  | - true
  | ...
-old_func(1,2)
+old_func(1, 2)
  | ---
  | - 3
  | ...
@@ -509,7 +427,7 @@ assert(new_module['debug_refs'] == 3)
  | ...
 
 -- Box function should carry own module.
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
  | ---
  | - 13
  | ...
diff --git a/test/box/lib.test.lua b/test/box/lib.test.lua
index 387c813c4..e0e4b9e4d 100644
--- a/test/box/lib.test.lua
+++ b/test/box/lib.test.lua
@@ -32,11 +32,9 @@ assert(old_module_copy['debug_refs'] == 2)
 old_module_copy:unload()
 assert(old_module['debug_refs'] == 1)
 old_cfunc_nop = old_module:load('cfunc_nop')
-old_cfunc_fetch_seq_evens = old_module:load('cfunc_fetch_seq_evens')
-old_cfunc_multireturn = old_module:load('cfunc_multireturn')
-old_cfunc_args = old_module:load('cfunc_args')
+old_cfunc_echo = old_module:load('cfunc_echo')
 old_cfunc_sum = old_module:load('cfunc_sum')
-assert(old_module['debug_refs'] == 6)
+assert(old_module['debug_refs'] == 4)
 
 -- Test for error on nonexisting function.
 _, err = pcall(old_module.load, old_module, 'no-such-func')
@@ -44,9 +42,7 @@ assert(err ~= nil)
 
 -- Make sure they all are callable.
 old_cfunc_nop()
-old_cfunc_fetch_seq_evens()
-old_cfunc_multireturn()
-old_cfunc_args()
+old_cfunc_echo()
 old_cfunc_sum()
 
 -- Unload the module but keep old functions alive, so
@@ -54,11 +50,9 @@ old_cfunc_sum()
 -- and still callable.
 old_module:unload()
 -- Test refs via function name.
-assert(old_cfunc_nop['debug_module_refs'] == 5)
+assert(old_cfunc_nop['debug_module_refs'] == 3)
 old_cfunc_nop()
-old_cfunc_fetch_seq_evens()
-old_cfunc_multireturn()
-old_cfunc_args()
+old_cfunc_echo()
 old_cfunc_sum()
 
 -- The module is unloaded I should not be able
@@ -69,9 +63,7 @@ old_module:unload()
 
 -- Clean old functions.
 old_cfunc_nop:unload()
-old_cfunc_fetch_seq_evens:unload()
-old_cfunc_multireturn:unload()
-old_cfunc_args:unload()
+old_cfunc_echo:unload()
 assert(old_cfunc_sum['debug_module_refs'] == 1)
 old_cfunc_sum:unload()
 
@@ -96,59 +88,43 @@ assert(old_module_ptr ~= new_module_ptr)
 
 -- All functions from old module should be loadable.
 old_cfunc_nop = old_module:load('cfunc_nop')
-old_cfunc_fetch_seq_evens = old_module:load('cfunc_fetch_seq_evens')
-old_cfunc_multireturn = old_module:load('cfunc_multireturn')
-old_cfunc_args = old_module:load('cfunc_args')
+old_cfunc_echo = old_module:load('cfunc_echo')
 old_cfunc_sum = old_module:load('cfunc_sum')
 assert(old_cfunc_nop['debug_module_ptr'] == old_module_ptr)
-assert(old_cfunc_fetch_seq_evens['debug_module_ptr'] == old_module_ptr)
-assert(old_cfunc_multireturn['debug_module_ptr'] == old_module_ptr)
-assert(old_cfunc_args['debug_module_ptr'] == old_module_ptr)
+assert(old_cfunc_echo['debug_module_ptr'] == old_module_ptr)
 assert(old_cfunc_sum['debug_module_ptr'] == old_module_ptr)
-assert(old_module['debug_refs'] == 6)
+assert(old_module['debug_refs'] == 4)
 
 -- Lookup for updated symbols.
 new_cfunc_nop = new_module:load('cfunc_nop')
-new_cfunc_fetch_seq_evens = new_module:load('cfunc_fetch_seq_evens')
-new_cfunc_multireturn = new_module:load('cfunc_multireturn')
-new_cfunc_args = new_module:load('cfunc_args')
+new_cfunc_echo = new_module:load('cfunc_echo')
 new_cfunc_sum = new_module:load('cfunc_sum')
 assert(new_cfunc_nop['debug_module_ptr'] == new_module_ptr)
-assert(new_cfunc_fetch_seq_evens['debug_module_ptr'] == new_module_ptr)
-assert(new_cfunc_multireturn['debug_module_ptr'] == new_module_ptr)
-assert(new_cfunc_args['debug_module_ptr'] == new_module_ptr)
+assert(new_cfunc_echo['debug_module_ptr'] == new_module_ptr)
 assert(new_cfunc_sum['debug_module_ptr'] == new_module_ptr)
-assert(new_module['debug_refs'] == 6)
+assert(new_module['debug_refs'] == 4)
 
 -- Call old functions.
 old_cfunc_nop()
-old_cfunc_fetch_seq_evens()
-old_cfunc_multireturn()
-old_cfunc_args()
+old_cfunc_echo()
 old_cfunc_sum()
 
 -- Call new functions.
 new_cfunc_nop()
-new_cfunc_multireturn()
-new_cfunc_fetch_seq_evens({2,4,6})
-new_cfunc_fetch_seq_evens({1,2,3})  -- error, odd numbers sequence
-new_cfunc_args(1, "hello")
+new_cfunc_echo({1, 2, 3})
+new_cfunc_echo(1, 2, 3)
 new_cfunc_sum(1) -- error, one arg passed
-new_cfunc_sum(1,2)
+new_cfunc_sum(1, 2)
 
 -- Cleanup old module's functions.
 old_cfunc_nop:unload()
-old_cfunc_fetch_seq_evens:unload()
-old_cfunc_multireturn:unload()
-old_cfunc_args:unload()
+old_cfunc_echo:unload()
 old_cfunc_sum:unload()
 old_module:unload()
 
 -- Cleanup new module data.
 new_cfunc_nop:unload()
-new_cfunc_multireturn:unload()
-new_cfunc_fetch_seq_evens:unload()
-new_cfunc_args:unload()
+new_cfunc_echo:unload()
 new_cfunc_sum:unload()
 new_module:unload()
 
@@ -161,20 +137,20 @@ _ = pcall(fio.unlink(cfunc_path))
 fio.symlink(cfunc3_path, cfunc_path)
 box.schema.func.create('cfunc.cfunc_add', {language = "C"})
 box.schema.user.grant('guest', 'execute', 'function', 'cfunc.cfunc_add')
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
 
 old_module = box.lib.load('cfunc')
 assert(old_module['debug_refs'] == 3) -- box.lib + 2 box.schema.func
 old_func = old_module:load('cfunc_add')
 assert(old_module['debug_refs'] == 4) -- plus function instance
-old_func(1,2)
+old_func(1, 2)
 
 -- Now update on disk and reload the module.
 _ = pcall(fio.unlink(cfunc_path))
 fio.symlink(cfunc4_path, cfunc_path)
 
 box.schema.func.reload("cfunc")
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
 
 -- The box.lib instance should carry own
 -- references to the module and old
@@ -182,7 +158,7 @@ box.func['cfunc.cfunc_add']:call({1,2})
 -- affect old functions. Thus one for
 -- box.lib and one for box.lib function.
 assert(old_module['debug_refs'] == 2)
-old_func(1,2)
+old_func(1, 2)
 old_func:unload()
 old_module:unload()
 
@@ -194,7 +170,7 @@ new_module = box.lib.load('cfunc')
 assert(new_module['debug_refs'] == 3)
 
 -- Box function should carry own module.
-box.func['cfunc.cfunc_add']:call({1,2})
+box.func['cfunc.cfunc_add']:call({1, 2})
 
 -- Cleanup.
 _ = pcall(fio.unlink(cfunc_path))



More information about the Tarantool-patches mailing list