sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\dll\t_path.cpp sl@0: // Overview: sl@0: // Test imported DLL path search order. sl@0: // API Information: sl@0: // None (implicit searching when loading an executable) sl@0: // Details: sl@0: // - t_pathdll1 and t_pathdll2 both export the same function which returns 1 sl@0: // 2 respectively. sl@0: // - Run t_path2 (linked to t_pathdll1) and check return value from DLL - should sl@0: // be 1. sl@0: // - Copy t_pathdll2 to C: and rename to t_pathdll1 - it should now be loaded sl@0: // instead. sl@0: // - Run t_path2 again and check return value from DLL - should be 2. sl@0: // Platforms/Drives/Compatibility: sl@0: // Not on emulator. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: RTest test(_L("T_PATH")); sl@0: RFs gFs; sl@0: CFileMan* gFileMan; sl@0: sl@0: TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: test.Start(_L("Test imported DLL search path order")); sl@0: sl@0: if (!PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) sl@0: { sl@0: test.Printf(_L("Skipping test as sysbin enforcement is disabled")); sl@0: return KErrNone; sl@0: } sl@0: sl@0: // Turn off evil lazy dll unloading sl@0: RLoader l; sl@0: test_KErrNone(l.Connect()); sl@0: test_KErrNone(l.CancelLazyDllUnload()); sl@0: l.Close(); sl@0: sl@0: CTrapCleanup* ct = CTrapCleanup::New(); sl@0: test_NotNull(ct); sl@0: test_KErrNone(gFs.Connect()); sl@0: TRAPD(r, gFileMan=CFileMan::NewL(gFs)); sl@0: test_KErrNone(r); sl@0: sl@0: test.Next(_L("Run t_path2, expecting DLL 1 to be loaded")); sl@0: _LIT(KPath2, "t_path2"); sl@0: RProcess path2; sl@0: test_KErrNone(path2.Create(KPath2, KNullDesC)); sl@0: TRequestStatus stat; sl@0: path2.Logon(stat); sl@0: path2.Resume(); sl@0: User::WaitForRequest(stat); sl@0: test_Equal(EExitKill, path2.ExitType()); sl@0: test_Equal(1, path2.ExitReason()); sl@0: path2.Close(); sl@0: sl@0: test.Next(_L("Copy DLL 2 to C drive")); sl@0: _LIT(KCopySrc, "Z:\\sys\\bin\\t_pathdll2.dll"); sl@0: _LIT(KCopyDest, "C:\\sys\\bin\\"); sl@0: test_KErrNone(gFileMan->Copy(KCopySrc(), KCopyDest(), CFileMan::ERecurse)); sl@0: _LIT(KRenSrc, "C:\\sys\\bin\\t_pathdll2.dll"); sl@0: _LIT(KRenDest, "C:\\sys\\bin\\t_pathdll1.dll"); sl@0: test_KErrNone(gFileMan->Rename(KRenSrc(), KRenDest())); sl@0: sl@0: test.Next(_L("Run t_path2, expecting DLL 2 to be loaded")); sl@0: test_KErrNone(path2.Create(KPath2, KNullDesC)); sl@0: path2.Logon(stat); sl@0: path2.Resume(); sl@0: User::WaitForRequest(stat); sl@0: test_Equal(EExitKill, path2.ExitType()); sl@0: test_Equal(2, path2.ExitReason()); sl@0: path2.Close(); sl@0: sl@0: // cleanup sl@0: gFileMan->Delete(KRenDest); sl@0: delete gFileMan; sl@0: gFs.Close(); sl@0: delete ct; sl@0: test.End(); sl@0: return KErrNone; sl@0: } sl@0: