Unverified Commit 2e3b87b1 authored by David Boucher's avatar David Boucher Committed by GitHub
Browse files

fix(perl): unit test broken

* fix(conan): libraries harmonized with engine
* test(perl): tests fixed to match last changes in clib.
* chore(doc): New release 20.10.1
* chore(doc): A typo introduced in the CHANGELOG
* fix(cmake): C++11 ABI used if available.

REFS: MON-6508
parent 6caaf5a2
# Changelog
## 20.10.1
`release date`
### Bug fixes
*Unit tests*
Unit tests have been updated due to changes in the clib.
......@@ -2,12 +2,12 @@
cmake_minimum_required(VERSION 2.8.12)
project(connectors CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=0")
add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")
set(CONNECTOR_MAJOR 20)
set(CONNECTOR_MINOR 10)
set(CONNECTOR_PATCH 0)
set(CONNECTOR_PATCH 1)
set(CONNECTOR_VERSION "${CONNECTOR_MAJOR}.${CONNECTOR_MINOR}.${CONNECTOR_PATCH}")
add_definitions(-DCENTREON_CONNECTOR_VERSION=\"${CONNECTOR_VERSION}\")
......
[requires]
gtest/1.8.1@bincrafters/stable
spdlog/1.4.2@bincrafters/stable
fmt/7.1.2
spdlog/1.8.1
[generators]
cmake_paths
......
......@@ -90,17 +90,9 @@ static constexpr const char scripts[] =
class TestConnector : public testing::Test {
public:
process p;
void SetUp() override{};
void TearDown() override{};
void launch_process(std::string const& process_name) {
p.enable_stream(process::in, true);
p.enable_stream(process::out, true);
p.enable_stream(process::err, false);
p.exec(process_name.c_str());
}
TestConnector() : testing::Test(), p(nullptr, true, true, false) {}
int wait_for_termination() {
// Wait for process termination.
......@@ -122,7 +114,7 @@ class TestConnector : public testing::Test {
size -= rb;
ptr += rb;
}
p.enable_stream(process::in, false);
p.update_ending_process(0);
}
std::string read_reply() {
......@@ -164,14 +156,17 @@ class TestConnector : public testing::Test {
// Close handle.
fclose(f);
}
protected:
process p;
};
TEST_F(TestConnector, EofOnStdin) {
// Process.
launch_process(perl_connector);
p.enable_stream(process::in, false);
p.exec(perl_connector);
p.update_ending_process(0);
int retval{wait_for_termination()};
int retval = wait_for_termination();
ASSERT_EQ(retval, 0);
}
......@@ -189,7 +184,7 @@ TEST_F(TestConnector, ExecuteModuleLoading) {
"exit 0;\n");
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Write command.
std::ostringstream oss;
......@@ -220,7 +215,7 @@ TEST_F(TestConnector, ExecuteMultipleScripts) {
}
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Generate command string.
std::string cmd;
......@@ -265,7 +260,7 @@ TEST_F(TestConnector, ExecuteSingleScript) {
"exit 0;\n");
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Write command.
std::ostringstream oss;
......@@ -304,7 +299,7 @@ TEST_F(TestConnector, ExecuteSingleScriptLogFile) {
"exit 0;\n");
// Process.
launch_process(perl_connector + " --log-file /tmp/log_file");
p.exec(perl_connector + " --log-file /tmp/log_file");
// Write command.
std::ostringstream oss;
......@@ -347,7 +342,7 @@ TEST_F(TestConnector, ExecuteWithAdditionalCode) {
"exit 0;\n");
// Process.
launch_process(
p.exec(
perl_connector +
" --code 'package Centreon::Test; our $company=\"Centreon\"; our "
"$attribute=\"wonderful\";'");
......@@ -374,7 +369,7 @@ TEST_F(TestConnector, ExecuteWithAdditionalCode) {
TEST_F(TestConnector, NonExistantScript) {
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Write command.
std::ostringstream oss;
......@@ -400,7 +395,7 @@ TEST_F(TestConnector, NonExistantScript) {
*/
TEST_F(TestConnector, TimeoutKill) {
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Write command.
std::ostringstream oss;
......@@ -420,7 +415,7 @@ TEST_F(TestConnector, TimeoutKill) {
TEST_F(TestConnector, TimeoutTerm) {
// Process.
launch_process(perl_connector);
p.exec(perl_connector);
// Write command.
std::ostringstream oss;
......
......@@ -36,14 +36,15 @@ using namespace com::centreon::connector::perl;
int main(int argc, char* argv[], char **env) {
// GTest initialization.
testing::InitGoogleTest(&argc, argv);
PERL_SYS_INIT3(&argc, &argv, &env);
embedded_perl::load(&argc, &argv, &env);
// Run all tests.
int ret = RUN_ALL_TESTS();
PERL_SYS_TERM();
PL_perl_destruct_level = 1;
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
my_perl = nullptr;
// Unload.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment