void GetResolvedDllInfo_OOMTestL()
	{
	TInt processHandlesS = 0;
	TInt threadHandlesS = 0;
	TInt processHandlesE = 0;
	TInt threadHandlesE = 0;
	RThread().HandleCount(processHandlesS, threadHandlesS);

	CEComServer* ecomServer = CEComServer::NewLC();
	TClientRequest clientReq;
	RArray<TUid> extendedInterfaces;
	CleanupClosePushL(extendedInterfaces);
	RImplInfoArray* implInfoArray = ecomServer->ListImplementationsL(KCExampleInterfaceUid,extendedInterfaces,clientReq);
	CleanupStack::PopAndDestroy(&extendedInterfaces);

	TEST(implInfoArray->Count() > 0);

	for(TInt count=1;;++count)
		{
		// Setting Heap failure for OOM test
		__UHEAP_SETFAIL(RHeap::EDeterministic, count);
		__UHEAP_MARK;

		TEntry dllInfo;
		TUid dtorIdKey;
		TClientRequest clntRq;
		CImplementationInformation* info = (*implInfoArray)[0];
		TRAPD(err, ecomServer->GetResolvedDllInfoL(info->ImplementationUid(),
												   dllInfo, dtorIdKey, clntRq));
		if(err == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if(err == KErrNone)
			{
			__UHEAP_MARKEND;
			RDebug::Print(_L("The test succeeded at heap failure rate=%d.\n"), count);
			break;
			}
		else
			{
			__UHEAP_MARKEND;
			TEST2(err, KErrNone);
			}
		__UHEAP_RESET;
		}
	__UHEAP_RESET;
	//implInfoArray should be deleted! The caller takes the ownership.
	if (implInfoArray!=NULL)
		{
		implInfoArray->Close();
		delete implInfoArray;
		}
	CleanupStack::PopAndDestroy(ecomServer);
	RThread().HandleCount(processHandlesE, threadHandlesE);
	TEST(processHandlesS == processHandlesE);
	TEST(threadHandlesS == threadHandlesE);
	}
Example #2
0
CELL *
bi_substr(CELL * sp)
{
    int n_args, len;
    register int i, n;
    STRING *sval;		/* substr(sval->str, i, n) */

    n_args = sp->type;
    sp -= n_args;
    if (sp->type != C_STRING)
	cast1_to_s(sp);
    /* don't use < C_STRING shortcut */
    sval = string(sp);

    if ((len = (int) sval->len) == 0)	/* substr on null string */
    {
	if (n_args == 3) {
	    cell_destroy(sp + 2);
	}
	cell_destroy(sp + 1);
	return sp;
    }

    if (n_args == 2) {
	n = MAX__INT;
	if (sp[1].type != C_DOUBLE)
	    cast1_to_d(sp + 1);
    } else {
	if (TEST2(sp + 1) != TWO_DOUBLES)
	    cast2_to_d(sp + 1);
	n = d_to_i(sp[2].dval);
    }
    i = d_to_i(sp[1].dval) - 1;	/* i now indexes into string */

    /*
     * Workaround in case someone's written a script that does substr(0,last-1)
     * by transforming it into substr(1,last).
     */
    if (i < 0) {
	n -= i + 1;
	i = 0;
    }
    if (n > len - i) {
	n = len - i;
    }

    if (n <= 0)			/* the null string */
    {
	sp->ptr = (PTR) & null_str;
	null_str.ref_cnt++;
    } else {			/* got something */
	sp->ptr = (PTR) new_STRING0((size_t) n);
	memcpy(string(sp)->str, sval->str + i, (size_t) n);
    }

    free_STRING(sval);
    return sp;
}
/**
@SYMTestCaseID			SYSLIB-SQL-UT-4058
@SYMTestCaseDesc		Background compaction - configuration test.
						The test creates a database with a background compaction mode.
						The test reopens the database and verifies that the compaction mode is persistent and is still background.
						Then the test reopens the database using different compaction mode in the configuration string and 
						verifies that the original (background) compaction mode cannot be changed when the database is opened.
@SYMTestPriority		Medium
@SYMTestActions			Background compaction - configuration test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ10274
*/
void CompactConfigTest3L()
	{
	//Create a test database with "background" compaction mode
	_LIT8(KConfigStr1, "encoding=utf-8;compaction=background");
	TInt err = TheDb.Create(KTestDbName1, &KConfigStr1);
	TEST2(err, KErrNone);
	//Check the vacuum mode. The SQLite vacuum mode should be "incremental"
	TSqlScalarFullSelectQuery scalarQuery(TheDb);
	TInt compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
	TEST2(compact, KIncrementalVacuum);
	TheDb.Close();
	//Close and open the database again. The SQLite vacuum mode should be "incremental".
	err = TheDb.Open(KTestDbName1);
	TEST2(err, KErrNone);
	scalarQuery.SetDatabase(TheDb);
	compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
	TEST2(compact, KIncrementalVacuum);
	TheDb.Close();
	//Close and open the database again with a config string with "manual" compaction mode. 
	//The SQLite vacuum mode should stay unchanged.
	_LIT8(KConfigStr2, "compaction=manual");
	err = TheDb.Open(KTestDbName1, &KConfigStr2);
	TEST2(err, KErrNone);
	scalarQuery.SetDatabase(TheDb);
	compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
	TEST2(compact, KIncrementalVacuum);
	TheDb.Close();
	//Delete database
	err = RSqlDatabase::Delete(KTestDbName1);
	TEST2(err, KErrNone);
	}
Example #4
0
/**
@SYMTestCaseID			SYSLIB-SQLITE3-UT-4021
@SYMTestCaseDesc		SQLite library multi-select performance test.
						The test selects 100 records and stores 
						the execution time for later use (comparison and printing).
						The IDs of the selected records are exactly the same as the IDs of the selected
						records, used by SYSLIB-SQLITE3-UT-4013 test case.
						The results of this test case will be compared against the results of
						the SYSLIB-SQLITE3-UT-4013 test case - "SQL server multi-select performance test".
@SYMTestPriority		High
@SYMTestActions			SQLite library multi-select performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ8782
*/
void SqliteMultiSelectTest(TPerfTestMode aPerfTestMode, const char aSelectSql[], int aSelectRecIds[], int aSelectRecCnt)
	{
	int err;
	const char* tail = 0;
	sqlite3_stmt* stmt = 0;
	int recCnt = 0;
	unsigned int fc;
	
	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
	TEST(!TheDb2);
	err = sqlite3_open(TestDbName(), &TheDb2);
	TEST2(err, SQLITE_OK);
	ExecSqliteConfig(aPerfTestMode);

	FormatSqlStmt(TheSqlBuf2, aSelectSql, aSelectRecIds, aSelectRecCnt);

	err = sqlite3_prepare(TheDb2, TheSqlBuf2, -1, &stmt, &tail);
	TEST2(err, SQLITE_OK);
	
	fc = FastCounterValue();
	while((err = sqlite3_step(stmt)) == SQLITE_ROW)
		{
		__int64 i64;
		double d;
		const unsigned short* t;
		const unsigned char* b;
		
		i64 = sqlite3_column_int64(stmt, 0);
		UNUSED_VAR(i64);
		d = sqlite3_column_double(stmt, 1);
		UNUSED_VAR(d);
		t = (const unsigned short*)sqlite3_column_text16(stmt, 2);
		UNUSED_VAR(t);
		b = (const unsigned char*)sqlite3_column_blob(stmt, 3);
		UNUSED_VAR(b);
		++recCnt;
		}
	StorePerfTestResult(aPerfTestMode, EPerfTestMultiSelect, FastCounterValue() - fc);
	TEST2(err, SQLITE_DONE);
	TEST2(recCnt, aSelectRecCnt);

	sqlite3_finalize(stmt);	
	sqlite3_close(TheDb2);
	TheDb2 = 0;
	}
/**
@SYMTestCaseID			SYSLIB-SQL-UT-4063
@SYMTestCaseDesc		Compaction configuration test - attached database.
						The test creates a database with an auto compaction mode.
						Then the test attaches the same database.
						The test verifies that the compaction mode of the main and the attached database is the same - auto.
@SYMTestPriority		Medium
@SYMTestActions			Compaction configuration test - attached database.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ10273
                        REQ10274
                        REQ10400
*/
void CompactConfigTest8L()
	{
	//Create a test database with "auto" compaction mode
	_LIT8(KConfigStr1, "; ;; ; compaction  =   auto; ");
	TInt err = TheDb.Create(KTestDbName1, &KConfigStr1);
	TEST2(err, KErrNone);
	//Attach a database
	err = TheDb.Attach(KTestDbName1, _L("db2"));
	TEST2(err, KErrNone);
	//Check compact for both main and attached database
	TSqlScalarFullSelectQuery scalarQuery(TheDb);
	TInt compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
	TEST2(compact, KAutoVacuum);
	compact = scalarQuery.SelectIntL(_L("PRAGMA db2.auto_vacuum"));
	TEST2(compact, KAutoVacuum);
	//Detach
	err = TheDb.Detach(_L("db2"));
	TEST2(err, KErrNone);
	//Check compact again
	compact = scalarQuery.SelectIntL(_L("PRAGMA auto_vacuum"));
	TEST2(compact, KAutoVacuum);
	//
	TheDb.Close();
	err = RSqlDatabase::Delete(KTestDbName1);
	TEST2(err, KErrNone);
	}
GLDEF_C TInt E32Main()
	{
	__UHEAP_MARK;
	TheTest.Printf(_L("\n"));
	TheTest.Title();
	TheTest.Start(_L("Ecom Ssa Tests"));

	TEST2(TheFs.Connect(), KErrNone);

	// get clean-up stack
	CTrapCleanup* cleanup = CTrapCleanup::New();

	TRAPD(err, ::KillEComServerL());
	TEST2(err, KErrNone);

	EnableEcomTestBehaviour(TheTest, TheFs);

	SetupFiles(); //Add plugins to C: drive

	TRAP(err,DoTestsL());
	TEST2(err, KErrNone);

	CleanupFiles(); //Cleanup after test. Remove the plugins from C: drive

	DisableEcomTestBehaviour(TheTest, TheFs);

	ResetSsa(TheTest, TheFs);

	//Make sure that following tests start a fresh version of EComServer
	TRAP(err, ::KillEComServerL());

	TheTest.End();
	TheTest.Close();

	//delete scheduler;
	delete cleanup;

	TheFs.Close();

	__UHEAP_MARKEND;

	User::Heap().Check();

	return KErrNone;
	}
static void VerifyFileContent(const TDesC8& aPattern, TInt64 aFilePos)
	{
	__ASSERT_DEBUG(aFilePos >= 0, User::Invariant());
	
	TheBuf.Zero();
	
	RFile64 file;
	TInt err = file.Open(TheFs, KTestFile, EFileShareReadersOrWriters);
	TEST2(err, KErrNone);

	err = file.Read(aFilePos, TheBuf, aPattern.Length());
	TEST2(err, KErrNone);
	
	file.Close();
	
	err = TheBuf.Compare(aPattern);
	TEST2(err, 0);
	}
	virtual void operator()()
		{
		RFileBuf64 fbuf(8192);
		RFs fs;
		TInt err = fs.Connect();
		TEST2(err, KErrNone);
		fbuf.Open(fs, KNullDesC, EFileRead);//panic here - invalid file name
		fs.Close();
		}
/**
@SYMTestCaseID          SYSLIB-LOGENG-CT-4012
@SYMTestCaseDesc	    Tests Message schema validation for the ELogNotifyExtended message.
@SYMTestPriority 	    High
@SYMTestActions  	    Sends a message to the test server to test the validation of messages
						against the message schema.  The message contains an invalid descriptor. 
@SYMTestExpectedResults The server should panic the client with KErrBadDescriptor
@SYMDEF                	INC114113
*/
void TestLogNotifyExtended2L()
	{
	
	RClientMessageTestSession session;

	TInt err = session.Connect();
    TEST2(err, KErrNone);
	
	CleanupClosePushL(session);

	_LIT8(KDes8,"Des8");
	TPckgBuf<TInt> int0(0);
	
	err = session.TestLogNotifyExtended(int0, 0, -1, KDes8);	
	TEST2(err, KErrNone);

	CleanupStack::PopAndDestroy(&session);
	}
Example #10
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0002
@SYMTestCaseDesc	    Tests Message schema validation for the messages accepting
 						TLogClientServerData parameters.
@SYMTestPriority 	    High
@SYMTestActions  	    Sends messages to the test server to test the validation of messages
						against the message schema.  The messages contain either valid or invalid 
						parameters. 
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF                	INC114113
*/
void TestCliServDataParam3L()
	{
	RClientMessageTestSession session;
	
	TInt err = session.Connect();
    TEST2(err, KErrNone);
	
	CleanupClosePushL(session);
	
	TBuf8<sizeof(TLogClientServerData) + 1> buf;
	
	buf.FillZ();
	
	err = session.TestCliServDataParam(ELogOperationInitiate,buf);	
	TEST2(err, KErrArgument);
	
	CleanupStack::PopAndDestroy(&session);
	}
Example #11
0
static void CreateTestDb()
	{
	int err;
	
	err = sqlite3_open(TheTestDbName, &TheDb);
	TEST2(err, SQLITE_OK);
	TEST(TheDb != 0);

	err = sqlite3_exec(TheDb, "CREATE TABLE A(F1 INTEGER, F2 BIGINT, F3 REAL, F4 TEXT, F5 BLOB)", &exec_callback, 0, 0);
	TEST2(err, SQLITE_OK);
	
	err = sqlite3_exec(TheDb, "INSERT INTO A VALUES(1, 1234567891234, 56.12, 'TEXT', x'313233343536')", &exec_callback, 0, 0);
	TEST2(err, SQLITE_OK);

	err = sqlite3_close(TheDb);
	TEST2(err, SQLITE_OK);
	TheDb = 0;
	}
Example #12
0
//DEF057265 - Panics when uninstalling a java midlet while it is running.
//The test will run one thread. Inside the thread's function the test will create
//DBMS session and reserve some disk space. Then the test will panic the thread
//(without freeing the reserved disk space).
//If DBMS server panics in _DEBUG mode - the defect is not fixed.
void DEF057265()
	{
	_LIT(KSessThreadName,"SessThrd");
	RThread sessThread;
	TEST2(sessThread.Create(KSessThreadName, &ThreadFunc, 0x2000, 0, 0), KErrNone);

	TRequestStatus sessThreadStatus;
	sessThread.Logon(sessThreadStatus);
	TEST2(sessThreadStatus.Int(), KRequestPending);

	sessThread.Resume();
	User::WaitForRequest(sessThreadStatus);
	TEST2(sessThread.ExitType(), EExitPanic);

	User::SetJustInTime(EFalse);	// disable debugger panic handling
	sessThread.Close();//This Close() operation will force DBMS server to close
					   //created in ThreadFunc() DBMS session.
	}
/**
@SYMTestCaseID			SYSLIB-ECOM-CT-3714
@SYMTestCaseDesc 		Tests CEComServer::ListImplementationsL	with customer resolver.
@SYMTestPriority 		High
@SYMTestActions  		Calls ListImplementationsL(TUid,TUid,const RExtendedInterfacesArray&,const TClientRequest&)
						with customer resolver.
@SYMTestExpectedResults No OOM errors.
@SYMDEF 				DEF111196
*/
void ListImplementations_OOMTest1L()
	{
	TInt processHandlesS = 0;
	TInt threadHandlesS = 0;
	TInt processHandlesE = 0;
	TInt threadHandlesE = 0;
	RThread().HandleCount(processHandlesS, threadHandlesS);


	for(TInt count=1;;++count)
		{
		CEComServer* ecomServer = CEComServer::NewLC();
		// Setting Heap failure for OOM test
		__UHEAP_SETFAIL(RHeap::EDeterministic, count);
		__UHEAP_MARK;

		TUid resolverUid = {0x10009DD0};

		TClientRequest clientReq;
		RArray<TUid> extendedInterfaces;
		CleanupClosePushL(extendedInterfaces);
		RImplInfoArray* ifArray=NULL;

		TRAPD(err, ifArray = ecomServer->ListImplementationsL(KCExampleInterfaceUid,resolverUid,extendedInterfaces,clientReq));
		CleanupStack::PopAndDestroy(&extendedInterfaces);
		if (ifArray!=NULL)
			{
			ifArray->Close();
			delete ifArray;
			}
		if(err == KErrNoMemory)
			{
			CleanupStack::PopAndDestroy(ecomServer);
			__UHEAP_MARKEND;
			}
		else if(err == KErrNone)
			{
			CleanupStack::PopAndDestroy(ecomServer);
			__UHEAP_MARKEND;
			//implInfoArray should not be deleted! The caller does not take the ownership.
			RDebug::Print(_L("The test succeeded at heap failure rate=%d.\n"), count);
			break;
			}
		else
			{
			CleanupStack::PopAndDestroy(ecomServer);
			__UHEAP_MARKEND;
			TEST2(err, KErrNone);
			}
		__UHEAP_RESET;
		}
	__UHEAP_RESET;
	//CleanupStack::PopAndDestroy(ecomServer);
	RThread().HandleCount(processHandlesE, threadHandlesE);
	TEST(processHandlesS == processHandlesE);
	TEST(threadHandlesS == threadHandlesE);
	}
/**
@SYMTestCaseID          PDS-EFM-UT-4113
@SYMTestCaseDesc        Unit test for client reference counting.
@SYMTestPriority        High
@SYMTestActions         Create CFeatureDiscovery object and check the client reference count
                        Connect using RFeatureControl and check the client reference count
                        Delete the CFeatureDiscovery object and check the client reference count
                        Close RFeatureControl and check the client reference count
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144262
*/  
void TestRefCountCFeatureDiscoveryL()
    {
        RFeatureControl featCtrl;
        CleanupClosePushL(featCtrl);
        CFeatureDiscovery* featDisc = CFeatureDiscovery::NewLC();    
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        featCtrl.Connect();
        TEST2 (GetClientCount(), 2); // Client count should be 2 at this point

        // Both should return same result
        TEST2 (featDisc->IsSupported(KDummyFeatUid), featCtrl.FeatureSupported(KDummyFeatUid)==KFeatureSupported);
        
        CleanupStack::PopAndDestroy(featDisc);
        TEST2 (GetClientCount(), 1); // Client count should be 1 at this point
        
        CleanupStack::PopAndDestroy(&featCtrl);
        TEST2 (GetClientCount(), 0); // Client count should be 0 at this point
    }
/**
@SYMTestCaseID			SYSLIB-SQL-UT-3510
@SYMTestCaseDesc		Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
						The test has 3 sub-cases, where the test attempts to open
						a secure shared database with:
						- missing default policy in the security policy table;
						- invalid database object type in the security policy table;
						- 2 default policies in the security policy table;
@SYMTestPriority		High
@SYMTestActions			Test for DEF109100: SQL, code coverage for TSqlDbSysSettings is low.
@SYMTestExpectedResults Test must not fail
@SYMDEF					DEF109100
*/
void LoadSecurityPolicyTest()
{
    //Case 1: missing default policy.
    RSqlDatabase db;
    TInt err = db.Open(KDb6);
    TEST2(err, KErrGeneral);
    db.Close();

    //Case 2: invalid database object type.
    err = db.Open(KDb7);
    TEST2(err, KErrGeneral);
    db.Close();

    //Case 3: 2 default policies.
    err = db.Open(KDb8);
    TEST2(err, KErrGeneral);
    db.Close();
}
Example #16
0
//"PRAGMA cache_size=1024" and "PRAGMA locking_mode=EXCLUSIVE" statements executed only if 
//aPerfTestMode is EPerfTestSqliteMode (to match the Symbian SQL build time settings of SQLite)
static void ExecSqliteConfig(TPerfTestMode aPerfTestMode)
	{
	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
	if(aPerfTestMode == EPerfTestSqliteSqlMode)
		{
		int err;
		err = sqlite3_exec(TheDb2, "PRAGMA cache_size=1024", 0, 0, 0);
		TEST2(err, SQLITE_OK);
		err = sqlite3_exec(TheDb2, "PRAGMA locking_mode=EXCLUSIVE", 0, 0, 0);
		TEST2(err, SQLITE_OK);
		err = sqlite3_exec(TheDb2, "PRAGMA auto_vacuum=incremental", 0, 0, 0);
		TEST2(err, SQLITE_OK);
		err = sqlite3_exec(TheDb2, "PRAGMA journal_mode=PERSIST", 0, 0, 0);
		TEST2(err, SQLITE_OK);
		err = sqlite3_exec(TheDb2, "PRAGMA journal_size_limit=2048000", 0, 0, 0);
		TEST2(err, SQLITE_OK);
		}
	}
Example #17
0
/**
@SYMTestCaseID          PDS-SQL-UT-4160
@SYMTestCaseDesc        CSqlServer::GetBackUpListL() OOM test
@SYMTestPriority        High
@SYMTestActions         Calls CSqlServer::GetBackUpListL() in an OOM loop.
@SYMTestExpectedResults Test must not fail
@SYMDEF                 DEF144096
*/  
void GetBackupListOomTest()
    {
    CSqlServer* server = NULL;
    TRAPD(err, server = CreateSqlServerL());
    TEST2(err, KErrNone);
  
    TInt fileCnt = 0;
    err = KErrNoMemory;
    TInt failingAllocationNo = 0;
    TheTest.Printf(_L("Iteration:\r\n"));
    while(err == KErrNoMemory)
        {
        TheTest.Printf(_L(" %d"), ++failingAllocationNo);
        OomPreStep(failingAllocationNo);
        const TUid KDbUd = {0x98765432};
        RArray<HBufC*> files;
        TRAP(err, server->GetBackUpListL(KDbUd, EDriveC, files));
        fileCnt = files.Count();
        if(err == KErrNone)
        	{
			//No directories should be returned in the list of files for backup
			for(TInt i=0;i<fileCnt;++i)
				{
				TPtrC fname = files[i]->Des();
				TInt rc = KPrivateSubDir().CompareF(fname);
				TEST(rc != 0);
				}
        	}
        for(TInt j=0;j<files.Count();++j)
        	{
			delete files[j];
        	}
        files.Close();
        OomPostStep();
        }
    
    delete server;
    
    if(err != KErrNoMemory)
        {
        TEST2(err, KErrNone);   
        }
    TheTest.Printf(_L("\r\n===OOM test succeeded at heap failure rate of %d ===\r\nFile count: %d\r\n"), failingAllocationNo, fileCnt);
    }
static void TwoDatabasesTestL()
    {
	TBuf<32> fmt;
	fmt.Copy(KSecure);
	fmt.Append(KSecureDbUid.Name());
	
    RDbNamedDatabase db1;
	TheTest.Printf(_L("Open secure shared database-1\n"));
	TInt err = db1.Open(TheDbs, KDb1Name, fmt);
	TEST2(err, KErrNone);

    RDbNamedDatabase db2;
	TheTest.Printf(_L("Open secure shared database-2\n"));
	err = db2.Open(TheDbs, KDb1Name, fmt);
	TEST2(err, KErrNone);

    db2.Close();
    db1.Close();
    }
Example #19
0
//Panic test.
//PanicTest function will create a new thread - panic thread, giving it a pointer to the function which has to
//be executed and the expectation is that the function will panic and kill the panic thread.
//PanicTest function will check the panic thread exit code, exit category and the panic code.
void PanicTest(TFunctor& aFunctor, TExitType aExpectedExitType, const TDesC& aExpectedCategory, TInt aExpectedPanicCode)
	{
	RThread thread;
	_LIT(KThreadName,"OsLayerPanicThread");
	TEST2(thread.Create(KThreadName, &ThreadFunc, 0x2000, 0x1000, 0x10000, (void*)&aFunctor, EOwnerThread), KErrNone);
	
	TRequestStatus status;
	thread.Logon(status);
	TEST2(status.Int(), KRequestPending);
	thread.Resume();
	User::WaitForRequest(status);
	User::SetJustInTime(ETrue);	// enable debugger panic handling

	TEST2(thread.ExitType(), aExpectedExitType);
	TEST(thread.ExitCategory() == aExpectedCategory);
	TEST2(thread.ExitReason(), aExpectedPanicCode);
	
	CLOSE_AND_WAIT(thread);
	}
Example #20
0
void InsertStatsTableL()
	{
	RDbView view;
	TInt err = view.Prepare(TheDatabase, _L("select * from STATS"), view.EInsertOnly);
	TEST2(err, KErrNone);
	TheRowSet = view;	

	CDbColSet* colSet = TheRowSet.ColSetL();
	const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId);
	const TInt KTrackCntIdx = colSet->ColNo(KNoOfTracks);
	const TInt KMarkedToPlayCntIdx = colSet->ColNo(KNoMarked2Play);
	const TInt KUnmarkedToPlayCntIdx = colSet->ColNo(KNoUnmarked2Play);
	const TInt KAutoStartCntIdx = colSet->ColNo(KNoAutostart);
	const TInt KManualStartCntIdx = colSet->ColNo(KNoManualStart);
	const TInt KSizeMusicFilesIdx = colSet->ColNo(KSizeOfMusicFiles);
	delete colSet;

	TInt default_Stat = 0;

	err = TheDatabase.Begin();
	TEST2(err, KErrNone);
	
	for (TInt ii=0;ii<KStatsRecordCount;++ii)
		{
		TheRowSet.InsertL();
		TheRowSet.SetColL(KCategoryIdIdx, ii);
		TheRowSet.SetColL(KTrackCntIdx,default_Stat);
		TheRowSet.SetColL(KMarkedToPlayCntIdx,default_Stat);
		TheRowSet.SetColL(KUnmarkedToPlayCntIdx,default_Stat);
		TheRowSet.SetColL(KAutoStartCntIdx,default_Stat);
		TheRowSet.SetColL(KManualStartCntIdx,default_Stat);
		TheRowSet.SetColL(KSizeMusicFilesIdx,default_Stat);
		TheRowSet.PutL();
		}

	err = TheDatabase.Commit();
	TEST2(err, KErrNone);
	
	//err = TheDatabase.Compact();
	//TEST2(err, KErrNone);

	TheRowSet.Close();	
	}
