diff -r 9aca3be14c27 -r 75252ea6123b kerneltest/e32test/system/t_atomicu.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kerneltest/e32test/system/t_atomicu.cpp Mon Jul 26 10:52:56 2010 +0100 @@ -0,0 +1,205 @@ +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// e32test\system\t_atomicu.cpp +// Overview: +// Simple test for class User atomic operations +// API Information: +// User::SafeInc(), User::SafeDec(), User::LockedInc(), +// User::LockedDec() +// Details: +// - Tests SafeInc, SafeDec, LockedInc and LockedDec +// functions in single thread and determines that counts +// match after finished +// - Tests SafeInc, SafeDec, LockedInc and LockedDec +// functions in multithreaded configuration and determines +// that counts match after finished +// Platforms/Drives/Compatibility: +// All. +// Assumptions/Requirement/Pre-requisites: +// Failures and causes: +// Base Port information: +// +// + +#define __E32TEST_EXTENSION__ +#include +#include +#include + +LOCAL_D RTest test(_L("T_ATOMICU")); + +const TInt KMaxOps=20000; +#define KNumThreads 20 +TInt gValue=0; + +void TestSafeIncAndSafeDec() + { + gValue=0; + // increasing when 0, should return 0 + test(User::SafeInc(gValue)==0); + // value also should be 0 + test(gValue==0); + + gValue=1; + TInt expected=0; + // gValue should vary only between 1 and 2 + for (TInt i=0; i