kerneltest/e32test/bench/t_svr5.cpp
changeset 269 d57b86b1867a
parent 0 a41df078684a
child 293 0659d0e1a03c
--- a/kerneltest/e32test/bench/t_svr5.cpp	Tue Aug 31 11:40:45 2010 +0100
+++ b/kerneltest/e32test/bench/t_svr5.cpp	Mon Sep 13 15:16:07 2010 +0100
@@ -624,6 +624,30 @@
 	return KErrNone;
 	}
 
+TInt RogueThread5(TAny*)
+	{
+	// try to masquerade as the WindowServer
+	UserSvr::WsRegisterThread();			// this should panic the thread
+	return KErrNone;
+	}
+
+TInt RogueThread6(TAny*)
+	{
+	// try to masquerade as the FileServer
+	UserSvr::FsRegisterThread();			// this should panic the thread
+	return KErrNone;
+	}
+
+TInt RogueThread7(TAny*)
+	{
+	// try to masquerade as the FileServer
+	RChunk myChunk;
+	TInt err = myChunk.CreateLocal(4096, 8192);
+	if (err == KErrNone)
+		UserSvr::RegisterTrustedChunk(myChunk.Handle());	// this should panic the thread
+	return err;
+	}
+
 void DisplayThreadExitInfo(const RThread& aThread)
 	{
 	TFullName fn=aThread.FullName();
@@ -675,6 +699,33 @@
 	test(thread.ExitType()==EExitPanic);
 	test(thread.ExitReason()==EBadMessageHandle);
 	thread.Close();
+
+	test.Next(_L("Rogue thread test 5"));
+	r=thread.Create(_L("Rogue5"),RogueThread5,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
+	test_KErrNone(r);
+	RunPanicThread(thread);	// wait for rogue thread to die
+	DisplayThreadExitInfo(thread);
+	test(thread.ExitType()==EExitPanic);
+	test(thread.ExitReason()==EAccessDenied);
+	thread.Close();
+
+	test.Next(_L("Rogue thread test 6"));
+	r=thread.Create(_L("Rogue6"),RogueThread6,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
+	test_KErrNone(r);
+	RunPanicThread(thread);	// wait for rogue thread to die
+	DisplayThreadExitInfo(thread);
+	test(thread.ExitType()==EExitPanic);
+	test(thread.ExitReason()==EAccessDenied);
+	thread.Close();
+
+	test.Next(_L("Rogue thread test 7"));
+	r=thread.Create(_L("Rogue7"),RogueThread7,KDefaultStackSize,KHeapSize,KHeapSize,NULL);
+	test_KErrNone(r);
+	RunPanicThread(thread);	// wait for rogue thread to die
+	DisplayThreadExitInfo(thread);
+	test(thread.ExitType()==EExitPanic);
+	test(thread.ExitReason()==EAccessDenied);
+	thread.Close();
 	}
 
 TInt SecondClient(TAny* aSession)