示例#1
0
// Called after a failed assertion or a SUCCESS().
// Print the test header for the first error or
// a continuation line for additional errors.
// Then print the failed test summary.
void TersePrinter::OnTestPartResult(const TestPartResult& test_part_result)
{
	if (test_part_result.failed() )
	{
		if (!test_header_printed_)
		{
			// print the message header
			test_header_printed_ = true;
			PrintTestHeader(COLOR_RED);
			// print the file name
			// the following checks for an error in a mock
			if (test_part_result.file_name() || test_part_result.line_number() > 0)
			{
				printf("%s:(%d)\n",
				       test_part_result.file_name(),
				       test_part_result.line_number());
			}
		}
		else
		{
			ColoredPrintf(COLOR_RED, "%s", "[          ]\n");
		}
		// print the failed test summary
		PrintFailedTestSummary(string(test_part_result.summary()));
		fflush(stdout);
	}
}
示例#2
0
// Called after the test ends.
// Print a summary only if the test failed.
void TersePrinter::OnTestEnd(const TestInfo& test_info)
{
	if (test_info.result()->Passed())
	{
		if (!useTerseOutput)
		{
			// print the message header
			test_header_printed_ = true;
			PrintTestHeader(COLOR_GREEN);
			// print the message trailer
			ColoredPrintf(COLOR_GREEN, "[       OK ] ");
			printf("%s.%s", test_case_name_.c_str(), test_info_name_.c_str());
			// print the test time
			if (GTEST_FLAG(print_time))
				printf(" (%s ms)\n", internal::StreamableToString(
				           test_info.result()->elapsed_time()).c_str());
			else
				printf("\n");
		}
	}
	else
	{
		ColoredPrintf(COLOR_RED, "%s", "[  FAILED  ] ");
		printf("%s.%s\n", test_case_name_.c_str(), test_info_name_.c_str());
	}
	fflush(stdout);
}
示例#3
0
int test_Basic(const char *name, void (*test_fct)(FILE *f, int Ocsp, int Crl), void (*test_virtual)(FILE *f, int Ocsp, int Crl), const char *folder, const char *reader, int bVerify, int Ocsp, int Crl)
{

	PTEID_Status tStatus = {0};
	long lHandle = 0;
	long lRet = 0;
	FILE *f=NULL;
	
	int i = 0;
	int j = 0;

	int iOcsp = 0;
	int iCrl = 0;
	char buffer[50];

	time_t timeStart;
	time_t timeStop;

	time(&timeStart);


	for(i=0;i<3;i++)
	{
		if(Ocsp>=0 && Ocsp<=2)
			i=Ocsp;

		switch(i)
		{
		case 0: iOcsp=PTEID_OCSP_CRL_NOT_USED;	break;
		case 1: iOcsp=PTEID_OCSP_CRL_OPTIONAL;	break;
		case 2: iOcsp=PTEID_OCSP_CRL_MANDATORY;	break;
		}

		for(j=0;j<3;j++)
		{
			if(Crl>=0 && Crl<=2)
				j=Crl;

			switch(j)
			{
			case 0: iCrl=PTEID_OCSP_CRL_NOT_USED;	break;
			case 1: iCrl=PTEID_OCSP_CRL_OPTIONAL;	break;
			case 2: iCrl=PTEID_OCSP_CRL_MANDATORY;	break;
			}

			if(NULL == (f=FileOpen(name, folder, bVerify, i, j)))
				return -1;

			PrintTestHeader(f,name);
			sprintf_s(buffer, sizeof(buffer), "%s (OCSP=%d - CRL=%d)",name,i,j);
			PrintHeader(f,buffer);

			PrintTestFunction(f,"PTEID_Init");
			tStatus = PTEID_Init((char*)reader, iOcsp, iCrl, &lHandle);
			PrintStatus(f,"PTEID_Init",&tStatus);
			if(PTEID_OK != tStatus.general)
			{
				PrintTestFunction(f,"PTEID_Exit");
				tStatus = PTEID_Exit();
				PrintStatus(f,"PTEID_Exit",&tStatus);
				//Don't warn if both parameter are set to mandatory, that's not allow
				if(iOcsp!=PTEID_OCSP_CRL_MANDATORY || iCrl!=PTEID_OCSP_CRL_MANDATORY)
					PrintWARNING(f,"Initialisation failed");
				
				FileClose(f);
				lRet = FileVerify(name, folder, bVerify, i, j);

				if(Crl>=0 && Crl<=2)
					break;
				else
					continue;
			}

			test_fct(f,Ocsp,Crl);

			PrintTestFunction(f,"PTEID_Exit");
			tStatus = PTEID_Exit();
			PrintStatus(f,"PTEID_Exit",&tStatus);

			//Virtual Reader
			if(test_virtual)
			{
 				PrintHeader(f,"INIT VIRTUAL READER");

				PrintTestFunction(f,"PTEID_Init(VIRTUAL)");
				tStatus = PTEID_Init("VIRTUAL", iOcsp, iCrl, &lHandle);
				PrintStatus(f,"PTEID_Init",&tStatus);
				if(PTEID_OK != tStatus.general)
				{
					PrintTestFunction(f,"PTEID_Exit");
					tStatus = PTEID_Exit();
					PrintWARNING(f,"Initialisation failed");
					PrintStatus(f,"PTEID_Exit",&tStatus);

					FileClose(f);
					lRet = FileVerify(name, folder, bVerify, i, j);

					if(Crl>=0 && Crl<=2)
						break;
					else
						continue;
				}

				test_virtual(f,Ocsp,Crl);

				PrintTestFunction(f,"PTEID_Exit");
				tStatus = PTEID_Exit();
				PrintStatus(f,"PTEID_Exit",&tStatus);
			}

			FileClose(f);
			lRet = FileVerify(name, folder, bVerify, i, j);

			if(Crl>=0 && Crl<=2)
				break;
		}

		if(Ocsp>=0 && Ocsp<=2)
			break;
	}

	time(&timeStop);

	printf("TOTAL TEST TIME = %.0lf secondes\n\n",difftime(timeStop,timeStart));

	return lRet;
}