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_SHARED_ABORT_H_ 18 #define _GTS_NANOAPPS_SHARED_ABORT_H_ 19 20 #include <cstdint> 21 22 namespace nanoapp_testing { 23 24 /** 25 * Enumeration of what should be blamed for why the test was aborted. 26 */ 27 enum class AbortBlame : uint16_t { 28 /** 29 * Most common failure mode, a presumed issue within the CHRE 30 * implementation. 31 * 32 * The test should have sent out an error message prior to aborting. 33 */ 34 kChre = 0, 35 36 /** 37 * A presumed issue within the CHRE implementation, discovered while 38 * in the nanoappEnd() method of the nanoapp. 39 * 40 * This differs from kChre in that we're not able to send out an 41 * error message prior to aborting, so we want a distinct value. 42 */ 43 kChreInNanoappEnd = 1, 44 45 /** 46 * A presumed bug in the test framework itself. 47 * 48 * The test should have sent out a kInternalError message prior to 49 * aborting. 50 */ 51 kTestFramework = 2 52 }; 53 54 /** 55 * This should fatally abort the nanoapp, and hence the current test. 56 * 57 * This is useful in cases where we cannot proceed due to previous issues, 58 * or in cases where we want to make unambigously clear that we've 59 * experienced a failure. 60 * 61 * The presumption is that code will send out a message prior to calling 62 * this method, if at all practical. 63 * 64 * This will invoke chreAbort() with the code (0x10000 + uint16_t(reason)), 65 * preserving the lower two bytes for tests to use for testing of 66 * chreAbort(). 67 * 68 * @param reason Optional. The appropriate AbortBlame. Defaults to kChre. 69 * @returns This function should never return. 70 */ 71 void abort(AbortBlame reason = AbortBlame::kChre); 72 73 } // namespace nanoapp_testing 74 75 #endif // _GTS_NANOAPPS_SHARED_ABORT_H_ 76