Skip to content

Commit

Permalink
Process: test exec(3) = E2BIG handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Dec 11, 2023
1 parent 12e1d5d commit 117f4ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(base_test_SOURCES
base-netstring.cpp
base-object.cpp
base-object-packer.cpp
base-process.cpp
base-serialize.cpp
base-shellescape.cpp
base-stacktrace.cpp
Expand Down Expand Up @@ -87,6 +88,7 @@ add_boost_test(base
base_netstring/netstring
base_object/construct
base_object/getself
base_process/e2big
base_serialize/scalar
base_serialize/array
base_serialize/dictionary
Expand Down
35 changes: 35 additions & 0 deletions test/base-process.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Icinga 2 | (c) 2023 Icinga GmbH | GPLv2+ */

#include "base/process.hpp"
#include <BoostTestTargetConfig.h>

using namespace icinga;

BOOST_AUTO_TEST_SUITE(base_process)

BOOST_AUTO_TEST_CASE(e2big)
{
#ifndef _WIN32
String placeHolder = "x";

for (int i = 0; i < 23; ++i) {
placeHolder += placeHolder; // 2^23 = 8388608 > ARG_MAX
}

Process::Ptr p = new Process(
{"echo", "truncated_" + placeHolder + "Y", "untouched"},
nullptr,
{"_" + placeHolder + "Y"}
);

p->SetTimeout(60 * 60);
p->Run();

auto& out (p->WaitForResult().Output);

BOOST_CHECK(out.Contains("truncated"));
BOOST_CHECK(out.Contains("x untouched"));
#endif /* _WIN32 */
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 117f4ec

Please sign in to comment.