Example #21
0
void VfsOpenTempFileOomTest()
    {
    //Delete all temp files in this test private data cage.
	TInt err = DoDeleteTempFiles();
    TEST(err == KErrNone || err == KErrNotFound);
    
    sqlite3_vfs* vfs = sqlite3_vfs_find(NULL);
    TEST(vfs != NULL);

    sqlite3_file* osFile = (sqlite3_file*)User::Alloc(vfs->szOsFile);
    TEST(osFile != NULL);
    
    TheTest.Printf(_L("Iteration: "));
    TInt failingAllocNum = 0;
    err = SQLITE_IOERR_NOMEM;
    while(err == SQLITE_IOERR_NOMEM)
        {
        ++failingAllocNum;
        TheTest.Printf(_L("%d "), failingAllocNum);
        OomPreStep(failingAllocNum);
        int outFlags = 0;
        err = sqlite3OsOpen(vfs, NULL, osFile, SQLITE_OPEN_READWRITE, &outFlags);
        if(err == SQLITE_OK)
            {
			//Since this is a temp file, its creation will be delayed till the first file write operation.
			err = sqlite3OsWrite(osFile, "1234", 4, 0);
			(void)sqlite3OsClose(osFile);
            }
        OomPostStep();
        if(err != SQLITE_OK)
            {
            TEST2(err, SQLITE_IOERR_NOMEM);
            }
        //If the iteration has failed, then no temp file should exist in the test private data cage.
        //If the iteration has succeeded, then sqlite3OsClose() should have deleted the temp file.
        TInt err2 = DoDeleteTempFiles();
        TEST2(err2, KErrNotFound);
        }
    TEST2(err, SQLITE_OK);
    TheTest.Printf(_L("\r\n=== TVfs::Open(<temp file>) OOM test succeeded at allcoation %d\r\n"), failingAllocNum);
    
    User::Free(osFile);
    }
