kerneltest/e32test/defrag/t_pagemove.cpp
changeset 4 56f325a607ea
parent 0 a41df078684a
equal deleted inserted replaced
2:4122176ea935 4:56f325a607ea
   369 		StartThreads(numThreads, userDataThread, s, threadFunc, threadArgs);
   369 		StartThreads(numThreads, userDataThread, s, threadFunc, threadArgs);
   370 
   370 
   371 		_T_PRINTF(_L("Move first array page repeatedly\n"));
   371 		_T_PRINTF(_L("Move first array page repeatedly\n"));
   372 		TBool success=EFalse;
   372 		TBool success=EFalse;
   373 		TUint inuse = 0;
   373 		TUint inuse = 0;
   374 		array[0] = array[0];	// Ensure the page of the first entry is paged in for the first move.
   374 		*(volatile TUint8*)array = *array;	// Ensure the page of the first entry is paged in for the first move.
   375 		for (TInt i=0; i < Repitions*2; i++)
   375 		for (TInt i=0; i < Repitions*2; i++)
   376 			{
   376 			{
   377 			TInt r = pagemove.TryMovingUserPage(firstpage, ETrue);
   377 			TInt r = pagemove.TryMovingUserPage(firstpage, ETrue);
   378 			if (i == 0)
   378 			if (i == 0)
   379 				{// If this is the first run allow the pinning threads to 
   379 				{// If this is the first run allow the pinning threads to 
   401 		// be paged in, in most cases it will be at least once.
   401 		// be paged in, in most cases it will be at least once.
   402 		// Pinning the page should always return KErrInUse except for virtually 
   402 		// Pinning the page should always return KErrInUse except for virtually 
   403 		// pinned non-paged memory as virtual pinning is a nop for unpaged memory.
   403 		// pinned non-paged memory as virtual pinning is a nop for unpaged memory.
   404 		test.Printf(_L("inuse test removed; inuse %d\n"),inuse);
   404 		test.Printf(_L("inuse test removed; inuse %d\n"),inuse);
   405 		//test(inuse || aPagedData || state == EVirtualPinning);
   405 		//test(inuse || aPagedData || state == EVirtualPinning);
   406 		test(success || state == EPhysicalPinning || aPagedData);
   406 		test(success || state == EPhysicalPinning);
   407 
   407 
   408 		ThreadDie = ETrue;
   408 		ThreadDie = ETrue;
   409 		EndThreads(numThreads, userDataThread, s);
   409 		EndThreads(numThreads, userDataThread, s);
   410 
   410 
   411 		_T_PRINTF(_L("Validate page data\n"));
   411 		_T_PRINTF(_L("Validate page data\n"));
   455 		RThread* codeRunThread = new RThread[numThreads];
   455 		RThread* codeRunThread = new RThread[numThreads];
   456 		TRequestStatus* s = new TRequestStatus[numThreads];
   456 		TRequestStatus* s = new TRequestStatus[numThreads];
   457 		StartThreads(numThreads, codeRunThread, s, threadFunc, threadArgs);
   457 		StartThreads(numThreads, codeRunThread, s, threadFunc, threadArgs);
   458 
   458 
   459 		_T_PRINTF(_L("Move first code page repeatedly\n"));
   459 		_T_PRINTF(_L("Move first code page repeatedly\n"));
       
   460 		test_Equal(KArbitraryNumber, aFunc());	
   460 		TBool inuse=EFalse, success=EFalse;
   461 		TBool inuse=EFalse, success=EFalse;
   461 		for (TInt i=0; i < Repitions; i++)
   462 		for (TInt i=0; i < Repitions; i++)
   462 			{
   463 			{
   463 			TInt r = aPagemove.TryMovingUserPage(firstpage, ETrue);
   464 			TInt r = aPagemove.TryMovingUserPage(firstpage, ETrue);
   464 			if (i == 0)
   465 			if (i == 0)
   582 			test_KErrNone(threadInitialised.Int());
   583 			test_KErrNone(threadInitialised.Int());
   583 
   584 
   584 			_T_PRINTF(_L("Move page repeatedly\n"));
   585 			_T_PRINTF(_L("Move page repeatedly\n"));
   585 			TBool success=EFalse, pagedOut=EFalse;
   586 			TBool success=EFalse, pagedOut=EFalse;
   586 			TUint inuse=0;
   587 			TUint inuse=0;
   587 			if (!aCode)
   588 			if (aCode)
   588 				aArray[0] = aArray[0];	// Ensure the page of the first entry is paged in for the first move.
   589 				{
       
   590 				test_Equal(KArbitraryNumber, aFunc());
       
   591 				}
       
   592 			else
       
   593 				{
       
   594 				*(volatile TUint8*)aArray = *aArray;
       
   595 				}
       
   596 
   589 			for (TInt i=0; i < Repitions; i++)
   597 			for (TInt i=0; i < Repitions; i++)
   590 				{
   598 				{
   591 				TInt r = aPagemove.TryMovingUserPage(firstpage, ETrue);
   599 				TInt r = aPagemove.TryMovingUserPage(firstpage, ETrue);
   592 				if (i == 0)
   600 				if (i == 0)
   593 					{
   601 					{
   614 			User::WaitForRequest(s);
   622 			User::WaitForRequest(s);
   615 			test.Printf(_L("inuse %d\n"),inuse);
   623 			test.Printf(_L("inuse %d\n"),inuse);
   616 			switch (state)
   624 			switch (state)
   617 				{
   625 				{
   618 				case ENoPinning :
   626 				case ENoPinning :
   619 					test(success || aPaged);
   627 					test(success);
   620 					if (aPaged && realtimeState == User::ERealtimeStateOn)
   628 					if (EExitPanic == accessThread.ExitType())
   621 						{
   629 						{
   622 						test_Equal(EExitPanic, accessThread.ExitType());
       
   623 						test(accessThread.ExitCategory()==_L("KERN-EXEC"));
   630 						test(accessThread.ExitCategory()==_L("KERN-EXEC"));
   624 						test_Equal(EIllegalFunctionForRealtimeThread, accessThread.ExitReason());
   631 						test_Equal(EIllegalFunctionForRealtimeThread, accessThread.ExitReason());
       
   632 						test(aPaged && realtimeState == User::ERealtimeStateOn);
   625 						}
   633 						}
   626 					else
   634 					else
   627 						{
   635 						{
   628 						test_Equal(EExitKill,accessThread.ExitType());
   636 						test_Equal(EExitKill,accessThread.ExitType());
   629 						test_KErrNone(accessThread.ExitReason());
   637 						test_KErrNone(accessThread.ExitReason());
   632 					if (aCode)
   640 					if (aCode)
   633 						{
   641 						{
   634 						test_Equal(KArbitraryNumber, aFunc());
   642 						test_Equal(KArbitraryNumber, aFunc());
   635 						}
   643 						}
   636 					else
   644 					else
   637 						*aArray = *aArray;
   645 						{
       
   646 						*(volatile TUint8*)aArray = *aArray;
       
   647 						}
   638 					break;				
   648 					break;				
   639 				case EVirtualPinning :
   649 				case EVirtualPinning :
   640 					test(!aCode || !inuse);
   650 					test(!aCode || !inuse);
   641 					test(success);
   651 					test(success);
   642 					test(!pagedOut);
   652 					test(!pagedOut);
   914 	User::WaitForRequest(threadInitialised);
   924 	User::WaitForRequest(threadInitialised);
   915 	test_KErrNone(threadInitialised.Int());
   925 	test_KErrNone(threadInitialised.Int());
   916 
   926 
   917 	_T_PRINTF(_L("Move code chunk page repeatedly\n"));
   927 	_T_PRINTF(_L("Move code chunk page repeatedly\n"));
   918 	TBool success=EFalse;
   928 	TBool success=EFalse;
   919 	p[0] = p[0];	// Ensure the page of the first entry is paged in for the first move.
   929 	*(volatile TUint8*)p = *p; // Ensure the page of the first entry is paged in for the first move.
   920 	for (TInt i=0; i < Repitions; i++)
   930 	for (TInt i=0; i < Repitions; i++)
   921 		{
   931 		{
   922 		TInt r = pagemove.TryMovingUserPage(firstpage, ETrue);
   932 		TInt r = pagemove.TryMovingUserPage(firstpage, ETrue);
   923 		if (i == 0)
   933 		if (i == 0)
   924 			{// If this is the first run allow the modifying thread to run now 
   934 			{// If this is the first run allow the modifying thread to run now 
   938 				test_KErrNone(r);
   948 				test_KErrNone(r);
   939 				success=ETrue;
   949 				success=ETrue;
   940 				break;
   950 				break;
   941 			}
   951 			}
   942 		}
   952 		}
   943 	test(success || aPagedData);
   953 	test(success);
   944 
   954 
   945 	ThreadDie = ETrue;
   955 	ThreadDie = ETrue;
   946 	User::WaitForRequest(s);
   956 	User::WaitForRequest(s);
   947 	test_Equal(EExitKill,modCodeThread.ExitType());
   957 	test_Equal(EExitKill,modCodeThread.ExitType());
   948 	test_KErrNone(modCodeThread.ExitReason());
   958 	test_KErrNone(modCodeThread.ExitReason());