Skip to content
Snippets Groups Projects
Commit eea85068 authored by Tomáš Pecka's avatar Tomáš Pecka Committed by Jan Trávníček
Browse files

alib2integration: Store aql output. Report it on failures #137

parent fccf1d93
No related branches found
No related tags found
1 merge request!73Dev jt
......@@ -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 ( );
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment