/** Constructor called from the respective Suite.cpp from their "AddTestStep" function Each test step initialises it's own name */ CEASShdOpCodeGetAlarmCharacteristics1Step::CEASShdOpCodeGetAlarmCharacteristics1Step() { // The server name and IPC number is obtained and all messages are checked Sync iSrServerName = _L("!AlarmServer"); iSrMessageType = 2; iSrMessageId = 5; iSrMessageMask = 0; iServerPanic = _L("ALARMSERVER"); TCapability cap[] = {ECapability_None, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; TInt i; for (i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } iExpectRejection = result; iStepCap = 0; // Get a unique thread name iSrChildThread.Format(_L("ChildThread_%S_%d"),&iSrServerName,iSrMessageId); }
void CT_StartAppTestStep::TestDeleteDataTypeL() { INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion")); TRequestStatus status; //Register for notification when data type mappings are restored from the data store ini file iApaLsSession.NotifyOnDataMappingChange(status); TInt err=iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText)); INFO_PRINTF2(_L("returned, %d"), err); TSecurityInfo info; info.Set(RProcess()); info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) : TEST(err==KErrPermissionDenied); if (err==KErrNone) { // Waits till the data type mappings are restored from the data store ini file User::WaitForRequest(status); TEST(status.Int()==KErrNone); } else { iApaLsSession.CancelNotifyOnDataMappingChange(); TEST(status.Int()==KErrCancel); } INFO_PRINTF1(_L("Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion....Done")); }
CHWRMFmTxClearRtDataStep::CHWRMFmTxClearRtDataStep() /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CPARAM_MESS_NAMEStep"); const TUint32 KCapabilityWriteUserDataBitMask = 0x10000; // 65536LL; const TUint32 KCapabilityCapabilityMultimediaDDBitMask = 0x8; //8LL; //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = KServerProcessName; SR_MESSAGE_TYPE = KSyncMessage; //Is it Async or sync? SR_MESSAGE_ID = EHWRMFmTxClearRtData ; //It holds the IPC number SR_MESSAGE_MASK = KCapabilityCapabilityMultimediaDDBitMask + KCapabilityWriteUserDataBitMask; //Holds the cap mask for the message //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("HWRM Server"); //TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit}; TCapability cap[] = {ECapabilityMultimediaDD, ECapabilityWriteUserData, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } #ifdef HWRM_FMTX_POLICY_CHECKING_DISABLED result = EFalse; #endif iExpect_Rejection = result; iStepCap = KCapabilityCapabilityMultimediaDDBitMask + KCapabilityWriteUserDataBitMask; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
/** @SYMTestCaseID APPFWK-APPARC-0010 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Tests DeleteDataMapping() which removes the linking of a datatype to the UID of an associated application @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::DeleteDataMapping() with datatype and service UID API Calls:\n RApaLsSession::DeleteDataMapping(const TDataType& aDataType, TUid aServiceUid) @SYMTestExpectedResults DeleteDataMapping() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestDeleteDataTypeL() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::DeleteDataMapping....Check data type mapping deletion")); _LIT8(KLitPlainText,"text/plain"); TSecurityInfo info; info.Set(RProcess()); //Main Panic KERN-EXEC 0 iApaLsSession.DeleteDataMapping(TDataType(KLitPlainText)); }
/** @SYMTestCaseID APPFWK-APPARC-0008 @SYMPREQ PREQ967 @SYMREQ REQ3889 @SYMTestCaseDesc Tests InsertDataMapping() which links a datatype to the UID of an associated application for launching assigns adds a low priority. Tests InsertDataMappingIfHigher() which remaps the datatype to the specified UID if the specified priority is higher. The "added" parameter indicates if the mapping was successful. @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Call RApaLsSession::InsertDataMapping() with datatype, application UID and low priority API Calls:\n RApaLsSession::InsertDataMapping(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid) @SYMTestExpectedResults InsertDataMapping() causes Main Panic KERN-EXEC 0 */ void CSysStartApparcTestCase::TestInsertDataTypeL() { RDebug::Print(_L("CSysStartApparcTestCase: Test RApaLsSession::InsertDataMapping....Check data type mapping addition")); const TDataTypePriority KPriLow = 1; _LIT8(KLitPlainText,"text/plain"); TSecurityInfo info; info.Set(RProcess()); //Main Panic KERN-EXEC 0 iApaLsSession.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp); }
CHWRMFmTxGetNextClearFreqStep::CHWRMFmTxGetNextClearFreqStep() /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CPARAM_MESS_NAMEStep"); TUint32 KCapabilityNoneBitMask = 0x80000000; // 2147483648LL; //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = KServerProcessName; SR_MESSAGE_TYPE = KSyncMessage; //Is it Async or sync? SR_MESSAGE_ID = EHWRMFmTxGetNextClearFreq ; //It holds the IPC number SR_MESSAGE_MASK = KCapabilityNoneBitMask; //Holds the cap mask for the message //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("HWRM Server"); //TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit}; TCapability cap[] = {ECapability_None, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } iExpect_Rejection = result; iStepCap = KCapabilityNoneBitMask; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
CECntGetOwnCard1Step::CECntGetOwnCard1Step() /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CECntGetOwnCard1Step"); //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = _L("CNTSRV"); SR_MESSAGE_TYPE = 2; SR_MESSAGE_ID = 40; SR_MESSAGE_MASK = 2147483648LL; //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("CNTMODEL"); TCapability cap[] = {ECapability_None, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } iExpect_Rejection = result; iStepCap = 2147483648LL; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
CPARAM_MESS_NAMEStep::CPARAM_MESS_NAMEStep(TBool aUpsAuthorisationGranted) /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CPARAM_MESS_NAMEStep"); //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = _L("PARAM_SVR_NAME"); SR_MESSAGE_TYPE = 2; SR_MESSAGE_ID = PARAM_MESS_VALUE; SR_MESSAGE_MASK = PARAM_MESS_CAPMASK; //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("PARAM_SVR_T16_PANIC"); TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if ((!aUpsAuthorisationGranted || cap[i] != ECapabilityNetworkServices) && !(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } iExpect_Rejection = result; iStepCap = (TUint32)PARAM_MESS_CAPMASK; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
CEAddEntrySizes1Step::CEAddEntrySizes1Step() /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CEAddEntrySizes1Step"); //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = _L("!AgendaServer"); SR_MESSAGE_ID = 203; SR_MESSAGE_MASK = 65536LL; //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("AgnServer"); TCapability cap[] = {ECapabilityWriteUserData, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { result=ETrue; } } SR_MESSAGE_TYPE = GetSyncOrAsync(SR_MESSAGE_ID); iExpect_Rejection = result; iStepCap = 65536LL; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
CELbsPrivacyServerCompleteRequest1Step::CELbsPrivacyServerCompleteRequest1Step() /** Each test step initialises it's own name */ { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CELbsPrivacyServerCompleteRequest1Step"); //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = _L("LBSPrivacyServer"); SR_MESSAGE_TYPE = 2; SR_MESSAGE_ID = 9; SR_MESSAGE_MASK = 131088; //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("EPos privacy"); TCapability caplist1[] = {ECapabilityLocation,ECapabilityReadDeviceData, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; // capability policing rules are all caps from list1 OR all caps from list2 for (TInt i = 0; caplist1[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(caplist1[i]))) { result=ETrue; } } iExpect_Rejection = result; iStepCap = 131088; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
/* TVerdict GetVerdict(TInt aAPIretValue) Called by: "MainThread" for returning verdict Parameters(TInt aRetValue) : 0 if API call gets thru without any rejection 1 if API call is rejected for capability error */ enum TVerdict CCapabilityTestStep::GetVerdict(TInt aAPIretValue) { TSecurityInfo info; info.Set(RProcess()); // INFO_PRINTF4(_L("The loaded Process has: capability: %x with SID:%x and VID: %x"), info.iCaps,info.iSecureId, info.iVendorId); INFO_PRINTF1(_L(" ")); INFO_PRINTF2(_L("The capability of the loaded Process is [%x] "), info.iCaps); INFO_PRINTF2(_L("The required capability for the test step is [%x] "), iStepCap); INFO_PRINTF1(_L("Therefore ... ")); TVerdict vVerdict[] = {EPass, EFail}; //please leave the following if/else block as the information printed by INFO_PRINTF1 is used bu CapTestSumm if(iExpect_Rejection)//[Inverse Test] EPass for 1 while EFail for 0 { INFO_PRINTF1(_L("Test Expected to Fail due to lack of capabilities")); return vVerdict[(aAPIretValue)?0:1]; } else //[Direct Test] EPass for 0 while EFail for 1 { INFO_PRINTF1(_L("Test Expected to Pass with correct capabilities")); return vVerdict[(aAPIretValue)?1:0]; } }
/** @SYMTestCaseID CT_RApaLsSessionTestStep_TestInsertDataTypeL @SYMPREQ Data caging @SYMTestCaseDesc @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions API Calls:\n RApaLsSession::InsertDataMapping \n RApaLsSession::InsertDataMappingIfHigher \n @SYMTestExpectedResults * */ void CT_StartAppTestStep::TestInsertDataTypeL() { INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition")); const TDataTypePriority KPriLow = 1; const TDataTypePriority KPriHigh = 2; TBool added=EFalse; TInt err=iApaLsSession.InsertDataMapping(TDataType(KLitPlainText), KPriLow, KUidTestApp); INFO_PRINTF2(_L("returned, %d"), err); TSecurityInfo info; info.Set(RProcess()); info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone) : TEST(err==KErrPermissionDenied); TRequestStatus status; //Register for notification when data type mappings are restored from the data store ini file iApaLsSession.NotifyOnDataMappingChange(status); err=iApaLsSession.InsertDataMappingIfHigher(TDataType(KLitPlainText), KPriHigh, KUidTestApp, added); INFO_PRINTF2(_L("returned, %d"), err); info.iCaps.HasCapability(ECapabilityWriteDeviceData) ? TEST(err==KErrNone && added) : TEST(err==KErrPermissionDenied); if (err==KErrNone) { // Waits till the data type mappings are restored from the data store ini file User::WaitForRequest(status); TEST(status.Int()==KErrNone); } else { iApaLsSession.CancelNotifyOnDataMappingChange(); TEST(status.Int()==KErrCancel); } INFO_PRINTF1(_L("Test RApaLsSession::InsertDataMapping....Check data type mapping addition....Done")); }
/** Each test step initialises it's own name */ CRSDbgMbufFreeSpace1Step::CRSDbgMbufFreeSpace1Step() { // store the name of this test case // this is the name that is used by the script file //DEF iTestStepName = _L("CRSDbgMbufFreeSpace1Step"); //The server name and IPC number is obtained and all messages are checked Sync SR_ServerName = _L("!RootServer"); SR_MESSAGE_TYPE = 2; SR_MESSAGE_ID = RootServer::RSDbgMbufFreeSpace; SR_MESSAGE_MASK = 1024; // Added to support SID/VID testing SR_MESSAGE_SID = TSecureId (0x00000000); SR_MESSAGE_VID = TVendorId (0x70000001); //The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName iServer_Panic = _L("Root Server Test"); TCapability cap[] = {ECapabilityNetworkControl, ECapability_Limit}; TSecurityInfo info; info.Set(RProcess()); TBool result = EFalse; // Skip check if no caps are required if (cap[0] != ECapability_None) { for (TInt i = 0; cap[i] != ECapability_Limit; i++) { if (!(info.iCaps.HasCapability(cap[i]))) { // this process doesn't have required caps - expect fail result=ETrue; break; } } } if (!result && SR_MESSAGE_SID != 0) { if (info.iSecureId != SR_MESSAGE_SID) { // this process doesn't have the required SID - expect fail result=ETrue; } } if (!result && SR_MESSAGE_VID != 0) { if (info.iVendorId != SR_MESSAGE_VID) { // this process doesn't have the required SID - expect fail result=ETrue; } } iExpect_Rejection = result; iStepCap = 1024; //Get a unique thread name ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID); }
/* TVerdict MainThread() Called by: "doTestStepL" Purpose: Creates the child thread(which calls the respective function with regard to the server and also implements the Message Call). Then this fn.waits for the completion of the childthread( doesnt matter how the thread did die!) Return Value(Verdict of the TestStep): A.Reporting PASS/FAIL Direct Test: When a message call gets thru. Please note that in such cases actually the implementation of the message has started. As we are passing "0" Parameters, server may panic, though our botheration stops once the call gets thru. NOTE: The style is the same when CONNECTION capabilities are tested, the only diff is you dont have to expect a panic from server Inverse Test: The call should be either failed or panicked with "KErrPermissionDenied" flag. General Case: If a thread creation failed or if the server couldnt be connected apart from the above two cases, then a FAIL is reported B.Reporting INCONCLUSIVE Any panic say from unexpected source (eg:KERN-EXEC) will be reported INCONCLUSIVE */ TVerdict CCapabilityTestStep::MainThread() { TBuf<100> tExitCategory; TInt tExitReason = 0; TBuf<100> TestStyle; iExpect_Rejection?TestStyle = _L("Inverse"):TestStyle = _L("Direct"); TCapabilitySet theCaps = TSecurityInfo(RProcess()).iCaps ; const TInt KMaxTestThreadHeapSize = 0x10000; //Initialize return values iResult_SR = iResult_Server = KErrNone; // Create a child thread, with a new heap TInt nRes_Thread = tChildThread.Create( ChildThread_SR, ThreadStartFn, KDefaultStackSize, KMinHeapSize, KMaxTestThreadHeapSize, this, EOwnerProcess); if(nRes_Thread == KErrNone)//Thread Created { //Let me know when the thread is dead TRequestStatus ThreadStatus; tChildThread.Logon(ThreadStatus); tChildThread.Resume(); //Is the thread dead? User::WaitForRequest( ThreadStatus ); //yes, he is dead. RIP! Now the Killer's profile tExitCategory = tChildThread.ExitCategory(); tExitReason = tChildThread.ExitReason(); //Somebody Please say what are we testing!! if(iSessionCreated && (SR_MESSAGE_ID >=0))//Flag set by Child thread when connected to Server { //INFO_PRINTF5(_L("Connected to Server(%S) for %S Test [MessageID: %d,Req.Cap: 0x%x,Present.Cap: 0x%x]"),&SR_ServerName,&TestStyle,SR_MESSAGE_ID,iStepCap,TSecurityInfo(RProcess())); } else if(SR_MESSAGE_ID < 0) { //DEF INFO_PRINTF5(_L("Testing Connection capabilities[%S Test] for Server(%S) [Req.Cap: 0x%x,Present.Cap: 0x%x]"),&TestStyle, //&SR_ServerName,TSecurityInfo(RProcess())); } else if(!iSessionCreated)// NO Connection { TSecurityInfo info; info.Set(RProcess()); RRsConfigurator iConfigurator; TInt result = iConfigurator.Connect(); INFO_PRINTF1(_L("iConfigurator Connection Sucessful")); INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),tExitReason); //INFO_PRINTF4(_L("connected to the Server(%S) ErrorCode - ServerRet: %d C32ret: %d"),&SR_ServerName,iResult_Server,iResult_C32); INFO_PRINTF2(_L("The capability of the loaded Process is [%x] "), info.iCaps); INFO_PRINTF2(_L("The required capability for the test step is [%x] "), iStepCap); INFO_PRINTF1(_L("Therefore ... ")); INFO_PRINTF1(_L("Test Expected to Fail due to lack of capabilities")); //INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason); return EPass; } switch(tChildThread.ExitType()) { case EExitPanic: //1.A Panic from the connected Server //2.A CServer Panic normally for capability rejection //3.A kernel Panic (consider yourself doomed!) if((tExitReason == KErrPermissionDenied) || //DEF ? it's old version (tExitReason == CServer::EClientDoesntHaveRequiredCaps))//Rejected for Insufficient Cap. // is it correct ? (tExitReason == CServer2::EClientDoesntHaveRequiredCaps))//Rejected for Insufficient Cap. { INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),tExitReason); return(GetVerdict(API_RetValue_PermissionDenied)); } else if(tExitCategory == iServer_Panic) //Panic from Server { INFO_PRINTF2(_L("Server(%S) Panic to child thread"),&tExitCategory); INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason); return(GetVerdict(API_RetValue_ServerPanic)); } else//A kernel Panic possibly { INFO_PRINTF3(_L("Child Thread: Panic from unexpected source (ExitCategory: %S ExitReason : %d)!"),&tExitCategory,tExitReason); return EInconclusive; } break; case EExitKill: if(iResult_SR != KErrPermissionDenied) { INFO_PRINTF2(_L("A Successfull call (Return Value : %d)"),((SR_MESSAGE_ID >=0)?iResult_SR:iResult_Server)); return(GetVerdict(API_RetValue_NoCapError)); } else { INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),((SR_MESSAGE_ID >=0)?iResult_SR:iResult_Server)); return(GetVerdict(API_RetValue_PermissionDenied)); } break; default: break; } } else //Our thread couldnt start :o( { INFO_PRINTF2(_L("ERROR: Failed to create Child thread, ErrorCode:(%d)"),nRes_Thread); return EFail; } return EInconclusive; }