예제 #1
0
void Scheduler::scheduleAppointment(int time, std::string namePatient, std::string nameDoctor)
{
	if(testTime(time))
	{
		Appointment appointment = Appointment(time, Doctor(nameDoctor), Patient(namePatient));
	}
}
예제 #2
0
void * thread_handler(void * arg)
{
	printf("My tid is %x\n", (int)pthread_self());
	int ret, policy;
	struct sched_param param;

	ret = pthread_getschedparam(pthread_self(), 
		&policy, &param);
	if (ret) {
		printf("get schedparam:%s\n",
			strerror(ret));
		return NULL;	
	}	
	
	if (policy == SCHED_OTHER)
		printf("policy:SCHED_OTHER");
	else if (policy == SCHED_FIFO)	
		printf("policy:SCHED_FIFO");
	else if (policy == SCHED_RR)	
		printf("policy:SCHED_RR");
	printf("\n");	

	struct timeval priv, next;
	gettimeofday(&priv, NULL);
	do_prime(300000007);
	gettimeofday(&next, NULL);

	testTime(&priv, &next);
	return NULL;
}
예제 #3
0
파일: main.cpp 프로젝트: JDongian/EE312
int main (void) {
	visualTests();
	equalityTests();
	specialCaseTests();
	relationalTests();
	algebraicTests();
	testTime();
	printf("The tests are over\n"); 
}
예제 #4
0
int main() {
	try {
		xp::RexImage nyan("files/nyan.xp");

		/*Flatten all layers into one, respecting transparency.*/
		nyan.flatten();

		/*Flip around the R,G,B values.*/
		/*It is also possible to reference a tile by its index into its layer's tile array.*/
		for (int x = 0; x < nyan.getWidth(); x++) {
			for (int y = 0; y < nyan.getHeight(); y++) {
				xp::RexTile original = *nyan.getTile(0, x, y);
				xp::RexTile modified = original;

				modified.fore_red = original.fore_blue;
				modified.fore_blue = original.fore_green;
				modified.fore_green = original.fore_red;

				nyan.setTile(0, x, y, modified);
			}
		}
		nyan.save("cat.xp");
	}
	catch (xp::Rexception& e) {
		std::cerr << "Exception! " << e.what() << " [" << e.code << "]" << std::endl;
	}

	std::cout << "Successfuly saved, modified, and loaded the file." << std::endl;


	/*The following functions test how long it takes to save and load.*/
#define TESTING_TIME 0
#if TESTING_TIME
	/*These files are 10x10, 20x20, etc.*/
	testTime("files\\10");
	testTime("files\\20");
	testTime("files\\40");
	testTime("files\\80");
	testTime("files\\160");
	testTime("files\\320");
	testTime("files\\640");
	testTime("files\\1280");
	testTime("files\\2500"); //Maximum size REXPaint 1.02 allows
#endif
	return EXIT_SUCCESS;
}
예제 #5
0
void CMMFTestVideoDecodeHwDevice::WriteCodedDataL(TVideoInputBuffer* aBuffer)
	{
	TTimeIntervalMicroSeconds testTime(KTestBufferSize);

	// check received buffer against test data
	if (!(aBuffer->iOptions == KTestBufferOptions) ||
		!(aBuffer->iDecodingTimestamp == testTime) ||
		!(aBuffer->iData == KTestBufferString))
		{
		User::Leave(KErrCorrupt);
		}
	}