Example #22
0
/**
@SYMTestCaseID          SYSLIB-LOGENG-LEGACY-T_LOGSERVIPC-0001
@SYMTestCaseDesc	    Tests Message schema validation for the messages accepting
 						TLogClientServerData parameters.
@SYMTestPriority 	    High
@SYMTestActions  	    Sends messages to the test server to test the validation of messages
						against the message schema.  The messages contain either valid or invalid 
						parameters. 
@SYMTestExpectedResults The server should validate the message and handle bad messages appropriately
@SYMDEF                	INC114113
*/
void TestCliServDataParam2L()
	{
	RClientMessageTestSession session;
	
	TInt err = session.Connect();
    TEST2(err, KErrNone);
	
	CleanupClosePushL(session);
	
	TBuf8<sizeof(TLogClientServerData) - 1> buf;
	
	buf.FillZ();
	
	//This should panic with Logserv 63
	err = session.TestCliServDataParam(ELogOperationInitiate,buf);	
    TEST2(err, KErrNone);
	
	CleanupStack::PopAndDestroy(&session);
	}
void DoSecurityTest2()
	{
	//It should not be possible to operate with the database file directly. Only through the passed file handles.		
	sqlite3* db = NULL;
	
	TInt err = sqlite3_open16(KTestDbName2, &db);
	TEST2(err, SQLITE_CANTOPEN);
	
	sqlite3_close(db);
	}
