From 607d3b980f31c51d3138cc3361c0980f455bd458 Mon Sep 17 00:00:00 2001 From: Tomas Pecka <peckato1@fit.cvut.cz> Date: Tue, 19 Mar 2019 12:52:40 +0100 Subject: [PATCH] alib2integration: Store aql output. Report it on failures #137 --- .../test-src/testing/TimeoutAqlTest.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp b/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp index ee0fa0a029..cd47e92024 100644 --- a/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp +++ b/alib2integrationtest/test-src/testing/TimeoutAqlTest.cpp @@ -6,6 +6,9 @@ #include <unistd.h> #include <sys/wait.h> #include <signal.h> +#include <string.h> + +#include <global/GlobalData.h> #define PIPE_RD 0 #define PIPE_WR 1 @@ -40,9 +43,16 @@ int aqlTest ( int fd, const ext::vector < std::string > & queries ) { try { cli::Environment environment; + std::stringstream ss; + common::Streams::out = ss; + common::Streams::err = ss; + for ( const std::string & q : queries ) { cli::Parser parser = cli::Parser ( cli::Lexer ( q ) ); parser.parse ( ) -> run ( environment ); + + if ( write ( fd, ss.str ( ).c_str ( ), ss.str ( ).length ( ) ) != ( ssize_t ) ss.str ( ).length ( ) ) + throw std::runtime_error ( "TimeoutAqlTest: child output write() failure (child to parent communication)" ); } return environment.getResult ( ); /* 0 = OK */ @@ -125,12 +135,16 @@ void _TimeoutAqlTest ( const std::chrono::microseconds & timeout, const ext::vec close ( pipefd [ PIPE_WR ] ); if ( WIFEXITED ( status ) ) { - // std::cerr << "Child process finished, code " << WEXITSTATUS ( status ) << std::endl; INFO ( "AqlTest failure. Trying to execute: " << queries ); INFO ( "Child output was: >" << childOutput << "<" ); REQUIRE ( WEXITSTATUS ( status ) == 0 ); } else if ( WIFSIGNALED ( status ) ) { - // std::cerr << "Child process signaled, signal ", WTERMSIG ( status ) << std::endl; - WARN ( "Timeout (" << timeout.count ( ) << " us) reached in test (" << queries << ")" ); + if ( WTERMSIG ( status ) == SIGTERM || WTERMSIG ( status ) == SIGKILL ) { /* killed by timeout control */ + WARN ( "Timeout (" << timeout.count ( ) << " us) reached in test (" << queries << ")" ); + } else { + INFO ( "Child process signaled, signal " << WTERMSIG ( status ) << " (" << strsignal ( WTERMSIG ( status ) ) << ")" ); + INFO ( "Child output was: >" << childOutput << "<" ); + FAIL ( ); + } } } -- GitLab