예제 #6
0
int main(void)
{
	int ret;
	struct timeval priv, next;

	gettimeofday(&priv, NULL);
	func();
	gettimeofday(&next, NULL);

	testTime(&priv, &next);		
	return 0;		
}
예제 #7
0
int main(void)
{
	pthread_t tid;
	int ret;
	pthread_attr_t attr;
	int policy, inher;
	struct sched_param param;

	policy = SCHED_FIFO;
	param.sched_priority = 99;


	pthread_attr_init(&attr);
	
	pthread_attr_getinheritsched(&attr, &inher);
	if (inher == PTHREAD_INHERIT_SCHED)
		printf("Can't change sched policy!\n");
	else if (inher == PTHREAD_EXPLICIT_SCHED)	
		printf("Can change sched policy!\n");
#if 1
	pthread_attr_setinheritsched(&attr, 
		PTHREAD_EXPLICIT_SCHED);

	ret = pthread_attr_setschedpolicy(&attr, policy);
	if (ret) {
		printf("set policy:%s\n",
			strerror(ret));
		exit(1);
	}

	ret = pthread_attr_setschedparam(&attr, &param);
	if (ret) {
		printf("set policy:%s\n",
			strerror(ret));
		exit(1);
	}
#endif
	ret = pthread_create(&tid, &attr,
		thread_handler, NULL);
	if (ret) {
		printf("pthread_create:%s\n",
			strerror(ret));
		exit(1);	
	}
	struct timeval priv, next;
	gettimeofday(&priv, NULL);
	do_prime(300000007);
	gettimeofday(&next, NULL);

	testTime(&priv, &next);
	pthread_exit(NULL);
}
예제 #8
0
int main(int argc, char **argv) {
	testTime();
	printf("\n");
	testClock();
	printf("\n");
	testSysTime();
	printf("\n");
	// TODO: timeofday
	testSet();
	printf("\n");
	testCopy();
	return 0;
}
예제 #9
0
void plot_szsz_n(Hamiltonian* h,cx_vec state,int n,double dt, double T){
    int N=h->get_system_size();
    Gnuplot gp;
    state=h->nat_2_eigen(state); //in eigenbasis transformieren
    ofstream myfile;
    stringstream str;
    str <<"SzSz_"<<h->get_lambda()<<"_"<<h->get_mu()<<".dat";
    myfile.open(str.str().c_str());

    Measurement testMes(h);
    Timeevolver testTime(h);

    myfile << *h;
    myfile << "# T="<<T<<endl;
    myfile << "# dt="<<dt<<endl;
    myfile << "# n="<<n<<endl;
    myfile << endl << "#<S_z*S_z+n>"<<endl;

    for (int i=0;i<N;i++){
        myfile <<testMes.sz_i_sz_in(state,i,n)<<"\t";
    }
    myfile<<endl;
    /*gp <<"reset"<<endl;
    gp <<"set term eps size 8in, 8in"<<endl;
    gp <<"set output '"<<str2.str()<<"'"<<endl;
    gp <<"set noborder"<<endl;
    gp <<"set noborder"<<endl;
    gp <<"set autoscale xfix"<<endl;
    gp <<"set autoscale yfix"<<endl;
    gp <<"set autoscale cbfix"<<endl;
    gp <<"load 'RdBu.plt'"<<endl;
    gp <<"set palette negative"<<endl;
    */ 
    //time translation:
    cout <<endl<<"<><><><><><><><><><><><><><><><>Zeitentwicklung<><><><><><><><><><><><><><><>"<<endl<<endl;
    double t=0;
    while (t<T){
        testTime.time_fw(&state,dt);
        t=t+dt;
        for (int i=0;i<N;i++){
            myfile <<testMes.sz_i_sz_in(state,i,n)<<"\t";
        }
        myfile << endl;
    }
    /*
    gp <<"p '"<<str.str()<<"' matrix with image notitle" <<endl;
    gp <<"set output"<<endl;  
    */
    myfile.close(); 
}
예제 #10
0
void CMMFTestVideoDecodeHwDevice::ConfigureDecoderL(const TVideoPictureHeader& aVideoPictureHeader)
	{
	TTimeIntervalMicroSeconds testTime(KTestInputBufferTimestamp);

	// check the picture header
	if (  (aVideoPictureHeader.iOptions != KTestPictureHeaderOptions)
		||(!(aVideoPictureHeader.iPresentationTimestamp == testTime))
		||(!(*(aVideoPictureHeader.iOptional) == KTestInputBufferData())))
		{
		User::Leave(KErrCorrupt);
		}

	iPictureHeader = aVideoPictureHeader;
	}
