kerneltest/e32test/dma/t_dma.cpp
branchRCL_3
changeset 21 e7d2d738d3c2
parent 8 538db54a451d
child 22 2f92ad2dc5db
equal deleted inserted replaced
20:597aaf25e343 21:e7d2d738d3c2
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   191 		{return new CDefaultFragTest(*this);}
   191 		{return new CDefaultFragTest(*this);}
   192 
   192 
   193 	const TInt iTotalTransferSize;
   193 	const TInt iTotalTransferSize;
   194 	};
   194 	};
   195 
   195 
       
   196 /**
       
   197 Test that it is possible to close a channel from a callback
       
   198 */
       
   199 class CCloseInCb : public CTest
       
   200 	{
       
   201 public:
       
   202 	CCloseInCb()
       
   203 		: CTest(NULL, 1), iTransferSize(4 * KKilo)
       
   204 		{}
       
   205 
       
   206 	TInt virtual DoRunTest();
       
   207 
       
   208 	virtual void AnnounceTest(TDes& aDes)
       
   209 		{
       
   210 		aDes.AppendFormat(_L("CCloseInCb"));
       
   211 		CTest::AnnounceTest(aDes);
       
   212 		}
       
   213 
       
   214 	CTest* Clone() const
       
   215 		{return new CCloseInCb(*this);}
       
   216 private:
       
   217 	const TInt iTransferSize;
       
   218 
       
   219 	};
   196 
   220 
   197 //
   221 //
   198 // Active object used to create a tester thread, log on to it and
   222 // Active object used to create a tester thread, log on to it and
   199 // interpret its exit status.
   223 // interpret its exit status.
   200 //
   224 //
   344 	
   368 	
   345 	iChannel.Close();
   369 	iChannel.Close();
   346 	return KErrNone;
   370 	return KErrNone;
   347 	}
   371 	}
   348 
   372 
       
   373 TInt CCloseInCb::DoRunTest()
       
   374 	{
       
   375 	TInt r = KErrNone;
       
   376 	RTest test(_L("CCloseInCb test"));
       
   377 
       
   378 	r = OpenChannel(1);
       
   379 	test_KErrNone(r);
       
   380 
       
   381 	const TInt KRequest = 0;
       
   382 	const TInt KSrcBuf = 0;
       
   383 	const TInt KDestBuf = 1;
       
   384 
       
   385 	const TInt size = Min(iTransferSize, Info.iMaxTransferSize);
       
   386 
       
   387 	r = iChannel.AllocBuffer(KSrcBuf, size);
       
   388 	test_KErrNone(r);
       
   389 	iChannel.FillBuffer(KSrcBuf, 'A');
       
   390 	r = iChannel.AllocBuffer(KDestBuf, size);
       
   391 	test_KErrNone(r);
       
   392 	iChannel.FillBuffer(KDestBuf, '\0');
       
   393 
       
   394 	TRequestStatus rs = KRequestPending;
       
   395 	r = iChannel.Fragment(KRequest, KSrcBuf, KDestBuf, size, &rs);
       
   396 	test_KErrNone(r);
       
   397 
       
   398 	// "X" will cause channel to be closed during callback
       
   399 	r = iChannel.Execute(_L8("QX0"));
       
   400 	test_KErrNone(r);
       
   401 
       
   402 	User::WaitForRequest(rs);
       
   403 	test_KErrNone(rs.Int());
       
   404 
       
   405 	test(iChannel.CheckBuffer(KDestBuf, 'A'));
       
   406 	iChannel.FreeAllBuffers();
       
   407 
       
   408 	test.Close();
       
   409 	return KErrNone;
       
   410 	}
   349 
   411 
   350 // Called when thread completed.
   412 // Called when thread completed.
   351 void CTesterThread::RunL()
   413 void CTesterThread::RunL()
   352 	{
   414 	{
   353 	TExitType et = iThread.ExitType();
   415 	TExitType et = iThread.ExitType();
   962 	test(Bipper != NULL);
  1024 	test(Bipper != NULL);
   963 
  1025 
   964 	test.Next(_L("Getting channel info"));
  1026 	test.Next(_L("Getting channel info"));
   965 	GetChannelInfo();
  1027 	GetChannelInfo();
   966 
  1028 
       
  1029 	test.Next(_L("Test that channel can be closed from callback"));
       
  1030 	test.Next(_L("sb"));
       
  1031 	RunSbTest(maxchannel, new CCloseInCb() );
       
  1032 	test.Next(_L("db"));
       
  1033 	RunDbTest(maxchannel, new CCloseInCb() );
       
  1034 	test.Next(_L("sg"));
       
  1035 	RunSgTest(maxchannel, new CCloseInCb() );
   967 	// Size for the single transfer test
  1036 	// Size for the single transfer test
   968 	TInt totalTransferSize = 64 * KKilo;
  1037 	TInt totalTransferSize = 64 * KKilo;
   969 
  1038 
   970 	test.Next(_L("Testing one shot single buffer transfer"));
  1039 	test.Next(_L("Testing one shot single buffer transfer"));
   971 	RunSbTest(maxchannel, new CFragmentationTest(TestOneShot, maxIter, maxfrag, maxFragSize));
  1040 	RunSbTest(maxchannel, new CFragmentationTest(TestOneShot, maxIter, maxfrag, maxFragSize));