Skip to content

Commit

Permalink
[#3351] use execve to silence valgrind on child exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Becheriu committed Oct 17, 2024
1 parent 924b256 commit 0f298df
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,8 @@ AC_CONFIG_FILES([src/lib/process/cfgrpt/Makefile])
AC_CONFIG_FILES([src/lib/process/cfgrpt/tests/Makefile])
AC_CONFIG_FILES([src/lib/process/tests/Makefile])
AC_CONFIG_FILES([src/lib/process/testutils/Makefile])
AC_CONFIG_FILES([src/lib/process/tests/process_test.sh],
[chmod +x src/lib/process/tests/process_test.sh])
AC_CONFIG_FILES([src/lib/stats/Makefile])
AC_CONFIG_FILES([src/lib/stats/tests/Makefile])
AC_CONFIG_FILES([src/lib/stats/testutils/Makefile])
Expand Down
1 change: 1 addition & 0 deletions src/lib/process/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/libprocess_unittests
/process_test.sh
1 change: 1 addition & 0 deletions src/lib/process/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dhcp_data_dir = @runstatedir@/@PACKAGE@
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/process/tests\"
AM_CPPFLAGS += -DTEST_SCRIPT_SH=\"$(abs_top_builddir)/src/lib/process/tests/process_test.sh\"
AM_CPPFLAGS += -DDATA_DIR="\"$(dhcp_data_dir)\""
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"

Expand Down
7 changes: 5 additions & 2 deletions src/lib/process/tests/daemon_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ TEST_F(DaemonTest, createPIDFileOverwrite) {
ASSERT_GE(pid, 0);

if (pid == 0) {
// This is the child, die right away. Tragic, no?
_exit (0);
char name[] = TEST_SCRIPT_SH;
char* argv[] = { name, 0 };
char* envp[] = { 0 };
execve(name, argv, envp);
_exit(0);
}

// Back in the parent test, we need to wait for the child to die
Expand Down
1 change: 1 addition & 0 deletions src/lib/process/tests/process_test.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#!/bin/sh

0 comments on commit 0f298df

Please sign in to comment.