예제 #11
0
void KEduVocTextTest::testEqualToOperator()
{
    // This list should be extended when new data members are added to
    // KEduVocTextPrivate.  Appropriate getter/setter methods needs to be
    // provided by KEduVocText.

    KEduVocText t1;
    KEduVocText t2;

    QCOMPARE(t1 == t2, true);

    t1.setText("foo");
    QCOMPARE(t1 == t2, false);
    t2.setText("foo");
    QCOMPARE(t1 == t2, true);

    t1.setPreGrade(1);
    QCOMPARE(t1 == t2, false);
    t2.setPreGrade(1);
    QCOMPARE(t1 == t2, true);

    t1.setGrade(1);
    QCOMPARE(t1 == t2, false);
    t2.setGrade(1);
    QCOMPARE(t1 == t2, true);

    t1.setPracticeCount(1);
    QCOMPARE(t1 == t2, false);
    t2.setPracticeCount(1);
    QCOMPARE(t1 == t2, true);

    t1.setBadCount(1);
    QCOMPARE(t1 == t2, false);
    t2.setBadCount(1);
    QCOMPARE(t1 == t2, true);

    QDateTime testTime(QDateTime::currentDateTime());
    t1.setPracticeDate(testTime);
    QCOMPARE(t1 == t2, false);
    t2.setPracticeDate(testTime);
    QCOMPARE(t1 == t2, true);

    t1.setInterval(1);
    QCOMPARE(t1 == t2, false);
    t2.setInterval(1);
    QCOMPARE(t1 == t2, true);
}
예제 #12
0
void plot_kurz(Hamiltonian* h,cx_vec state,double dt, double T){
    //Gnuplot gp;
    int N=h->get_system_size();
    state=h->nat_2_eigen(state); //in eigenbasis transformieren
    ofstream myfile;
    stringstream str;
    if (N<10)
        str <<"kurzzeit_0"<<N<<".dat";
    else
        str <<"kurzzeit_"<<N<<".dat";
    myfile.open(str.str().c_str());
    Measurement testMes(h);
    Timeevolver testTime(h);
    myfile << *h;
    myfile <<"# T="<<T<<endl;
    myfile <<"# dt="<<dt<<endl;
    myfile << endl << "# t \t <S_z,1>"<<endl;
    cout <<endl<<"<><><><><><><><><><><><><><><><>Zeitentwicklung<><><><><><><><><><><><><><><>"<<endl<<endl;
    double t=0;
    double res=0;
    res = testMes.sz_i(state,1);
    myfile << t << "\t" << res << endl; 
    while (t<T){
        testTime.time_fw(&state,dt);
        t=t+dt;
        res = testMes.sz_i(state,1);
        myfile << t << "\t" << res << endl;
    }
    /* 
    gp <<"reset"<<endl;
    gp <<"set term eps"<<endl;
    gp <<"set output \"kurzzeit.eps\""<<endl;
    gp <<"set samples 2000"<<endl;
    gp <<"set linetype 10"<<endl;
    gp <<"set xrange [0:"<<T<<"]"<<endl;
    gp <<"set yrange [-1:1]"<<endl;
    gp <<"f(x)=-0.5+0.5*x**2"<<endl;
    
    gp <<"p \"kurzzeit.dat\" u 1:2  with lines lc rgb \"red\",f(x),-0.5*besj0(2*x)"<<endl;
    gp <<"set output"<<endl;
    */
   
    myfile.close();
}
예제 #13
0
void plot_groundstate_quench(Hamiltonian* h1, Hamiltonian *h2,double dt, double T){

    int N=h1->get_system_size();
    cx_vec state=ground_state(h1);
    state=h2->nat_2_eigen(state);
    cx_vec state_0=state;
   
    ofstream myfile;
    myfile.open("groundstate.dat");
    myfile << "#groundstate of h1:"<<endl;
    myfile << *h1;
    myfile << "#time evolution with h2:"<<endl;
    myfile << *h2;
    myfile << "# T="<<T<<endl;
    myfile << "# dt="<<dt<<endl;
    myfile << endl << "#t \t <Y0|Yt>"<<endl;
    
    //time translation:
    cout <<endl<<"<><><><><><><><><><><><><><><><>Zeitentwicklung<><><><><><><><><><><><><><><>"<<endl<<endl;
    double t=0;
    double res=0;
    Timeevolver testTime(h2);
    res=norm(cdot(state_0,state));
    myfile << t << "\t" << res << endl;
    while (t<T){
        testTime.time_fw(&state,dt);
        t+=dt;
        res=norm(cdot(state_0,state));
        myfile << t << "\t" << res << endl;
    }
    myfile.close();

    Gnuplot gp;
    gp <<"reset"<<endl;
    gp <<"set term eps"<<endl;
    gp <<"set output \"groundstate.eps\""<<endl;
    gp <<"set samples 2000"<<endl;
    gp <<"set linetype 10"<<endl;
    gp <<"set xrange [0:"<<T<<"]"<<endl;
    gp <<"p \"groundstate.dat\" u 1:2  with lines lc rgb \"red\"  "<<endl;
    gp <<"set output"<<endl;

}
예제 #14
0
void plot_lohschmidt_echo(Hamiltonian *h,cx_vec state,double dt,double T){
    Gnuplot gp;
    state=h->nat_2_eigen(state); //in eigenbasis transformieren
    cx_vec state_0=state;

    ofstream myfile;

    myfile.open("loch1.dat");
    myfile << *h;
    myfile << "# T="<<T<<endl;
    myfile << "# dt="<<dt<<endl;
    
    //time translation:
    cout <<endl<<"<><><><><><><><><><><><><><><><>Zeitentwicklung<><><><><><><><><><><><><><><>"<<endl<<endl;
    double t=0;
    double res=0;
    Timeevolver testTime(h);
    res=norm(cdot(state_0,state));
    myfile << t << "\t" << res << endl;
    while (t<T){
        testTime.time_fw(&state,dt);
        t=t+dt;
        res=norm(cdot(state_0,state));
        myfile << t << "\t" << res << endl;
    }
    myfile.close();
 
    //Gnulot Skript test:
    gp <<"reset"<<endl;
    gp <<"set term eps"<<endl;
    gp <<"set output \"loch1.eps\""<<endl;
    gp <<"set samples 2000"<<endl;
    gp <<"set linetype 10"<<endl;
    gp <<"set xrange [0:"<<T<<"]"<<endl;
    gp <<"p \"loch1.dat\" u 1:2  with lines lc rgb \"red\"  "<<endl;
    gp <<"set output"<<endl;

}
예제 #15
0
파일: testlib.c 프로젝트: TellarHK/wwiv
void testSystemSpecific1( void )
	{
#if 0	/* See comment below */
	const CRYPT_ATTRIBUTE_TYPE testType = -1;
#endif /* 0 */
	int bigEndian;
#ifndef _WIN32_WCE
	int i;
#endif /* WinCE */

	/* Make sure that we've got the endianness set right.  If the machine is
	   big-endian (up to 64 bits) the following value will be signed,
	   otherwise it will be unsigned.  We can't easily test for things like
	   middle-endianness without knowing the size of the data types, but
	   then again it's unlikely we're being run on a PDP-11 */
	bigEndian = ( *( long * ) "\x80\x00\x00\x00\x00\x00\x00\x00" < 0 );
#ifdef DATA_LITTLEENDIAN
	if( bigEndian )
		{
		puts( "The CPU endianness define is set wrong in crypt.h, this "
			  "machine appears to be\nbig-endian, not little-endian.  Edit "
			  "the file and rebuild cryptlib." );
		exit( EXIT_FAILURE );
		}
#else
	if( !bigEndian )
		{
		puts( "The CPU endianness define is set wrong in crypt.h, this "
			  "machine appears to be\nlittle-endian, not big-endian.  Edit "
			  "the file and rebuild cryptlib." );
		exit( EXIT_FAILURE );
		}
#endif /* DATA_LITTLEENDIAN */

	/* Make sure that the compiler doesn't use variable-size enums (done by, 
	   for example, the PalmOS SDK for backwards compatibility with 
	   architectural decisions made for 68K-based PalmPilots) */
	if( sizeof( CRYPT_ALGO_TYPE ) != sizeof( int ) || \
		sizeof( CRYPT_MODE_TYPE ) != sizeof( int ) ||
		sizeof( CRYPT_ATTRIBUTE_TYPE ) != sizeof( int ) )
		{
		puts( "The compiler you are using treats enumerated types as "
			  "variable-length non-\ninteger values, making it impossible "
			  "to reliably pass the address of an\nenum as a function "
			  "parameter.  To fix this you need to rebuild cryptlib\nwith "
			  "the appropriate compiler option or pragma to ensure that\n"
			  "sizeof( enum ) == sizeof( int )." );
		exit( EXIT_FAILURE );
		}

#if 0	/* The ANSI C default is 'int' with signedness being unimportant, 
		   MSVC defaults to signed, gcc defaults to unsigned, and cryptlib
		   works with either, so whatever the CodeSourcery build of gcc is
		   doing it's more serious than a simple signedness issue */
	/* Make sure that the compiler doesn't use unsigned enums (for example a 
	   mutant CodeSourcery build of gcc for eCos does this) */
	if( testType >= 0 )
		{
		puts( "The compiler you are using treats enumerated types as "
			  "unsigned values,\nmaking it impossible to reliably use enums "
			  "in conjunction with standard\n(signed) integers.  To fix this "
			  "you need to rebuild cryptlib with the\nappropriate compiler "
			  "option or pragma to ensure that enumerated types\nare signed "
			  "like standard data types." );
		exit( EXIT_FAILURE );
		}
#endif /* 0 */

	/* Make sure that mktime() works properly (there are some systems on
	   which it fails well before 2038) */
#ifndef _WIN32_WCE
	for( i = 10; i < 36; i ++ )
		{
		const time_t theTime = testTime( i );

		if( theTime < 0 )
			{
			printf( "Warning: This system has a buggy mktime() that can't "
					"handle dates beyond %d.\n         Some certificate tests "
					"will fail, and long-lived CA certificates\n         won't "
					"be correctly imported.\nPress a key...\n", 2000 + i );
			getchar();
			break;
			}
		}
#endif /* !WinCE */

	/* If we're compiling under Unix with threading support, make sure the
	   default thread stack size is sensible.  We don't perform the check for
	   UnixWare/SCO since this already has the workaround applied */
#if defined( UNIX_THREADS ) && !defined( __SCO_VERSION__ )
	{
	pthread_attr_t attr;
	size_t stackSize;

	pthread_attr_init( &attr );
	pthread_attr_getstacksize( &attr, &stackSize );
    pthread_attr_destroy( &attr );
  #if ( defined( sun ) && OSVERSION > 4 )
	/* Slowaris uses a special-case value of 0 (actually NULL) to indicate
	   the default stack size of 1MB (32-bit) or 2MB (64-bit), so we have to
	   handle this specially */
	if( stackSize < 32768 && stackSize != 0 )
  #else
	if( stackSize < 32768 )
  #endif /* Slowaris special-case handling */
		{
		printf( "The pthread stack size is defaulting to %ld bytes, which is "
				"too small for\ncryptlib to run in.  To fix this, edit the "
				"thread-creation function macro in\ncryptos.h and recompile "
				"cryptlib.\n", ( long ) stackSize );
		exit( EXIT_FAILURE );
		}
	}
#endif /* UNIX_THREADS */
	}
