PCU_Runner_Status pcu_runner_run() {
   pcu_suite_t* cur;
   unsigned int totalPasses=0; 
   unsigned int totalTests=0; 
   PCU_Runner_Status returnStatus;
   int ii=0;

   for( ii=0; ii<pcu_nlsnrs; ii++ ) {
      pcu_lsnrs[ii]->runbegin( pcu_lsnrs[ii], pcu_nsuites );
   }

   cur = pcu_suites;
   while( cur ) {
      pcu_suite_run( cur, pcu_lsnrs, pcu_nlsnrs );
      totalPasses += cur->npassed;
      totalTests += cur->ntests;
      cur = cur->next;
   }

   for( ii=0; ii<pcu_nlsnrs; ii++ ) {
      pcu_lsnrs[ii]->runend( pcu_lsnrs[ii], pcu_nsuites, totalPasses, totalTests );
   }

   if ( totalPasses == totalTests ) {
      returnStatus = PCU_RUNNER_ALLPASS;
   }
   else {
      returnStatus = PCU_RUNNER_FAILS;
   }
   
   return returnStatus;
}
Exemple #2
0
void pcu_suite_run( pcu_suite_t* suite, pcu_listener_t* lsnr ) {
   /* Must have a listener. */
   assert( lsnr );

   /* Temporarily set the listener, we need this so assert
      macros can work properly. */
   assert( suite );
   suite->lsnr = lsnr;
   suite->npassed = 0;

   /* Run all sub-suites first. */
   if( suite->subsuites ) {
      pcu_suite_t* sub;

      sub = suite->subsuites;
      while( sub ) {
         pcu_suite_run( sub, lsnr );
         sub = sub->next;
      }
   }

   /* Set this as the active suite. */
   pcu_cursuite = suite;

   /* Begin this suite. */
   lsnr->suitebegin( lsnr, suite );

   /* Temporarily set the current test, once again needed
      for assert macros. */
   suite->curtest = suite->tests;

   /* Loop over all the tests. */
   while( suite->curtest ) {
      /* Run the test. */
      if( suite->setup )
	 suite->setup( suite->data );
      pcu_test_run( suite->curtest, lsnr );
      if( suite->teardown )
	 suite->teardown( suite->data );

      /* Move to the next test. */
      suite->curtest = suite->curtest->next;
   }

   /* End the suite. */
   lsnr->suiteend( lsnr, suite );

   /* Clear temporary settings. */
   suite->curtest = NULL;
   suite->lsnr = NULL;
   pcu_cursuite = NULL;
}