Below is the code I am using to test it
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE ProcessTest
#include <boost/test/unit_test.hpp>
#include "../src/Process.h"
BOOST_AUTO_TEST_CASE( ProcessTest )
{
const std::vector<std::string> commands = {
"ls"
, "pwd"
, "uname -a"
, "cat /proc/cpuinfo"
, "wget https://dl.google.com/dl/earth/client/current/google-earth-pro-stable-current.x86_64.rpm"};
for(const auto& cmd: commands)
{
Process p(cmd, 3600);
p.run();
BOOST_CHECK( p.getReturnStatus() == 0); // #1 continues on error
}
const std::vector<std::string> commandsThatShouldFail = {
"ls doesnotexit"
, "cat /proc/doesnotexist"
, "wget https://dl.google.com/dl/earth/client/current/doesnotxist.rpm"};
for(const auto& cmd: commandsThatShouldFail)
{
Process p(cmd, 3600);
p.run();
BOOST_CHECK( p.getReturnStatus() != 0); // #1 continues on error
}
}
Please provide your valuable comments and suggestions.