void Pipeline_Run_Test::test_tar () { size_t errorc = 0; Filter f ("tar", "/bin/tar"); Argument *a[] = { new Argument ("/usr/local/tmp/file1", true, &f), new Argument ("/usr/local/tmp/file2", true, &f) }; Option *o[] = { new Option (&f, "-cvf", "/home/kare/tmp/store/file_pipeline_ut.tar") }; f.add_argument (o[0]); f.add_argument (a[0]); f.add_argument (a[1]); _filters.push_back (&f); try { CPPUNIT_ASSERT (_pipeline.push (_filters.begin (),_filters.end ()) == EXIT_SUCCESS); CPPUNIT_ASSERT (_pipeline.push (_filters.begin (),_filters.end () - 1) == EXIT_FAILURE); /// Empty pipeline _filters.clear (); } CATCH_ERROR_PCHAR; }
void Pipeline_Run_Test::test_first_child_exit_failure () { uint errorc = 0; int status = EXIT_SUCCESS; Filter f ("rm", "/bin/rm"); Argument *a = new Argument ("...", true, &f); f.add_argument (a); _filters.push_back (&f); try { status = _pipeline.push (_filters.begin (), _filters.end ()); CPPUNIT_ASSERT (status == EXIT_FAILURE); // std::cerr << status << std::endl; // CPPUNIT_ASSERT (status == 127); } CATCH_ERROR_PCHAR; _filters.clear (); // return; Pipeline p[] = { "ls ...", "ls ./..." }; CPPUNIT_ASSERT (p[0].execute () == 2); CPPUNIT_ASSERT (p[1].execute () == 2); }
void Pipeline_Run_Test::test_first_child_exit_success () { pid_t pid; uint errorc = 0; int status = EXIT_FAILURE; Filter f ("ls", "/bin/ls"); Argument *a = new Argument ("..", true, &f); f.add_argument (a); _filters.push_back (&f); try { status = _pipeline.push (_filters.begin (), _filters.end ()); CPPUNIT_ASSERT (status == EXIT_SUCCESS); } CATCH_ERROR_PCHAR; _filters.clear (); Pipeline p[] = { "ls .", "ls .." }; CPPUNIT_ASSERT (p[0].execute () == EXIT_SUCCESS); CPPUNIT_ASSERT (p[1].execute () == EXIT_SUCCESS); }