TVerdict CTestDevVideoPlayClock::DoTestStepL()
	{
	TVerdict ret = EPass;
	TTimeIntervalMicroSeconds testTime(0);
	TUint timeUint = 0;

	iClockSource = CSystemClockSource::NewL();

	// Construct a new thread to constantly probe the clock - to test that it'll work from multiple threads
	RThread thread;
	
	TInt error = thread.Create(_L("ClockSourceTestThread"), 
								&CTestDevVideoPlayClock::StartThread,
								KDefaultStackSize, 
								&User::Heap(),
								static_cast<TAny*>(this), 
								EOwnerThread);

	if (error)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		delete iClockSource;
		return EInconclusive;
		}

	TRequestStatus stat;
	thread.Logon(stat);
	if (stat!=KRequestPending)
		{
		delete iClockSource;
		ERR_PRINTF2(_L("Error - Couldn't logon to the thread err=%d"), stat.Int());
		thread.LogonCancel(stat);
		User::WaitForRequest(stat);
		return EInconclusive;
		}
	thread.SetPriority(EPriorityLess);

	// wait for system to calm down
	User::After(KTestClock2Seconds);

	// reset the clock
	iClockSource->Reset();

	thread.Resume();

	// wait for 2 seconds and then check the time == 2 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock2Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		ret = EFail;
		}
	else 
		{
		INFO_PRINTF3(_L("Time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		}

	// reset the clock back to 2 seconds
	//testTime = KTestClock2Seconds;
	//iClockSource->Reset(testTime);

	// suspend timer for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock4Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		}

	// reset clock to 18 seconds
	testTime = KTestClock18Seconds;
	iClockSource->Reset(testTime);

	// wait for 2 seconds and then check the time == 20 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock20Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Reset() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Reset() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		}

	// suspend for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock22Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		}

	// Now test the periodic utility
	TRAPD(perError, iPeriodicUtility = CMMFClockSourcePeriodicUtility::NewL(*iClockSource, *this));
	if (perError)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		ret = EInconclusive;
		}
	else
		{
		iPeriodicUtilityTestVerdict = EPass;
		TTimeIntervalMicroSeconds32 period = KTestClock2Seconds;
		iClockSource->Reset();
		iPeriodicUtility->Start(period);
		CActiveScheduler::Start();
		ret = iPeriodicUtilityTestVerdict;
		}
	delete iPeriodicUtility;
	iPeriodicUtility = NULL;

	// Clean up the thread
	iShutdownSubthread = ETrue;
	User::WaitForRequest(stat);
	thread.Close();

	delete iClockSource;

	return ret;
	}