persistentstorage/sql/TEST/t_sqlprivcage.cpp
changeset 55 44f437012c90
parent 29 cce6680bbf1c
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    62 			TName name = th.Name();
    62 			TName name = th.Name();
    63 			RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine);
    63 			RDebug::Print(_L("*** Thread %S, Line %d\r\n"), &name, aLine);
    64 			}
    64 			}
    65 		else
    65 		else
    66 			{
    66 			{
    67 			RDebug::Print(_L("*** Line %d\r\n"), aLine);
    67 			TheTest.Printf(_L("*** Line %d. Expression evaluated to false\r\n"), aLine);
    68 			}
    68 			}
    69 		TheTest(EFalse, aLine);
    69 		TheTest(EFalse, aLine);
    70 		}
    70 		}
    71 	}
    71 	}
    72 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse)
    72 void Check2(TInt aValue, TInt aExpected, TInt aLine, TBool aPrintThreadName = EFalse)
    80 			TName name = th.Name();
    80 			TName name = th.Name();
    81 			RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue);
    81 			RDebug::Print(_L("*** Thread %S, Line %d Expected error: %d, got: %d\r\n"), &name, aLine, aExpected, aValue);
    82 			}
    82 			}
    83 		else
    83 		else
    84 			{
    84 			{
    85 			RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    85 			TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    86 			}
    86 			}
    87 		TheTest(EFalse, aLine);
    87 		TheTest(EFalse, aLine);
    88 		}
    88 		}
    89 	}
    89 	}
    90 #define TEST(arg) ::Check1((arg), __LINE__)
    90 #define TEST(arg) ::Check1((arg), __LINE__)
   531 	//Run a test thread which will begin a transaction and then simulate a crash within the transaction
   531 	//Run a test thread which will begin a transaction and then simulate a crash within the transaction
   532 	TEST2(ThreadCritSect.CreateLocal(), KErrNone);
   532 	TEST2(ThreadCritSect.CreateLocal(), KErrNone);
   533 	ThreadCritSect.Wait();
   533 	ThreadCritSect.Wait();
   534 	TEST2(MainCritSect.CreateLocal(), KErrNone);
   534 	TEST2(MainCritSect.CreateLocal(), KErrNone);
   535 	MainCritSect.Wait();
   535 	MainCritSect.Wait();
   536 	RDebug::Print(_L("+++:MainThread: Create the worker thread\r\n"));
   536 	TheTest.Printf(_L("+++:MainThread: Create the worker thread\r\n"));
   537 	_LIT(KThreadName, "WorkThrd");
   537 	_LIT(KThreadName, "WorkThrd");
   538 	RThread thread;
   538 	RThread thread;
   539 	TEST2(thread.Create(KThreadName, &ThreadFunc1, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone);
   539 	TEST2(thread.Create(KThreadName, &ThreadFunc1, 0x2000, 0x1000, 0x10000, NULL, EOwnerProcess), KErrNone);
   540 	TRequestStatus status;
   540 	TRequestStatus status;
   541 	thread.Logon(status);
   541 	thread.Logon(status);
   542 	TEST2(status.Int(), KRequestPending);
   542 	TEST2(status.Int(), KRequestPending);
   543 	thread.Resume();
   543 	thread.Resume();
   544 	RDebug::Print(_L("+++:MainThread: Wait SQL statement(s) to be executed...\r\n"));
   544 	TheTest.Printf(_L("+++:MainThread: Wait SQL statement(s) to be executed...\r\n"));
   545 	MainCritSect.Wait();
   545 	MainCritSect.Wait();
   546 	RDebug::Print(_L("+++:MainThread: Notify the worker thread to simulate a crash...\r\n"));
   546 	TheTest.Printf(_L("+++:MainThread: Notify the worker thread to simulate a crash...\r\n"));
   547 	ThreadCritSect.Signal();
   547 	ThreadCritSect.Signal();
   548 	User::WaitForRequest(status);
   548 	User::WaitForRequest(status);
   549 	User::SetJustInTime(ETrue);	// enable debugger panic handling
   549 	User::SetJustInTime(ETrue);	// enable debugger panic handling
   550 	TEST2(thread.ExitType(), EExitPanic);
   550 	TEST2(thread.ExitType(), EExitPanic);
   551 	TEST2(thread.ExitReason(), KPanicCode);
   551 	TEST2(thread.ExitReason(), KPanicCode);