diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8919de304dc..0ce49985ac9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 @@ -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 diff --git a/test/base-process.cpp b/test/base-process.cpp new file mode 100644 index 00000000000..38e781357fe --- /dev/null +++ b/test/base-process.cpp @@ -0,0 +1,35 @@ +/* Icinga 2 | (c) 2023 Icinga GmbH | GPLv2+ */ + +#include "base/process.hpp" +#include + +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()