Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 1 | #ifndef TEST_COMMON_H |
| 2 | #define TEST_COMMON_H |
| 3 | |
| 4 | #include <stdlib.h> |
| 5 | #include <stdio.h> |
| 6 | #include <stdbool.h> |
| 7 | #include <string.h> |
| 8 | #include <assert.h> |
| 9 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 10 | #include <vulkan.h> |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 11 | |
| 12 | #include "gtest/gtest.h" |
Courtney Goeltzenleuchter | 5b80493 | 2014-09-01 16:33:55 -0600 | [diff] [blame] | 13 | #include "gtest-1.7.0/include/gtest/gtest.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 14 | #include "vktestbinding.h" |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 15 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 16 | #define ASSERT_VK_SUCCESS(err) ASSERT_EQ(VK_SUCCESS, err) << vk_result_string(err) |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 17 | |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 18 | static inline const char *vk_result_string(VkResult err) |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 19 | { |
| 20 | switch (err) { |
| 21 | #define STR(r) case r: return #r |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 22 | STR(VK_SUCCESS); |
| 23 | STR(VK_UNSUPPORTED); |
| 24 | STR(VK_NOT_READY); |
| 25 | STR(VK_TIMEOUT); |
| 26 | STR(VK_EVENT_SET); |
| 27 | STR(VK_EVENT_RESET); |
| 28 | STR(VK_ERROR_UNKNOWN); |
| 29 | STR(VK_ERROR_UNAVAILABLE); |
| 30 | STR(VK_ERROR_INITIALIZATION_FAILED); |
Tony Barbour | d1c3572 | 2015-04-16 15:59:00 -0600 | [diff] [blame^] | 31 | STR(VK_ERROR_OUT_OF_HOST_MEMORY); |
| 32 | STR(VK_ERROR_OUT_OF_DEVICE_MEMORY); |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 33 | STR(VK_ERROR_DEVICE_ALREADY_CREATED); |
| 34 | STR(VK_ERROR_DEVICE_LOST); |
| 35 | STR(VK_ERROR_INVALID_POINTER); |
| 36 | STR(VK_ERROR_INVALID_VALUE); |
| 37 | STR(VK_ERROR_INVALID_HANDLE); |
| 38 | STR(VK_ERROR_INVALID_ORDINAL); |
| 39 | STR(VK_ERROR_INVALID_MEMORY_SIZE); |
| 40 | STR(VK_ERROR_INVALID_EXTENSION); |
| 41 | STR(VK_ERROR_INVALID_FLAGS); |
| 42 | STR(VK_ERROR_INVALID_ALIGNMENT); |
| 43 | STR(VK_ERROR_INVALID_FORMAT); |
| 44 | STR(VK_ERROR_INVALID_IMAGE); |
| 45 | STR(VK_ERROR_INVALID_DESCRIPTOR_SET_DATA); |
| 46 | STR(VK_ERROR_INVALID_QUEUE_TYPE); |
| 47 | STR(VK_ERROR_INVALID_OBJECT_TYPE); |
| 48 | STR(VK_ERROR_UNSUPPORTED_SHADER_IL_VERSION); |
| 49 | STR(VK_ERROR_BAD_SHADER_CODE); |
| 50 | STR(VK_ERROR_BAD_PIPELINE_DATA); |
| 51 | STR(VK_ERROR_TOO_MANY_MEMORY_REFERENCES); |
| 52 | STR(VK_ERROR_NOT_MAPPABLE); |
| 53 | STR(VK_ERROR_MEMORY_MAP_FAILED); |
| 54 | STR(VK_ERROR_MEMORY_UNMAP_FAILED); |
| 55 | STR(VK_ERROR_INCOMPATIBLE_DEVICE); |
| 56 | STR(VK_ERROR_INCOMPATIBLE_DRIVER); |
| 57 | STR(VK_ERROR_INCOMPLETE_COMMAND_BUFFER); |
| 58 | STR(VK_ERROR_BUILDING_COMMAND_BUFFER); |
| 59 | STR(VK_ERROR_MEMORY_NOT_BOUND); |
| 60 | STR(VK_ERROR_INCOMPATIBLE_QUEUE); |
| 61 | STR(VK_ERROR_NOT_SHAREABLE); |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 62 | #undef STR |
| 63 | default: return "UNKNOWN_RESULT"; |
| 64 | } |
| 65 | } |
| 66 | |
Chia-I Wu | a9a506a | 2014-12-27 22:04:00 +0800 | [diff] [blame] | 67 | static inline void test_error_callback(const char *expr, const char *file, |
| 68 | unsigned int line, const char *function) |
| 69 | { |
| 70 | ADD_FAILURE_AT(file, line) << "Assertion: `" << expr << "'"; |
| 71 | } |
| 72 | |
Courtney Goeltzenleuchter | b7f5050 | 2014-08-12 14:09:50 -0600 | [diff] [blame] | 73 | #endif // TEST_COMMON_H |