1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _GTS_NANOAPPS_GENERAL_TEST_HEAP_EXHAUSTION_STABILITY_TEST_H_ 18 #define _GTS_NANOAPPS_GENERAL_TEST_HEAP_EXHAUSTION_STABILITY_TEST_H_ 19 20 #include <general_test/test.h> 21 22 namespace general_test { 23 24 /** 25 * Exhaust the heap and confirm the platform remains stable when trying 26 * various things. 27 * 28 * We don't require everything to be available when the heap is exhausted, 29 * but we do require the system is honest about its capabilities, and doesn't 30 * crash. 31 * 32 * Simple Protocol. 33 */ 34 class HeapExhaustionStabilityTest : public Test { 35 public: 36 HeapExhaustionStabilityTest(); 37 38 protected: 39 void handleEvent(uint32_t senderInstanceId, uint16_t eventType, 40 const void* eventData) override; 41 void setUp(uint32_t messageSize, const void *message) override; 42 43 private: 44 bool mInMethod; 45 46 void **mExhaustionPtrs; 47 size_t mExhaustionPtrCount; 48 49 static constexpr size_t kStageCount = 2; 50 static constexpr uint32_t kAllFinished = (1 << kStageCount) - 1; 51 uint32_t mFinishedBitmask; 52 53 void exhaustHeap(); 54 void freeMemory(); 55 56 void testLog(uint32_t zero); 57 void testSetTimer(); 58 void testSendEvent(); 59 void testSensor(); 60 // TODO(b/32114261): This method currently doesn't test anything. 61 void testMessageToHost(); 62 63 void handleTimer(uint32_t senderInstanceId, const void *eventData); 64 void handleSelfEvent(uint32_t senderInstanceId, const void *eventData); 65 66 void markSuccess(uint32_t stage); 67 }; 68 69 } // namespace general_test 70 71 72 #endif // _GTS_NANOAPPS_GENERAL_TEST_HEAP_EXHAUSTION_STABILITY_TEST_H_ 73