parent
58e685c386
commit
30d3d92276
8 changed files with 108 additions and 56 deletions
@ -1 +1,11 @@ |
||||
SUBDIRS = mrw |
||||
|
||||
include_HEADERS = mrw/auto.hpp mrw/unistd.hpp \ |
||||
mrw/stacktrace.hpp mrw/exception.hpp \ |
||||
mrw/exec.hpp |
||||
data_DATA = AUTHORS NEWS README COPYING INSTALL ChangeLog |
||||
|
||||
webserver: doc dist |
||||
mkdir /home/www/marc/mrw-c++ |
||||
cp mrw/doc/html/* /home/www/marc/mrw-c++/ |
||||
cp @PACKAGENAME@-@MAJOR@.@MINOR@.tar.gz /home/www/marc/mrw-c++/ |
@ -1,22 +1,29 @@ |
||||
#include <mrw/exec.hpp> |
||||
#include <mrw/stacktrace.hpp> |
||||
#include <cppunit/TestFixture.h> |
||||
#include <cppunit/ui/text/TestRunner.h> |
||||
#include <cppunit/extensions/HelperMacros.h> |
||||
#include <cppunit/extensions/TestFactoryRegistry.h> |
||||
#include <string> |
||||
#include <iostream> |
||||
class ExecTest: public CppUnit::TestFixture { |
||||
public: |
||||
void lsTest() { |
||||
std::string res = (mrw::Cmd("/bin/ls"), "-l", "..").execute(); |
||||
CPPUNIT_ASSERT(res.find("COPYING")<res.size()); |
||||
} |
||||
void excTest() { |
||||
std::string res = (mrw::Cmd("/bin/false")).execute().result(); |
||||
} |
||||
CPPUNIT_TEST_SUITE(ExecTest); |
||||
CPPUNIT_TEST(lsTest); |
||||
CPPUNIT_TEST_EXCEPTION(excTest, mrw::ExecutionFailedExc); |
||||
CPPUNIT_TEST_SUITE_END(); |
||||
}; |
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ExecTest); |
||||
|
||||
int main() { |
||||
// std::cout<<"RESULT: "
|
||||
// <<(mrw::Cmd("/bin/ls"), "-l", "/tmp").execute().result()
|
||||
// <<std::endl;
|
||||
try { |
||||
std::cout<<"RESULT: " |
||||
<<(mrw::Cmd("/bin/false")).execute().result() |
||||
<<std::endl; |
||||
} catch (const mrw::exception &x) { |
||||
mrw::StackTrace::createSymtable(); |
||||
std::cout<<"EXCEPTION: ----------------------------------------"<<std::endl |
||||
<<"---------- Reason:"<<std::endl |
||||
<<x.what()<<std::endl |
||||
<<"---------- Stack:"<<std::endl |
||||
<<x.stacktrace()<<std::endl |
||||
<<"---------------------------------------------------"<<std::endl; |
||||
} |
||||
CppUnit::TextUi::TestRunner runner; |
||||
runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); |
||||
return runner.run() ? 0 : 1; |
||||
} |
||||
|
Loading…
Reference in new issue