#include <cstdlib>
#include <cstring>
+#include <cerrno>
#include <fcntl.h>
#include <fstream>
#include <memory>
close(WRITE);
int ret;
- if ((ret= pipe(_fd)) < 0)
+ if (pipe(_fd) == -1)
{
- throw strerror(ret);
+ throw strerror(errno);
}
_open[0]= true;
_open[1]= true;
{
- ret= fcntl(_fd[0], F_GETFL, 0);
- if (ret == -1)
+ if ((ret= fcntl(_fd[0], F_GETFL, 0)) == -1)
{
- Error << "fcntl(F_GETFL) " << strerror(ret);
- throw strerror(ret);
+ Error << "fcntl(F_GETFL) " << strerror(errno);
+ throw strerror(errno);
}
- ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK);
- if (ret == -1)
+ if ((ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK)) == -1)
{
- Error << "fcntl(F_SETFL) " << strerror(ret);
- throw strerror(ret);
+ Error << "fcntl(F_SETFL) " << strerror(errno);
+ throw strerror(errno);
}
}
}
if (_open[type])
{
int ret;
- if ((ret= ::close(_fd[type])) < 0)
+ if (::close(_fd[type]) == -1)
{
- Error << "close(" << strerror(ret) << ")";
+ Error << "close(" << strerror(errno) << ")";
}
_open[type]= false;
+ _fd[type]= -1;
}
}
void Application::delete_argv()
{
- if (built_argv == NULL)
- {
- return;
- }
-
- for (size_t x= 0; x < _argc; x++)
+ if (built_argv)
{
- if (built_argv[x])
+ for (size_t x= 0; x < _argc; x++)
{
- ::free(built_argv[x]);
+ if (built_argv[x])
+ {
+ ::free(built_argv[x]);
+ }
}
+ delete[] built_argv;
+ built_argv= NULL;
+ _argc= 0;
}
- delete[] built_argv;
- built_argv= NULL;
- _argc= 0;
}
@libtest/unittest
valgrind-unittest: libtest/unittest
- @$(VALGRIND_COMMAND) libtest/unittest
+ @$(VALGRIND_COMMAND) libtest/unittest TESTS_ENVIRONMENT="valgrind"
gdb-unittest: libtest/unittest
@$(GDB_COMMAND) libtest/unittest
if (Application::SUCCESS != (ret= app.wait()))
{
- Error << "Application::wait() " << app.print() << " " << ret;
+ Error << "Application::wait() " << _running << " " << ret;
return false;
}
#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
test_compare(Application::FAILURE, true_app.wait());
#else
- test_compare(Application::INVALID, true_app.wait());
+ if (getenv("TESTS_ENVIRONMENT") and strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
+ {
+ test_compare(Application::FAILURE, true_app.wait());
+ }
+ else
+ {
+ test_compare(Application::INVALID, true_app.wait());
+ }
#endif
}
test_compare(0, true_app.stdout_result().size());