Commit 0a632746 authored by Dorian Guillois's avatar Dorian Guillois
Browse files

Add log into unit test.

parent 77705a23
......@@ -18,11 +18,13 @@
** <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/io/file_stream.hh"
#include "com/centreon/process.hh"
#include "test/connector/misc.hh"
......@@ -106,8 +108,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,8 +18,8 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstdio>
#include <list>
#include <stdio.h>
#include <sstream>
#include "com/centreon/clib.hh"
#include "com/centreon/io/file_stream.hh"
......
......@@ -18,13 +18,15 @@
** <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/io/file_stream.hh"
#include "com/centreon/process.hh"
#include "com/centreon/exceptions/basic.hh"
#include "test/connector/misc.hh"
#include "test/connector/paths.hh"
......@@ -103,8 +105,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,8 +18,8 @@
** <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
#include "com/centreon/exceptions/basic.hh"
#include "test/connector/misc.hh"
......
......@@ -18,10 +18,12 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/paths.hh"
......@@ -86,8 +88,21 @@ int main() {
retval = (p.exit_code() != 0);
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,10 +18,12 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/paths.hh"
......@@ -86,8 +88,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -23,6 +23,7 @@
#include <sstream>
#include <string>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/paths.hh"
......@@ -85,20 +86,26 @@ int main() {
p.terminate();
p.wait();
}
else {
else
retval = (p.exit_code() != 0);
std::cout << "connector exit code: " << p.exit_code() << std::endl;
}
// Cleanup.
clib::unload();
// Data.
std::cout << "output size: " << output.size() << " (expected "
<< (sizeof (RESULT) - 1) << ")" << std::endl;
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
// Compare results.
return (retval
|| (output.size() != (sizeof (RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof (RESULT) - 1)));
return (retval);
}
......@@ -69,6 +69,9 @@ int main(int argc, char* argv[], char* env[]) {
int status;
if (waitpid(child, &status, 0) == child)
retval = !(WIFEXITED(status) && (WEXITSTATUS(status) == 42));
if (retval)
std::cerr << "execute script failed: exit_code=" << retval
<< ", status=" << WEXITSTATUS(status) << std::endl;
// Remove temporary file.
remove(script_path.c_str());
......@@ -79,6 +82,5 @@ int main(int argc, char* argv[], char* env[]) {
catch (...) {
std::cerr << "unknown error" << std::endl;
}
return (retval);
}
......@@ -73,6 +73,9 @@ int main(int argc, char* argv[], char* env[]) {
int status;
if (waitpid(child, &status, 0) == child)
retval = !(WIFEXITED(status) && (WEXITSTATUS(status) == 42));
if (retval)
std::cerr << "execute script failed: exit_code=" << retval
<< ", status=" << WEXITSTATUS(status) << std::endl;
// Remove temporary file.
remove(script_path.c_str());
......@@ -83,6 +86,5 @@ int main(int argc, char* argv[], char* env[]) {
catch (...) {
std::cerr << "unknown error" << std::endl;
}
return (retval);
}
......@@ -18,10 +18,12 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/binary.hh"
......@@ -88,8 +90,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));;
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,8 +18,10 @@
** <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <cstring>
#include <iostream>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/binary.hh"
......@@ -72,8 +74,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));;
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,10 +18,12 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include "com/centreon/clib.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/binary.hh"
......@@ -87,8 +89,21 @@ int main() {
retval = (p.exit_code() != 0);
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
......@@ -18,12 +18,14 @@
** <http://www.gnu.org/licenses/>.
*/
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <string.h>
#include <time.h>
#include "com/centreon/clib.hh"
#include "com/centreon/concurrency/thread.hh"
#include "com/centreon/exceptions/basic.hh"
#include "com/centreon/process.hh"
#include "test/connector/binary.hh"
......@@ -116,8 +118,20 @@ int main() {
clib::unload();
// Compare results.
return (retval
|| (output.size() != (sizeof(RESULT) - 1))
|| (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1)));;
try {
if (retval)
throw (basic_error() << "invalid return code: " << retval);
if (output.size() != (sizeof(RESULT) - 1))
throw (basic_error()
<< "invalid output size: " << output.size()
<< ", output: " << output);
if (memcmp(output.c_str(), RESULT, sizeof(RESULT) - 1))
throw (basic_error() << "invalid output: " << output);
}
catch (std::exception const& e) {
retval = 1;
std::cerr << "error: " << e.what() << std::endl;
}
return (retval);
}
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