Tarantool development patches archive
 help / color / mirror / Atom feed
From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: Maxim Kokryashkin <max.kokryashkin@gmail.com>,
	 tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH luajit v2] Fix command-line argv handling.
Date: Thu, 11 Apr 2024 17:45:35 +0300	[thread overview]
Message-ID: <ezcfjdompfnpy2cloipmcmkmjbh2tip2ytwjcgtvqyybgevfbk@4cwhjma7ulrn> (raw)
In-Reply-To: <Zhfk-txTq2u0x2Dj@root>

Hi, Sergey!
Thanks for the patch!
Fixed, branch is force-pushed:
===
diff --git a/test/tarantool-c-tests/CMakeLists.txt b/test/tarantool-c-tests/CMakeLists.txt
index 7ae440e2..5f789ad8 100644
--- a/test/tarantool-c-tests/CMakeLists.txt
+++ b/test/tarantool-c-tests/CMakeLists.txt
@@ -36,9 +36,9 @@ add_test_suite_target(tarantool-c-tests
   DEPENDS libluajit libtest tarantool-c-tests-build
 )

-# XXX: The tarantool-c-tests target cannot be linked with the LuaJIT
-# library when it is built as shared. The test suite is disabled for
-# the dynamic build mode.
+# XXX: The tarantool-c-tests target cannot be linked with the
+# LuaJIT library when it is built as shared. The test suite is
+# disabled for the dynamic build mode.
 if(BUILDMODE STREQUAL "dynamic")
   message("Dynamic build mode, tarantool-c-tests suite is empty")
   return()
diff --git a/test/tarantool-tests/CMakeLists.txt b/test/tarantool-tests/CMakeLists.txt
index 05deb534..0d5f3774 100644
--- a/test/tarantool-tests/CMakeLists.txt
+++ b/test/tarantool-tests/CMakeLists.txt
@@ -128,7 +128,8 @@ file(GLOB_RECURSE tests ${CMAKE_CURRENT_SOURCE_DIR} "*${LUA_TEST_SUFFIX}")
 foreach(test_path ${tests})
   get_filename_component(test_name ${test_path} NAME)

-  if(test_name STREQUAL "fix-argv-handling.test.lua" AND NOT BUILDMODE STREQUAL "dynamic")
+  if(test_name STREQUAL "fix-argv-handling.test.lua"
+      AND NOT BUILDMODE STREQUAL "dynamic")
     continue()
   endif()

diff --git a/test/tarantool-tests/fix-argv-handling.test.lua b/test/tarantool-tests/fix-argv-handling.test.lua
index 57e5f169..fd558705 100644
--- a/test/tarantool-tests/fix-argv-handling.test.lua
+++ b/test/tarantool-tests/fix-argv-handling.test.lua
@@ -5,9 +5,9 @@ local test = tap.test('fix-argv-handling'):skipcond({

 test:plan(1)

--- XXX: Since the Linux kernel 5.18-rc1 release, `argv` is
--- forced to a single empty string if it is empty [1], so
--- the issue is not reproducible on new kernels.
+-- XXX: Since the Linux kernel 5.18-rc1 release, `argv` is forced
+-- to a single empty string if it is empty [1], so the issue is
+-- not reproducible on new kernels.
 --
 -- [1]: https://lore.kernel.org/all/20220201000947.2453721-1-keescook@chromium.org/

@@ -19,7 +19,7 @@ local cmd = utils.exec.luabin(arg)
 -- `luaL_newstate`.
 local output = execlib.empty_argv_exec(cmd)

--- Without the patch, the test fails with a segmentation fault instead of
--- returning an error.
+-- Without the patch, the test fails with a segmentation fault
+-- instead of returning an error.
 test:like(output, 'cannot create state', 'correct argv handling')
 test:done(true)
diff --git a/test/tarantool-tests/fix-argv-handling/execlib.c b/test/tarantool-tests/fix-argv-handling/execlib.c
index ef8217d4..a8d5f16c 100644
--- a/test/tarantool-tests/fix-argv-handling/execlib.c
+++ b/test/tarantool-tests/fix-argv-handling/execlib.c
@@ -1,7 +1,7 @@
+#define _GNU_SOURCE
 #include "lua.h"
 #include "lauxlib.h"

-#define _GNU_SOURCE
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -22,7 +22,7 @@ static int empty_argv_exec(struct lua_State *L)
 {
 	const char *path = luaL_checkstring(L, -1);
 	int pipefds[2] = {};
-	char *const  argv[] = {NULL};
+	char *const argv[] = {NULL};
 	char buf[BUF_SIZE];

 	CHECKED(pipe2(pipefds, O_CLOEXEC));
@@ -32,15 +32,15 @@ static int empty_argv_exec(struct lua_State *L)

 	if (pid == 0) {
 		/*
-		 * Mock the `luaL_newstate` with
-		 * an error-injected version.
+		 * Mock the `luaL_newstate` with an error-injected
+		 * version.
 		 */
 		setenv("LD_PRELOAD", "mynewstate.so", 1);
-		CHECKED(dup2(pipefds[1], 1));
-		CHECKED(dup2(pipefds[1], 2));
+		CHECKED(dup2(pipefds[1], STDOUT_FILENO));
+		CHECKED(dup2(pipefds[1], STDERR_FILENO));
 		/*
-		 * Pipes are closed on the exec
-		 * call because of the O_CLOEXEC flag.
+		 * Pipes are closed on the exec call because of
+		 * the O_CLOEXEC flag.
 		 */
 		CHECKED(execvp(path, argv));
 	}
@@ -48,7 +48,6 @@ static int empty_argv_exec(struct lua_State *L)
 	close(pipefds[1]);
 	CHECKED(waitpid(pid, NULL, 0));

-
 	CHECKED(read(pipefds[0], buf, BUF_SIZE));
 	close(pipefds[0]);

===

  reply	other threads:[~2024-04-11 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 13:00 Maxim Kokryashkin via Tarantool-patches
2024-04-11 13:26 ` Sergey Kaplun via Tarantool-patches
2024-04-11 14:45   ` Maxim Kokryashkin via Tarantool-patches [this message]
2024-04-11 14:57     ` Sergey Kaplun via Tarantool-patches
2024-04-11 16:30 ` Sergey Bronnikov via Tarantool-patches

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=ezcfjdompfnpy2cloipmcmkmjbh2tip2ytwjcgtvqyybgevfbk@4cwhjma7ulrn \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=max.kokryashkin@gmail.com \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit v2] Fix command-line argv handling.' \
    /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