summaryrefslogtreecommitdiffstats
path: root/tests/auto/exceptionsafety_objects
diff options
context:
space:
mode:
authormread <qt-info@nokia.com>2009-09-02 11:52:43 (GMT)
committermread <qt-info@nokia.com>2009-09-02 12:12:53 (GMT)
commitfcf32920adff00197591ab496d896609e3190546 (patch)
tree8b9222658d54796f10ccceaf00b644b91f105d7b /tests/auto/exceptionsafety_objects
parent5871ed63be9dae9543fa0b715d593365bd1d2a7c (diff)
downloadQt-fcf32920adff00197591ab496d896609e3190546.zip
Qt-fcf32920adff00197591ab496d896609e3190546.tar.gz
Qt-fcf32920adff00197591ab496d896609e3190546.tar.bz2
Symbian OOM testing extended to release builds
The RHeap test functions, such as enabled by the __UHEAP macros, are only enabled for debug builds. This change puts a wrapper allocator in place which replicates the debug functions in all builds. This should allow the exceptionsafety_objects autotest to progress further on Symbian release builds. Reviewed-by: axis
Diffstat (limited to 'tests/auto/exceptionsafety_objects')
-rw-r--r--tests/auto/exceptionsafety_objects/oomsimulator.h81
1 files changed, 76 insertions, 5 deletions
diff --git a/tests/auto/exceptionsafety_objects/oomsimulator.h b/tests/auto/exceptionsafety_objects/oomsimulator.h
index 8358fea..9432a5b 100644
--- a/tests/auto/exceptionsafety_objects/oomsimulator.h
+++ b/tests/auto/exceptionsafety_objects/oomsimulator.h
@@ -189,6 +189,82 @@ static struct QCrtDebugRegistrator
} crtDebugRegistrator;
+#elif defined(Q_OS_SYMBIAN)
+
+struct QAllocFailAllocator : public RAllocator
+{
+ QAllocFailAllocator() : allocator(User::Allocator())
+ {
+ User::SwitchAllocator(this);
+ }
+
+ ~QAllocFailAllocator()
+ {
+ User::SwitchAllocator(&allocator);
+ }
+
+ RAllocator& allocator;
+
+ // from MAllocator
+ TAny* Alloc(TInt aSize)
+ {
+ ++mallocCount;
+ if (mallocFailActive && --mallocFailIndex < 0)
+ return 0; // simulate OOM
+ return allocator.Alloc(aSize);
+ }
+
+ void Free(TAny* aPtr)
+ {
+ allocator.Free(aPtr);
+ }
+
+ TAny* ReAlloc(TAny* aPtr, TInt aSize, TInt aMode)
+ {
+ ++mallocCount;
+ if (mallocFailActive && --mallocFailIndex < 0)
+ return 0; // simulate OOM
+ return allocator.ReAlloc(aPtr, aSize, aMode);
+ }
+
+ TInt AllocLen(const TAny* aCell) const
+ {
+ return allocator.AllocLen(aCell);
+ }
+
+ TInt Compress()
+ {
+ return allocator.Compress();
+ }
+
+ void Reset()
+ {
+ allocator.Reset();
+ }
+
+ TInt AllocSize(TInt& aTotalAllocSize) const
+ {
+ return allocator.AllocSize(aTotalAllocSize);
+ }
+
+ TInt Available(TInt& aBiggestBlock) const
+ {
+ return allocator.Available(aBiggestBlock);
+ }
+
+ TInt DebugFunction(TInt aFunc, TAny* a1, TAny* a2)
+ {
+ return allocator.DebugFunction(aFunc, a1, a2);
+ }
+
+ TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+ {
+ return ((MAllocator&)allocator).Extension_(aExtensionId, a0, a1);
+ }
+};
+
+QAllocFailAllocator symbianTestAllocator;
+
#endif
struct AllocFailer
@@ -201,9 +277,6 @@ struct AllocFailer
#ifdef RUNNING_ON_VALGRIND
if (RUNNING_ON_VALGRIND)
VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(VALGRIND_GET_ALLOC_INDEX + index + 1);
-#elif defined(Q_OS_SYMBIAN)
- // symbian alloc fail index is 1 based
- __UHEAP_BURSTFAILNEXT(index+1, KMaxTUint16);
#endif
mallocFailIndex = index;
mallocFailActive = true;
@@ -214,8 +287,6 @@ struct AllocFailer
mallocFailActive = false;
#ifdef RUNNING_ON_VALGRIND
VALGRIND_ENABLE_OOM_AT_ALLOC_INDEX(0);
-#elif defined(Q_OS_SYMBIAN)
- __UHEAP_RESET;
#endif
}