49 #ifdef _SQLPROFILER |
48 #ifdef _SQLPROFILER |
50 TInt TheSqlSrvProfilerFileRead = 0; |
49 TInt TheSqlSrvProfilerFileRead = 0; |
51 TInt TheSqlSrvProfilerFileWrite = 0; |
50 TInt TheSqlSrvProfilerFileWrite = 0; |
52 TInt TheSqlSrvProfilerFileSync = 0; |
51 TInt TheSqlSrvProfilerFileSync = 0; |
53 TInt TheSqlSrvProfilerFileSetSize = 0; |
52 TInt TheSqlSrvProfilerFileSetSize = 0; |
54 #endif |
|
55 |
|
56 #ifdef _DEBUG |
|
57 //SQLite panic category. |
|
58 _LIT(KSqlitePanicCategory, "Sqlite"); |
|
59 #endif |
53 #endif |
60 |
54 |
61 /////////////////////////////////////////////////////////////////////////////////////// |
55 /////////////////////////////////////////////////////////////////////////////////////// |
62 |
56 |
63 void DeleteTestFiles() |
57 void DeleteTestFiles() |
777 TEST2(err, SQLITE_OK); |
771 TEST2(err, SQLITE_OK); |
778 TheTest.Printf(_L("\r\n=== TVfs::Open(<delete on close file>) OOM test succeeded at allcoation %d\r\n"), failingAllocNum); |
772 TheTest.Printf(_L("\r\n=== TVfs::Open(<delete on close file>) OOM test succeeded at allcoation %d\r\n"), failingAllocNum); |
779 User::Free(osFile); |
773 User::Free(osFile); |
780 } |
774 } |
781 |
775 |
782 /////////////////////////////////////////////////////////////////////////////////////// |
|
783 |
|
784 //Panic thread function. |
|
785 //It will cast aData parameter to a TFunctor pointer and call it. |
|
786 //The expectation is that the called function will panic and kill the panic thread. |
|
787 TInt ThreadFunc(void* aData) |
|
788 { |
|
789 CTrapCleanup* tc = CTrapCleanup::New(); |
|
790 TEST(tc != NULL); |
|
791 |
|
792 User::SetJustInTime(EFalse); // disable debugger panic handling |
|
793 |
|
794 TFunctor* obj = reinterpret_cast<TFunctor*> (aData); |
|
795 TEST(obj != NULL); |
|
796 (*obj)();//call the panic function |
|
797 |
|
798 delete tc; |
|
799 |
|
800 return KErrNone; |
|
801 } |
|
802 |
|
803 //Panic test. |
|
804 //PanicTest function will create a new thread - panic thread, giving it a pointer to the function which has to |
|
805 //be executed and the expectation is that the function will panic and kill the panic thread. |
|
806 //PanicTest function will check the panic thread exit code, exit category and the panic code. |
|
807 void PanicTest(TFunctor& aFunctor, TExitType aExpectedExitType, const TDesC& aExpectedCategory, TInt aExpectedPanicCode) |
|
808 { |
|
809 RThread thread; |
|
810 _LIT(KThreadName,"OsLayerPanicThread"); |
|
811 TEST2(thread.Create(KThreadName, &ThreadFunc, 0x2000, 0x1000, 0x10000, (void*)&aFunctor, EOwnerThread), KErrNone); |
|
812 |
|
813 TRequestStatus status; |
|
814 thread.Logon(status); |
|
815 TEST2(status.Int(), KRequestPending); |
|
816 thread.Resume(); |
|
817 User::WaitForRequest(status); |
|
818 User::SetJustInTime(ETrue); // enable debugger panic handling |
|
819 |
|
820 TEST2(thread.ExitType(), aExpectedExitType); |
|
821 TEST(thread.ExitCategory() == aExpectedCategory); |
|
822 TEST2(thread.ExitReason(), aExpectedPanicCode); |
|
823 |
|
824 CLOSE_AND_WAIT(thread); |
|
825 } |
|
826 |
|
827 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
828 ////////////////////////////// Panic test functions ///////////////////////////////////////////////// |
|
829 //////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
830 |
|
831 #ifdef _DEBUG |
|
832 |
|
833 //Panic when calling COsLayerData::Create() is called and the OS layer data has been already created. |
|
834 class TOsLayerDataDuplicated : public TFunctor |
|
835 { |
|
836 private: |
|
837 virtual void operator()() |
|
838 { |
|
839 (void)sqlite3SymbianLibInit();//This should crash the thread in debug mode (because the Os layer |
|
840 //data was created already in TestEnvInit()). |
|
841 } |
|
842 }; |
|
843 static TOsLayerDataDuplicated TheOsLayerDataDuplicated; |
|
844 |
|
845 #endif //_DEBUG |
|
846 |
|
847 /** |
776 /** |
848 @SYMTestCaseID SYSLIB-SQL-CT-1650 |
777 @SYMTestCaseID SYSLIB-SQL-CT-1650 |
849 @SYMTestCaseDesc SQL, OS porting layer tests. |
778 @SYMTestCaseDesc SQL, OS porting layer tests. |
850 @SYMTestPriority High |
779 @SYMTestPriority High |
851 @SYMTestActions SQL, OS porting layer tests. |
780 @SYMTestActions SQL, OS porting layer tests. |
875 VfsOpenTempFileOomTest(); |
804 VfsOpenTempFileOomTest(); |
876 TheTest.Printf(_L("TVfs::Open(<temp file>) file I/O error simulation test\r\n")); |
805 TheTest.Printf(_L("TVfs::Open(<temp file>) file I/O error simulation test\r\n")); |
877 VfsOpenTempFileFileIoErrTest(); |
806 VfsOpenTempFileFileIoErrTest(); |
878 TheTest.Printf(_L("TVfs::Open(<'delete on close' file>) OOM test\r\n")); |
807 TheTest.Printf(_L("TVfs::Open(<'delete on close' file>) OOM test\r\n")); |
879 VfsCreateDeleteOnCloseFileOomTest(); |
808 VfsCreateDeleteOnCloseFileOomTest(); |
880 #ifdef _DEBUG |
|
881 TheTest.Printf(_L("'An attempt to create the OS layer data again' panic\r\n")); |
|
882 PanicTest(TheOsLayerDataDuplicated, EExitPanic, KSqlitePanicCategory, ESqliteOsPanicOsLayerDataExists); |
|
883 #endif //_DEBUG |
|
884 } |
809 } |
885 |
810 |
886 TInt E32Main() |
811 TInt E32Main() |
887 { |
812 { |
888 TheTest.Title(); |
813 TheTest.Title(); |