Back to index

nordugrid-arc-nox  1.1.0~rc6
RunTest.cpp
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #include <string>
00004 
00005 #include <cppunit/extensions/HelperMacros.h>
00006 
00007 #include <arc/Run.h>
00008 
00009 class RunTest
00010   : public CppUnit::TestFixture {
00011 
00012   CPPUNIT_TEST_SUITE(RunTest);
00013   CPPUNIT_TEST(TestRun0);
00014   CPPUNIT_TEST(TestRun255);
00015   CPPUNIT_TEST_SUITE_END();
00016 
00017 public:
00018   void setUp();
00019   void tearDown();
00020   void TestRun0();
00021   void TestRun255();
00022 
00023 private:
00024 };
00025 
00026 
00027 void RunTest::setUp() {
00028 }
00029 
00030 
00031 void RunTest::tearDown() {
00032 }
00033 
00034 void RunTest::TestRun0() {
00035   std::string outstr;
00036   std::string errstr;
00037   Arc::Run run("./rcode 0");
00038   run.AssignStdout(outstr);
00039   run.AssignStderr(errstr);
00040   CPPUNIT_ASSERT((bool)run);
00041   CPPUNIT_ASSERT(run.Start());
00042   CPPUNIT_ASSERT(run.Wait(10));
00043   CPPUNIT_ASSERT_EQUAL(0, run.Result());
00044   CPPUNIT_ASSERT_EQUAL(std::string("STDOUT"), outstr);
00045   CPPUNIT_ASSERT_EQUAL(std::string("STDERR"), errstr);
00046 }
00047 
00048 void RunTest::TestRun255() {
00049   std::string outstr;
00050   std::string errstr;
00051   Arc::Run run("./rcode 255");
00052   run.AssignStdout(outstr);
00053   run.AssignStderr(errstr);
00054   CPPUNIT_ASSERT((bool)run);
00055   CPPUNIT_ASSERT(run.Start());
00056   CPPUNIT_ASSERT(run.Wait(10));
00057   CPPUNIT_ASSERT_EQUAL(255, run.Result());
00058 }
00059 
00060 CPPUNIT_TEST_SUITE_REGISTRATION(RunTest);
00061