Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 SYSTEM_KEYMASTER_GOOGLE_KEYMASTER_TEST_UTILS_H_ |
| 18 | #define SYSTEM_KEYMASTER_GOOGLE_KEYMASTER_TEST_UTILS_H_ |
| 19 | |
| 20 | /* |
| 21 | * Utilities used to help with testing. Not used in production code. |
| 22 | */ |
| 23 | |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame^] | 24 | #include <stdarg.h> |
| 25 | |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 26 | #include <ostream> |
| 27 | |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 28 | #include "authorization_set.h" |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame^] | 29 | #include "keymaster_defs.h" |
| 30 | #include "logger.h" |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 31 | |
| 32 | std::ostream& operator<<(std::ostream& os, const keymaster_key_param_t& param); |
| 33 | bool operator==(const keymaster_key_param_t& a, const keymaster_key_param_t& b); |
| 34 | |
| 35 | namespace keymaster { |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame^] | 36 | |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 37 | bool operator==(const AuthorizationSet& a, const AuthorizationSet& b); |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame^] | 38 | |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 39 | std::ostream& operator<<(std::ostream& os, const AuthorizationSet& set); |
Shawn Willden | 2f3be36 | 2014-08-25 11:31:39 -0600 | [diff] [blame^] | 40 | |
| 41 | namespace test { |
| 42 | |
| 43 | class StdoutLogger : public Logger { |
| 44 | public: |
| 45 | int log(const char* fmt, ...) const { |
| 46 | va_list args; |
| 47 | va_start(args, fmt); |
| 48 | int result = vprintf(fmt, args); |
| 49 | va_end(args); |
| 50 | return result; |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | } // namespace test |
Shawn Willden | 7636471 | 2014-08-11 17:48:04 -0600 | [diff] [blame] | 55 | } // namespace keymaster |
| 56 | |
| 57 | #endif // SYSTEM_KEYMASTER_GOOGLE_KEYMASTER_TEST_UTILS_H_ |