Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\cppexceptions\t_unmap2.cpp
19 #include <e32std_private.h>
21 #include <e32base_private.h>
25 _LIT(KTestName, "t_unmap2");
26 RTest test(KTestName);
27 RSemaphore WaitSemaphore;
28 RSemaphore SignalSemaphore;
30 void TestLibraryCleanup();
34 test.Start(_L("Check code seg unmapping over User::Leave()/C++ exceptions."));
37 CTrapCleanup* cleanup = CTrapCleanup::New();
38 TInt r = KErrNoMemory;
41 test.Printf(_L("Opening semaphores for barrier with other process\n"));
42 test(WaitSemaphore.Open(1)==KErrNone);
43 test(SignalSemaphore.Open(2)==KErrNone);
44 TRAP(r, TestLibraryCleanup());
45 test.Printf(_L("Returned %d, expected %d\n"), r, KErrGeneral);
46 test(r == KErrGeneral);
47 WaitSemaphore.Close();
48 SignalSemaphore.Close();
59 void Checkpoint(TAny*)
61 test.Printf(_L("Checkpointing...\n"));
62 SignalSemaphore.Signal();
66 void TestLibraryCleanup()
68 test.Printf(_L("Loading DLL.\n"));
70 test(library.Load(KLeavingDll2) == KErrNone);
72 test.Printf(_L("Pushing cleanup item to synchronise after closing library handle.\n"));
73 CleanupStack::PushL(TCleanupItem(&Checkpoint, NULL));
75 test.Printf(_L("Pushing handle to dynamically loaded DLL onto the cleanup stack.\n"));
76 CleanupClosePushL(library);
78 test.Printf(_L("Pushing cleanup item to synchronise during leave\n"));
79 CleanupStack::PushL(TCleanupItem(&Checkpoint, NULL));
81 test.Printf(_L("Looking up leaving function.\n"));
82 TLibraryFunction leaving = library.Lookup(1);
83 test(leaving != NULL);
85 test.Printf(_L("Check-point whilst holding the open library handle.\n"));
88 test.Printf(_L("Calling leaving function.\n"));
91 test.Printf(_L("Cleaning up checkpoint operation.\n"));
92 CleanupStack::Pop(); // pause leave op
94 test.Printf(_L("Cleaning up DLL handle.\n"));
95 CleanupStack::PopAndDestroy();
97 test.Printf(_L("Cleaning up checkpoint operation.\n"));
98 CleanupStack::Pop(); // pause leave op