proj home

Files   Classes   Functions   Hierarchy  

systemcallstest Class Reference

Test systemcalls class. More...

#include <systemcallstest.h>

Collaboration diagram for systemcallstest:

List of all members.

Static Public Member Functions

static void developmenttest01 ()
 Printing local directory.
static void developmenttest02 ()
 Running a perl tool.
static void developmenttest03 ()
 Running a perl tool and redirecting output to a file.
static void developmenttest04 ()
 Using systemcall, running a perl tool.
static int unittest01 ()
 Unit test systemcalls.

Static Public Attributes

static string doc []
 Brief description of each test.


Detailed Description

Test systemcalls class.

Definition at line 8 of file systemcallstest.h.


Member Function Documentation

void systemcallstest::developmenttest01 (  )  [static]

Printing local directory.

Definition at line 23 of file systemcallstest.cpp.

Referenced by main().

00024 {
00025   system("pwd");
00026 }

void systemcallstest::developmenttest02 (  )  [static]

Running a perl tool.

Definition at line 28 of file systemcallstest.cpp.

Referenced by main().

00029 {
00030   string s1="perl ../makefilebuildtool/extractheaders.pl ../vrml/vrmlshape.h";
00031 
00032   system(s1.c_str());
00033 }

void systemcallstest::developmenttest03 (  )  [static]

Running a perl tool and redirecting output to a file.

Definition at line 35 of file systemcallstest.cpp.

Referenced by main().

00036 {
00037   string s1="perl ../makefilebuildtool/extractheaders.pl ../vrml/vrmlshape.h";
00038   string filename("tempheaders.txt");
00039   s1 += " > ";
00040   s1 += filename;
00041 
00042   system(s1.c_str());
00043 
00044   ifstream in(filename.c_str());
00045 
00046   string str;
00047   vector<string> lines;
00048   while (in)
00049   {
00050     getline(in,str);
00051     if (str.length() > 0)
00052       lines.push_back(str);
00053   }
00054 
00055   for (uint i=0; i<lines.size(); ++i)
00056   {
00057     cout << "*" << lines[i] << "*" << endl;
00058   }
00059 }

void systemcallstest::developmenttest04 (  )  [static]

Using systemcall, running a perl tool.

Definition at line 61 of file systemcallstest.cpp.

References systemcalls::eval(), and systemcalls::lines.

Referenced by main().

00062 {
00063   systemcalls sys01
00064   (
00065     "perl ../makefilebuildtool/extractheaders.pl ../vrml/vrmlshape.h",
00066     "tempheaders.txt"
00067   );
00068 
00069   cout << "Doing the system call" << endl;
00070   sys01.eval();
00071 
00072   cout<< "Printing the output." << endl;
00073  
00074 
00075   for (uint i=0; i<sys01.lines.size(); ++i)
00076   {
00077     cout << "*" << sys01.lines[i] << "*-" << endl;
00078   }
00079 }

int systemcallstest::unittest01 (  )  [static]

Unit test systemcalls.

Definition at line 81 of file systemcallstest.cpp.

References assertreturnOS, systemcalls::eval(), exitint::exitstatus, systemcalls::lines, print(), and SHOW.

Referenced by main().

00082 {
00083   {
00084     cout << "TEST 1.1" << endl;
00085     systemcalls sys
00086     (
00087       "find . -name \"*.z\"",
00088       "/tmp/temp.txt"
00089     );
00090 
00091     cout << SHOW(sys.exitstatus) << endl;
00092     sys.eval();
00093     cout << SHOW(sys.exitstatus) << endl;
00094     cout << print(sys.lines,"\n") << endl;
00095 
00096     assertreturnOS(sys.exitstatus==0);
00097   }
00098 /*
00099 
00100   {
00101     cout << "TEST 1.2" << endl;
00102     systemcalls sys
00103     (
00104       "nonexistantcommand",
00105       "/tmp/temp.txt"
00106     );
00107     sys.eval();
00108     cout << SHOW(sys.exitstatus) << endl;
00109     assertreturnOS(!sys.isvalid());
00110   }
00111 
00112   {
00113     cout << "TEST 1.3" << endl;
00114     string text=systemcallseval("echo `date +%Y`").output();
00115     cout << text << endl;
00116   }
00117 
00118   {
00119     cout << "TETS 1.4 1.5 1.6 demonstrate difficulty with exit codes" << endl;
00120     cout << "  The exit status is not being captured, but can be explicitly output through bash's $?" << endl;
00121 
00122     cout << "TEST 1.4" << endl;
00123     systemcalls sys("make -f fku; echo \<exitstatus\>$?\</exitstatus\>","temp01.txt");
00124     sys.combine=true;
00125     sys.eval();
00126     string text = sys.output();
00127     cout << SHOW3(text) << endl;
00128   }
00129 
00130   {
00131     cout << "TEST 1.5" << endl;
00132     systemcalls sys("make -f fku 2>./temp02.txt; echo \<exitstatus\>$?\</exitstatus\>","temp01.txt");
00133 //    sys.combine=true;
00134     sys.eval();
00135     cout << SHOW(sys.exitstatus) << endl;
00136     assertreturnOS(sys.exitstatus==0); // status associated with echo
00137     string text = sys.output();
00138     cout << SHOW3(text) << endl;
00139   }
00140 
00141   {
00142     cout << "TEST 1.6" << endl;
00143     systemcalls sys("make -f fku","temp01.txt");
00144     sys.combine=true;
00145     sys.eval();
00146     cout << SHOW(sys.exitstatus) << endl;
00147     assertreturnOS(sys.exitstatus!=0); // The file make is trying to compile does not exist.
00148     string text = sys.output();
00149     cout << SHOW3(text) << endl;
00150   }
00151 */
00152     
00153   return 0;
00154 }


Member Data Documentation

string systemcallstest::doc [static]

Initial value:

 
{
  "",
  "Printing local directory.",
  "Running a perl tool.",
  "Running a perl tool and redirecting output to a file.",
  "Using systemcall, running a perl tool.",
  "Unit test systemcalls"
}
Brief description of each test.

Definition at line 13 of file systemcallstest.h.

Referenced by main().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:18 2011 for Chelton Evans Source by  doxygen 1.5.8