Пример #1
0
// ---------------------------------------------------------
// CPosTp17::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CPosTp17::StartL()
    {
#ifdef __WINS__
    _LIT(KNotSupported, "Test case is not supported on WINS, exucute it on target!");
    LogErrorAndLeave(KNotSupported);
#else
    _LIT(KErrors, "One or several Dll's have an incorrect size");
    SetupTestDataL();
 
    RFs session;
    User::LeaveIfError(session.Connect());
    CleanupClosePushL(session);
 
    RFile file;
    TBuf<1> drive= _L("c");
    TBuf<KMaxDllFileNameLength> name;
    name.Copy(iDllNames[0]);
    name.Replace(0,1,drive); 
 
    if (file.Open(session, name, EFileRead) != KErrNone)
        {
        iLog->Put(_L("(Flashed) Use Drive Z:"));
        drive.Copy(_L("z"));
        }
	else iLog->Put(_L("(Nonflashed) Use Drive C:"));
 
    file.Close();
    TBool errors=EFalse;
    for (TInt i=0; i<iDllNames.Count(); i++)
        {
        name.Copy(iDllNames[i]);
        name.Replace(0,1,drive);
        //User::LeaveIfError(file.Open(session, name, EFileRead));
        TInt err = file.Open(session, name, EFileRead);
        if (err != KErrNone)
            {
            TBuf<70> buffe;
            buffe.Append(_L("Error when opening file "));
            buffe.Append(name);
			LogErrorAndLeave(buffe, err);
            }

        CleanupClosePushL(file);
        TInt fileSize=0;
        file.Size(fileSize);
       
        if (fileSize > iFootprints[i])
            {
            errors = ETrue;
            
            _LIT(KDllSizeErr, "ERROR: %S is to big (%d), Max allowed ROM footprint is %d");
            TBuf<255> info;
            HBufC* temp = name.Alloc();
            info.Format(KDllSizeErr, temp, fileSize, iFootprints[i]);
            delete temp;
            iLog->Put(info);
            }
        else 
            {
			// Always log .dll size
            _LIT(KDllSizeDebug, "%S is (%d), Max allowed ROM footprint is %d");
            TBuf<255> info;
            HBufC* temp = name.Alloc();
            info.Format(KDllSizeDebug, temp, fileSize, iFootprints[i]);
            delete temp;
            iLog->Put(info);
            }
        
        CleanupStack::PopAndDestroy(&file);
        } 
    CleanupStack::PopAndDestroy(&session);

    if (errors)
        {
        LogErrorAndLeave(KErrors);
        }
#endif
    }