LOCAL_C TInt MainL()
{
	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
	CActiveScheduler::Install(scheduler);

	TRAPD(err,RunTestL());
    TEST2(err, KErrNone);
    
	delete scheduler;
}
//This functnion is called while there is an open secure connection.
//The function will create a new, non-secure connection and check that the non-secure database schema can be modified,
//while there is another alive, secure database connection.
void NonSecureDbTest()
    {
    (void)RSqlDatabase::Delete(KTestDbName2);
    RSqlDatabase db;
    TInt err = db.Create(KTestDbName2);
    TEST2(err, KErrNone);
    
    err = db.Exec(_L("CREATE TABLE A(I1 INTEGER, I2 INTEGER)"));
    TEST(err >= 0);
    err = db.Exec(_L("CREATE TEMP TABLE B(I1 INTEGER, I2 INTEGER)"));
    TEST(err >= 0);

    //"CREATE VIRTUAL TABLE" statement not supported
    err = db.Exec(_L("CREATE VIRTUAL TABLE V1 USING FTS3(ColOne TEXT, ColTwo DATETIME)"));
    TPtrC msg = db.LastErrorMessage();
    TheTest.Printf(_L("*** \"CREATE VIRTUAL TABLE\" expected failure, msg=\"%S\", err=%d\r\n"), &msg, err);
    TEST(err != KErrNone);
    
    err = db.Exec(_L("CREATE TRIGGER T1 AFTER INSERT ON A BEGIN INSERT INTO B VALUES(new.I1, new.I2); END;"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP TRIGGER T1"));
    TEST(err >= 0);
    err = db.Exec(_L("CREATE TEMP TRIGGER T2 AFTER UPDATE OF I1 ON A BEGIN UPDATE B SET I1 = new.I1; END;"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP TRIGGER T2"));
    TEST(err >= 0);

    err = db.Exec(_L("CREATE VIEW V1 AS SELECT * FROM A"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP VIEW V1"));
    TEST(err >= 0);
    err = db.Exec(_L("CREATE TEMP VIEW V2 AS SELECT * FROM A"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP VIEW V2"));
    TEST(err >= 0);

    err = db.Exec(_L("CREATE INDEX Idx1 ON A(I1)"));
    TEST(err >= 0);
    err = db.Exec(_L("ANALYZE A"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP INDEX Idx1"));
    TEST(err >= 0);
    err = db.Exec(_L("CREATE INDEX Idx2 ON B(I1)"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP INDEX Idx2"));
    TEST(err >= 0);
        
    err = db.Exec(_L("DROP TABLE B"));
    TEST(err >= 0);
    err = db.Exec(_L("DROP TABLE A"));
    TEST(err >= 0);
    
    db.Close();
    (void)RSqlDatabase::Delete(KTestDbName2);
    }
Example #26
0
/**
@SYMTestCaseID			SYSLIB-SQLITE3-UT-4005
@SYMTestCaseDesc		Two database connections in the same thread - "read operations" test. 
						The test creates two connections to the same database in the same thread.
						Both connections prepare a SELECT statement and call sqlite3_step() each
						thus testing that the file locking in the OS porting layer works properly
						(the SQLite library permits multiple connections to read from the database simultaneously,
						using a shared file locking mode).
						List of called SQLITE3 functions:
						 - sqlite3_open;
						 - sqlite3_prepare;
						 - sqlite3_step;
						 - sqlite3_finalize;
						 - sqlite3_close;
@SYMTestPriority		High
@SYMTestActions			Two database connections in the same thread - "read operations" test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ8782
*/
static void TwoReadersTest()
	{
	int err;
  	const char* tail = 0;

	TestNext("@SYMTestCaseID:SYSLIB-SQLITE3-UT-4005: Test two readers");
  	
	CreateTestDb();

	err = sqlite3_open(TheTestDbName, &TheDb);
	TEST2(err, SQLITE_OK);
	TEST(TheDb != 0);

	err = sqlite3_open(TheTestDbName, &TheDb2);
	TEST2(err, SQLITE_OK);
	TEST(TheDb2 != 0);

	/* ------------- */
	err = sqlite3_prepare(TheDb, "SELECT * FROM A", -1, &TheStmt, &tail);
	TEST2(err, SQLITE_OK);
	TEST((unsigned int)TheStmt);
	TEST(!tail || strlen(tail) == 0);

	err = sqlite3_prepare(TheDb2, "SELECT * FROM A", -1, &TheStmt2, &tail);
	TEST2(err, SQLITE_OK);
	TEST((unsigned int)TheStmt2);
	TEST(!tail || strlen(tail) == 0);

	err = sqlite3_step(TheStmt);
	TEST2(err, SQLITE_ROW);

	err = sqlite3_step(TheStmt2);
	TEST2(err, SQLITE_ROW);
	
	/* ------------- */

	(void)sqlite3_finalize(TheStmt2);
	TheStmt2 = 0;
	
	(void)sqlite3_finalize(TheStmt);
	TheStmt = 0;

	err = sqlite3_close(TheDb2);
	TEST2(err, SQLITE_OK);
	TheDb2 = 0;

	err = sqlite3_close(TheDb);
	TEST2(err, SQLITE_OK);
	TheDb = 0;
	
	(void)remove(TheTestDbName);
	}
void CreateTestEnv()
{
    TInt err = TheFs.Connect();
    TEST2(err, KErrNone);

    err = TheFs.MkDir(KTestDir);
    TEST(err == KErrNone || err == KErrAlreadyExists);

    err = TheFs.CreatePrivatePath(EDriveC);
    TEST(err == KErrNone || err == KErrAlreadyExists);
}
Example #28
0
void CreateTestDir()
    {
    RFs fs;
	TInt err = fs.Connect();
	TEST2(err, KErrNone);

	err = fs.MkDir(KTestDir);
	TEST(err == KErrNone || err == KErrAlreadyExists);
	
	fs.Close();
	}
Example #29
0
/**
@SYMTestCaseID			SYSLIB-SQLITE3-UT-4022
@SYMTestCaseDesc		SQLite library single-insert performance test.
						The test inserts one record and stores 
						the execution time for later use (comparison and printing).
						The ID of the inserted record is exactly the same as the ID of the inserted
						record, used by SYSLIB-SQLITE3-UT-4014 test case.
						The results of this test case will be compared against the results of
						the SYSLIB-SQLITE3-UT-4014 test case - "SQL server single-insert performance test".
@SYMTestPriority		High
@SYMTestActions			SQLite library single-insert performance test.
@SYMTestExpectedResults Test must not fail
@SYMREQ					REQ8782
*/
void SqliteSingleInsertTest(TPerfTestMode aPerfTestMode, const char aSingleInsertSql[], TInt aInsertRecId)
	{
	int err;
	unsigned int fc;
	
	TEST(aPerfTestMode > EPerfTestSqlMode && aPerfTestMode < EPerfTestModeCnt);
	TEST(!TheDb2);
	err = sqlite3_open(TestDbName(), &TheDb2);
	TEST2(err, SQLITE_OK);
	ExecSqliteConfig(aPerfTestMode);

	sprintf(TheSqlBuf2, aSingleInsertSql, aInsertRecId);
	fc = FastCounterValue();
	err = sqlite3_exec(TheDb2, TheSqlBuf2, 0, 0, 0);
	StorePerfTestResult(aPerfTestMode, EPerfTestSingleInsert, FastCounterValue() - fc);
	TEST2(err, SQLITE_OK);
	
	sqlite3_close(TheDb2);
	TheDb2 = 0;
	}
Example #30
0
//If _SQLPROFILER macro is not defined then all profiling PS porting layer functions should return KErrNotSupported.
void ProfilerDisabledTest()
	{
#ifndef _SQLPROFILER
	TInt err = sqlite3SymbianProfilerStart(0);
	TEST2(err, KErrNotSupported);
	
	err = sqlite3SymbianProfilerStop(0);
	TEST2(err, KErrNotSupported);
	
	err = sqlite3SymbianProfilerReset(0);
	TEST2(err, KErrNotSupported);
	
	TBuf8<1> res;
	err = sqlite3SymbianProfilerQuery(0, res);
	TEST2(err, KErrNotSupported);
	res = res;
#else	
	TheTest.Printf(_L("  The _SQLPROFILER macro is defined. The Profliling OS porting layer functions are tested in t_sqlapi2\r\n"));
#endif
	}