1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/system/t_trap.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,723 @@
1.4 +// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// e32test\system\t_trap.cpp
1.18 +// Overview:
1.19 +// Test TRAP, Leave and Assert
1.20 +// API Information:
1.21 +// TRAP, User::Leave, __ASSERT_DEBUG_NO_LEAVE, __ASSERT_ALWAYS_NO_LEAVE
1.22 +// Details:
1.23 +// - Test TRAP macro works as expected.
1.24 +// - Test User::Leave works as expected including leave from
1.25 +// within nested calls.
1.26 +// - Verify that a leave without a TRAP causes the thread to panic.
1.27 +// - Create a thread that asserts and verify the exit type and other
1.28 +// results are as expected.
1.29 +// Platforms/Drives/Compatibility:
1.30 +// All.
1.31 +// Assumptions/Requirement/Pre-requisites:
1.32 +// Failures and causes:
1.33 +// Base Port information:
1.34 +//
1.35 +//
1.36 +
1.37 +#include <e32test.h>
1.38 +#include <e32panic.h>
1.39 +
1.40 +const TInt KLeaveVal=1111;
1.41 +const TInt KUnLeaveVal=2222;
1.42 +const TInt KRecursiveUnLeaveVal=3333;
1.43 +const TInt KRecursiveSingleLeaveVal=4444;
1.44 +const TInt KMaxDepth=20;
1.45 +
1.46 +//#define __TEST_BREAKPOINT_IN_TRAP__
1.47 +
1.48 +LOCAL_D RTest test(_L("T_TRAP"));
1.49 +
1.50 +
1.51 +LOCAL_C TInt UnLeaveFunction(void)
1.52 + {
1.53 +
1.54 + return(KUnLeaveVal);
1.55 + }
1.56 +
1.57 +LOCAL_C TInt LeaveFunction(void)
1.58 + {
1.59 +
1.60 + User::Leave(KLeaveVal);
1.61 + return(0);
1.62 + }
1.63 +
1.64 +LOCAL_C TInt RecursiveUnLeave(TInt level)
1.65 + {
1.66 +
1.67 + if (level==0)
1.68 + return(KRecursiveUnLeaveVal);
1.69 + else
1.70 + return(RecursiveUnLeave(--level));
1.71 + }
1.72 +
1.73 +LOCAL_C TInt RecursiveSingleLeave(TInt level)
1.74 + {
1.75 +
1.76 + if (level==0)
1.77 + User::Leave(KRecursiveSingleLeaveVal);
1.78 + else
1.79 + RecursiveSingleLeave(--level);
1.80 + return(0);
1.81 + }
1.82 +
1.83 +LOCAL_C TInt RecursiveMultiLeave1(TInt level)
1.84 + {
1.85 +
1.86 + TInt ret=0;
1.87 + TRAP(ret,{if (level==0) User::Leave(level); else ret=RecursiveMultiLeave1(level-1); test(EFalse);})
1.88 + test(ret==level);
1.89 + User::Leave(level+1);
1.90 + return(0);
1.91 + }
1.92 +
1.93 +LOCAL_C TInt RecursiveMultiLeave2(TInt level)
1.94 + {
1.95 +
1.96 + if (level==0)
1.97 + return(1);
1.98 + TInt ret=0;
1.99 + TRAP(ret,ret=RecursiveMultiLeave2(level-1))
1.100 + test(ret==level);
1.101 + User::Leave(level+1);
1.102 + return(0);
1.103 + }
1.104 +
1.105 +LOCAL_C TInt doTrap(TInt aVal)
1.106 +//
1.107 +// Nest trap function.
1.108 +//
1.109 + {
1.110 +
1.111 + if (aVal)
1.112 + {
1.113 + TInt j=(-1);
1.114 + TRAP(j,j=doTrap(aVal-1))
1.115 + test(j==aVal);
1.116 + }
1.117 + return(aVal+1);
1.118 + }
1.119 +
1.120 +#ifdef __TEST_BREAKPOINT_IN_TRAP__
1.121 +void bkpt()
1.122 + {
1.123 + __BREAKPOINT();
1.124 + }
1.125 +#endif
1.126 +
1.127 +LOCAL_C void doLeave(TInt aLevel,TInt aVal)
1.128 +//
1.129 +// Nest trap with leave function.
1.130 +//
1.131 + {
1.132 +
1.133 + if (aLevel)
1.134 + doLeave(aLevel-1,aVal);
1.135 + else
1.136 + User::Leave(aVal);
1.137 + }
1.138 +
1.139 +LOCAL_C void testTrap()
1.140 +//
1.141 +// Test trap functions O.K.
1.142 +//
1.143 + {
1.144 +
1.145 + test.Start(_L("Trap level 1"));
1.146 +//
1.147 + TInt i=2;
1.148 + TRAP(i,i=1);
1.149 + test(i==1);
1.150 +#ifdef __TEST_BREAKPOINT_IN_TRAP__
1.151 + TRAP(i,bkpt());
1.152 + TRAP(i,TRAP(i,bkpt()));
1.153 +#endif
1.154 +//
1.155 + test.Next(_L("Trap level n"));
1.156 + for (i=1;i<KMaxDepth;i++)
1.157 + test(doTrap(i)==(i+1));
1.158 +//
1.159 + test.End();
1.160 + }
1.161 +
1.162 +LOCAL_C void testLeave()
1.163 +//
1.164 +// Test leave functions O.K.
1.165 +//
1.166 + {
1.167 +
1.168 + test.Start(_L("Leave level 1"));
1.169 +//
1.170 + TInt i=0;
1.171 + TRAP(i,User::Leave(2))
1.172 + test(i==2);
1.173 +//
1.174 + test.Next(_L("Leave level 2"));
1.175 + i=0;
1.176 + TRAP(i,TRAP(i,User::Leave(3)))
1.177 + test(i==3);
1.178 +//
1.179 +#ifdef __TEST_BREAKPOINT_IN_TRAP__
1.180 + TRAP(i,TRAP(i,User::Leave(33)); bkpt())
1.181 + test(i==33);
1.182 +#endif
1.183 +//
1.184 + test.Next(_L("Leave from nested calls"));
1.185 + for (i=1;i<KMaxDepth;i++)
1.186 + {
1.187 + TInt j=(-1);
1.188 + TRAP(j,doLeave(i,i))
1.189 + test(j==i);
1.190 + }
1.191 +//
1.192 + test.End();
1.193 + }
1.194 +
1.195 +LOCAL_C void testMH(void)
1.196 + {
1.197 +
1.198 + TInt ret=0;
1.199 + TRAP(ret,ret=UnLeaveFunction())
1.200 + test(ret==KUnLeaveVal);
1.201 + TRAP(ret,LeaveFunction())
1.202 + test(ret==KLeaveVal);
1.203 + TInt i=0;
1.204 + for(;i<=KMaxDepth;i++)
1.205 + {
1.206 + TRAP(ret,ret=RecursiveUnLeave(i))
1.207 + test(ret==KRecursiveUnLeaveVal);
1.208 + }
1.209 + for(i=0;i<=KMaxDepth;i++)
1.210 + {
1.211 + TRAP(ret,ret=RecursiveSingleLeave(i))
1.212 + test(ret==KRecursiveSingleLeaveVal);
1.213 + }
1.214 + for(i=0;i<=KMaxDepth;i++)
1.215 + {
1.216 + TRAP(ret,ret=RecursiveMultiLeave1(i))
1.217 + test(ret==i+1);
1.218 + }
1.219 + for(i=0;i<=KMaxDepth;i++)
1.220 + {
1.221 + TRAP(ret,ret=RecursiveMultiLeave2(i))
1.222 + test(ret==i+1);
1.223 + }
1.224 + }
1.225 +
1.226 +TInt LeaveNoTrapThread(TAny*)
1.227 + {
1.228 + User::Leave(KErrGeneral);
1.229 + return KErrNone;
1.230 + }
1.231 +
1.232 +void TestLeaveNoTrap()
1.233 + {
1.234 + RThread thread;
1.235 + TInt r=thread.Create(_L("Leave without Trap thread"),LeaveNoTrapThread,0x1000,&User::Allocator(),NULL);
1.236 + test(r==KErrNone);
1.237 + TRequestStatus stat;
1.238 + thread.Logon(stat);
1.239 + test(stat==KRequestPending);
1.240 + TBool justInTime=User::JustInTime();
1.241 + User::SetJustInTime(EFalse);
1.242 + thread.Resume();
1.243 + User::WaitForRequest(stat);
1.244 + User::SetJustInTime(justInTime);
1.245 + test(thread.ExitType()==EExitPanic);
1.246 + test(thread.ExitReason()==EUserLeaveWithoutTrap);
1.247 + test(thread.ExitCategory()==_L("USER"));
1.248 + CLOSE_AND_WAIT(thread);
1.249 + }
1.250 +
1.251 +enum TAssertTest
1.252 + {
1.253 + EAssertTest_Debug = 1,
1.254 + EAssertTest_Leave = 2,
1.255 + EAssertTest_Ret = 4,
1.256 + };
1.257 +
1.258 +TInt AssertThread(TAny* a)
1.259 + {
1.260 + TInt f = (TInt)a;
1.261 + TInt r = f | EAssertTest_Ret;
1.262 + if (f & EAssertTest_Leave)
1.263 + {
1.264 + if (f & EAssertTest_Debug)
1.265 + {
1.266 + __ASSERT_DEBUG_NO_LEAVE(User::Leave(r));
1.267 + }
1.268 + else
1.269 + {
1.270 + __ASSERT_ALWAYS_NO_LEAVE(User::Leave(r));
1.271 + }
1.272 + }
1.273 + else
1.274 + {
1.275 + if (f & EAssertTest_Debug)
1.276 + {
1.277 + __ASSERT_DEBUG_NO_LEAVE(RThread().Terminate(r));
1.278 + }
1.279 + else
1.280 + {
1.281 + __ASSERT_ALWAYS_NO_LEAVE(RThread().Terminate(r));
1.282 + }
1.283 + }
1.284 + return r;
1.285 + }
1.286 +
1.287 +TInt _AssertThread(TAny* a)
1.288 + {
1.289 + TInt s=0;
1.290 + TRAP_IGNORE(s=AssertThread(a));
1.291 + return s;
1.292 + }
1.293 +
1.294 +void TestAssert(TInt aTest)
1.295 + {
1.296 + test.Printf(_L("Assert %d\n"), aTest);
1.297 + RThread t;
1.298 + TInt r = t.Create(_L("assert"), &_AssertThread, 0x1000, NULL, (TAny*)aTest);
1.299 + test(r==KErrNone);
1.300 + TRequestStatus s;
1.301 + t.Logon(s);
1.302 + test(s==KRequestPending);
1.303 + TBool jit = User::JustInTime();
1.304 + User::SetJustInTime(EFalse);
1.305 + t.Resume();
1.306 + User::WaitForRequest(s);
1.307 + User::SetJustInTime(jit);
1.308 + TInt exitType = t.ExitType();
1.309 + TInt exitReason = t.ExitReason();
1.310 + const TDesC& exitCat = t.ExitCategory();
1.311 + CLOSE_AND_WAIT(t);
1.312 + test.Printf(_L("Exit %d,%d,%S\n"), exitType, exitReason, &exitCat);
1.313 + if (aTest & EAssertTest_Leave)
1.314 + {
1.315 + if (aTest & EAssertTest_Debug)
1.316 + {
1.317 +#ifdef _DEBUG
1.318 + test(exitType == EExitPanic);
1.319 + test(exitReason == EUnexpectedLeave);
1.320 +#else
1.321 + test(exitType == EExitKill);
1.322 + test(exitReason == KErrNone);
1.323 +#endif
1.324 + }
1.325 + else
1.326 + {
1.327 + test(exitType == EExitPanic);
1.328 + test(exitReason == EUnexpectedLeave);
1.329 + }
1.330 + }
1.331 + else
1.332 + {
1.333 + test(exitType == EExitTerminate);
1.334 + test(exitReason == (aTest | EAssertTest_Ret));
1.335 + }
1.336 + }
1.337 +
1.338 +/*============== server for testing exceptions in TRAP implementation ====================*/
1.339 +
1.340 +#include <e32base.h>
1.341 +#include <e32base_private.h>
1.342 +
1.343 +#include "../mmu/mmudetect.h"
1.344 +
1.345 +const TInt KHeapSize=0x2000;
1.346 +
1.347 +_LIT(KServerName,"Display");
1.348 +
1.349 +class CMySession : public CSession2
1.350 + {
1.351 +public:
1.352 + CMySession();
1.353 + virtual void ServiceL(const RMessage2& aMessage);
1.354 + };
1.355 +
1.356 +class CMyServer : public CServer2
1.357 + {
1.358 +public:
1.359 + enum {ERead,EStop};
1.360 +public:
1.361 + CMyServer(TInt aPriority);
1.362 + static CMyServer* New(TInt aPriority);
1.363 + virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;//Overloading
1.364 + };
1.365 +
1.366 +class RDisplay : public RSessionBase
1.367 + {
1.368 +public:
1.369 + TInt Open();
1.370 + void Read(TRequestStatus& aStatus);
1.371 + TInt Stop();
1.372 + };
1.373 +
1.374 +LOCAL_D RTest testSvr(_L("T_TRAP Server"));
1.375 +LOCAL_D RSemaphore client;
1.376 +LOCAL_D RSemaphore server;
1.377 +LOCAL_D RDisplay display;
1.378 +LOCAL_D const RMessage2* message;
1.379 +
1.380 +// Constructor
1.381 +//
1.382 +//
1.383 +CMySession::CMySession()
1.384 + {}
1.385 +
1.386 +CMyServer* CMyServer::New(TInt aPriority)
1.387 +//
1.388 +// Create a new CMyServer.
1.389 +//
1.390 + {
1.391 + return new CMyServer(aPriority);
1.392 + }
1.393 +
1.394 +CMyServer::CMyServer(TInt aPriority)
1.395 +//
1.396 +// Constructor.
1.397 +//
1.398 + : CServer2(aPriority)
1.399 + {}
1.400 +
1.401 +CSession2* CMyServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2&) const
1.402 +//
1.403 +// Create a new client for this server.
1.404 +//
1.405 + {
1.406 + return(new(ELeave) CMySession());
1.407 + }
1.408 +
1.409 +void CMySession::ServiceL(const RMessage2& aMessage)
1.410 +//
1.411 +// Handle messages for this server.
1.412 +//
1.413 + {
1.414 + TInt r=KErrNone;
1.415 + switch (aMessage.Function())
1.416 + {
1.417 + case CMyServer::ERead:
1.418 + testSvr.Printf(_L("read message received\n"));
1.419 + if (HaveVirtMem())
1.420 + {
1.421 + message = &aMessage;
1.422 + }
1.423 + client.Signal();
1.424 + server.Wait();
1.425 + break;
1.426 + case CMyServer::EStop:
1.427 + testSvr.Printf(_L("stop message received\n"));
1.428 + CActiveScheduler::Stop();
1.429 + break;
1.430 + default:
1.431 + r=KErrNotSupported;
1.432 + }
1.433 + aMessage.Complete(r);
1.434 + }
1.435 +
1.436 +TInt RDisplay::Open()
1.437 +//
1.438 +// Open the server.
1.439 +//
1.440 + {
1.441 + return(CreateSession(KServerName,TVersion(),1));
1.442 + }
1.443 +
1.444 +void RDisplay::Read(TRequestStatus& aStatus)
1.445 +//
1.446 +// Get session to test CSession2::ReadL.
1.447 +//
1.448 + {
1.449 + TBuf<0x10>* bad = (TBuf<0x10> *)(0x30000000);
1.450 + SendReceive(CMyServer::ERead, TIpcArgs(bad), aStatus);
1.451 + }
1.452 +
1.453 +TInt RDisplay::Stop()
1.454 +//
1.455 +// Stop the server.
1.456 +//
1.457 + {
1.458 + return SendReceive(CMyServer::EStop, TIpcArgs());
1.459 + }
1.460 +
1.461 +LOCAL_C TInt serverThreadEntryPoint(TAny*)
1.462 +//
1.463 +// The entry point for the server thread.
1.464 +//
1.465 + {
1.466 + testSvr.Title();
1.467 + testSvr.Start(_L("Create CActiveScheduler"));
1.468 + CActiveScheduler* pR=new CActiveScheduler;
1.469 + testSvr(pR!=NULL);
1.470 + CActiveScheduler::Install(pR);
1.471 +//
1.472 + testSvr.Next(_L("Create CMyServer"));
1.473 + CMyServer* pS=CMyServer::New(0);
1.474 + testSvr(pS!=NULL);
1.475 +//
1.476 + testSvr.Next(_L("Start CMyServer"));
1.477 + TInt r=pS->Start(KServerName);
1.478 + testSvr(r==KErrNone);
1.479 +//
1.480 + testSvr.Next(_L("Signal to client that we have started"));
1.481 + client.Signal();
1.482 +//
1.483 + testSvr.Next(_L("Start CActiveScheduler"));
1.484 + CActiveScheduler::Start();
1.485 +//
1.486 + testSvr.Next(_L("Exit server"));
1.487 + delete pS;
1.488 + testSvr.Close();
1.489 + return(KErrNone);
1.490 + }
1.491 +
1.492 +void CreateServer()
1.493 + {
1.494 + test.Next(_L("Creating client semaphore"));
1.495 + TInt r=client.CreateLocal(0);
1.496 + test(r==KErrNone);
1.497 +//
1.498 + test.Next(_L("Creating server semaphore"));
1.499 + r=server.CreateLocal(0);
1.500 + test(r==KErrNone);
1.501 +//
1.502 + test.Next(_L("Creating server thread"));
1.503 + RThread server;
1.504 + r=server.Create(_L("Server"),serverThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
1.505 + test(r==KErrNone);
1.506 + server.SetPriority(EPriorityMore);
1.507 +//
1.508 + test.Next(_L("Resume server thread"));
1.509 + server.Resume();
1.510 + test(ETrue);
1.511 +//
1.512 + test.Next(_L("Wait for server to start"));
1.513 + client.Wait();
1.514 +//
1.515 + test.Next(_L("Connect to server"));
1.516 + r=display.Open();
1.517 + test(r==KErrNone);
1.518 + }
1.519 +
1.520 +void StopServer()
1.521 + {
1.522 + test.Next(_L("Stop server"));
1.523 + TInt r=display.Stop();
1.524 + test(r==KErrNone);
1.525 +//
1.526 + test.Next(_L("Close connection"));
1.527 + display.Close();
1.528 +//
1.529 + test.Next(_L("Close all"));
1.530 + server.Close();
1.531 + client.Close();
1.532 + }
1.533 +
1.534 +/*============== end of server for testing exceptions in TRAP implementation ====================*/
1.535 +
1.536 +#undef TRAP_INSTRUMENTATION_START
1.537 +#undef TRAP_INSTRUMENTATION_NOLEAVE
1.538 +#undef TRAP_INSTRUMENTATION_LEAVE
1.539 +#define TRAP_INSTRUMENTATION_START ++TrapStart;
1.540 +#define TRAP_INSTRUMENTATION_NOLEAVE ++TrapNoLeave; TestExcInInstrumentation();
1.541 +#define TRAP_INSTRUMENTATION_LEAVE(aReason) TrapLeave=aReason;
1.542 +
1.543 +TInt TrapStart = 0;
1.544 +TInt TrapNoLeave = 0;
1.545 +TInt TrapLeave = 123;
1.546 +
1.547 +//
1.548 +// This is mostly for the benefit of WINS, where Win32 exceptions
1.549 +// have a nasty habit of interacting badly with C++ exceptions
1.550 +//
1.551 +
1.552 +void TestExcInInstrumentation()
1.553 + {
1.554 + TRequestStatus status;
1.555 + display.Read(status);
1.556 + test(status.Int() == KRequestPending);
1.557 +
1.558 + client.Wait();
1.559 +
1.560 + TBuf<0x100> buf;
1.561 + if (message)
1.562 + test(message->Read(0,buf) == KErrBadDescriptor);
1.563 +
1.564 + server.Signal();
1.565 +
1.566 + User::WaitForRequest(status);
1.567 + test(status.Int() == KErrNone);
1.568 + }
1.569 +
1.570 +void TestTrapInstrumentation()
1.571 + {
1.572 + CreateServer();
1.573 +
1.574 + test.Start(_L("TRAPD No Leave"));
1.575 + TRAPD(r,User::LeaveIfError(0));
1.576 + test(TrapStart==1);
1.577 + test(TrapLeave==123);
1.578 + test(r==0);
1.579 + test(TrapNoLeave==1);
1.580 +
1.581 + test.Next(_L("TRAP No Leave"));
1.582 + TRAP(r,User::LeaveIfError(0));
1.583 + test(TrapStart==2);
1.584 + test(TrapLeave==123);
1.585 + test(r==0);
1.586 + test(TrapNoLeave==2);
1.587 +
1.588 + test.Next(_L("TRAP_IGNORE No Leave"));
1.589 + TRAP_IGNORE(User::LeaveIfError(0));
1.590 + test(TrapStart==3);
1.591 + test(TrapLeave==123);
1.592 + test(TrapNoLeave==3);
1.593 +
1.594 + test.Next(_L("TRAPD Leave"));
1.595 + TRAPD(r2,User::LeaveIfError(-999));
1.596 + test(TrapStart==4);
1.597 + test(TrapLeave==-999);
1.598 + test(r2==TrapLeave);
1.599 + test(TrapNoLeave==3);
1.600 +
1.601 + test.Next(_L("TRAP Leave"));
1.602 + TRAP(r2,User::LeaveIfError(-666));
1.603 + test(TrapStart==5);
1.604 + test(TrapLeave==-666);
1.605 + test(r2==TrapLeave);
1.606 + test(TrapNoLeave==3);
1.607 +
1.608 + test.Next(_L("TRAP_IGNORE Leave"));
1.609 + TRAP_IGNORE(User::LeaveIfError(-333));
1.610 + test(TrapStart==6);
1.611 + test(TrapLeave==-333);
1.612 + test(TrapNoLeave==3);
1.613 +
1.614 + test.Next(_L("Leave"));
1.615 + test.End();
1.616 +
1.617 + StopServer();
1.618 + }
1.619 +
1.620 +#undef TRAP_INSTRUMENTATION_START
1.621 +#undef TRAP_INSTRUMENTATION_NOLEAVE
1.622 +#undef TRAP_INSTRUMENTATION_LEAVE
1.623 +#define TRAP_INSTRUMENTATION_START
1.624 +#define TRAP_INSTRUMENTATION_NOLEAVE
1.625 +#define TRAP_INSTRUMENTATION_LEAVE(aReason)
1.626 +
1.627 +#ifdef __WINS__
1.628 +TUint32* Stack;
1.629 +volatile TInt* volatile Q;
1.630 +const TInt A[] = {17,19,23,29,31,37,41,43,47,53};
1.631 +
1.632 +void ExceptionHandler(TExcType)
1.633 + {
1.634 + TUint32* sp = Stack;
1.635 + for (; *sp!=0xfacefeed; --sp) {}
1.636 + *sp = (TUint32)(Q++);
1.637 + }
1.638 +
1.639 +__NAKED__ TInt GetNext()
1.640 + {
1.641 + _asm mov Stack, esp
1.642 + _asm mov eax, 0facefeedh
1.643 + _asm mov eax, [eax]
1.644 + _asm ret
1.645 + }
1.646 +
1.647 +void testExceptionsInTrap()
1.648 + {
1.649 + TInt ix = 0;
1.650 + TInt r;
1.651 + User::SetExceptionHandler(&ExceptionHandler, 0xffffffff);
1.652 + Q = (volatile TInt* volatile)A;
1.653 + r = GetNext();
1.654 + test(r==A[ix++]);
1.655 + TInt i;
1.656 + TRAP(i,r=GetNext());
1.657 + test(i==0);
1.658 + test(r==A[ix++]);
1.659 + TRAP(i,TRAP(i,r=GetNext()));
1.660 + test(i==0);
1.661 + test(r==A[ix++]);
1.662 + TRAP(i, TRAP(i,User::Leave(271));r=GetNext(); );
1.663 + test(i==271);
1.664 + test(r==A[ix++]);
1.665 + TRAP(i, TRAP(i, TRAP(i,User::Leave(487));r=GetNext(); ); );
1.666 + test(i==487);
1.667 + test(r==A[ix++]);
1.668 + TInt s=-1;
1.669 + TRAP(i, TRAP(i, TRAP(i, TRAP(i,User::Leave(999));r=GetNext(); ); s=GetNext(); ); );
1.670 + test(i==999);
1.671 + test(r==A[ix++]);
1.672 + test(s==A[ix++]);
1.673 + TInt j=-1, k=-1, l=-1;
1.674 + TRAP(l, \
1.675 + TRAP(k, \
1.676 + TRAP(j, \
1.677 + TRAP(i,User::Leave(9991)); \
1.678 + r=GetNext(); \
1.679 + ); \
1.680 + User::Leave(9992); \
1.681 + ); \
1.682 + s=GetNext(); \
1.683 + );
1.684 + test(i==9991);
1.685 + test(j==0);
1.686 + test(k==9992);
1.687 + test(l==0);
1.688 + test(r==A[ix++]);
1.689 + test(s==A[ix++]);
1.690 + }
1.691 +#endif
1.692 +
1.693 +GLDEF_C TInt E32Main()
1.694 + {
1.695 + test.Title();
1.696 +//
1.697 + test.Start(_L("Trap"));
1.698 + testTrap();
1.699 +//
1.700 + test.Next(_L("Leave"));
1.701 + testLeave();
1.702 +//
1.703 + test.Next(_L("Assorted"));
1.704 + testMH();
1.705 +//
1.706 + test.Next(_L("Leave without Trap"));
1.707 + TestLeaveNoTrap();
1.708 +//
1.709 + test.Next(_L("Assertions"));
1.710 + TestAssert(0);
1.711 + TestAssert(EAssertTest_Debug);
1.712 + TestAssert(EAssertTest_Leave);
1.713 + TestAssert(EAssertTest_Leave | EAssertTest_Debug);
1.714 +
1.715 +#ifdef __LEAVE_EQUALS_THROW__
1.716 + test.Next(_L("Trap instrumentation"));
1.717 + TestTrapInstrumentation();
1.718 +#endif
1.719 +
1.720 +#ifdef __WINS__
1.721 + testExceptionsInTrap();
1.722 +#endif
1.723 +
1.724 + test.End();
1.725 + return(0);
1.726 + }