blob: 3112a390dccf2bb6532902e12916e83d743d2f19 [file] [log] [blame]
Shawn Willden76364712014-08-11 17:48:04 -06001/*
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 Willden2f3be362014-08-25 11:31:39 -060024#include <stdarg.h>
25
Shawn Willden76364712014-08-11 17:48:04 -060026#include <ostream>
27
Shawn Willden76364712014-08-11 17:48:04 -060028#include "authorization_set.h"
Shawn Willden2f3be362014-08-25 11:31:39 -060029#include "keymaster_defs.h"
30#include "logger.h"
Shawn Willden76364712014-08-11 17:48:04 -060031
32std::ostream& operator<<(std::ostream& os, const keymaster_key_param_t& param);
33bool operator==(const keymaster_key_param_t& a, const keymaster_key_param_t& b);
34
35namespace keymaster {
Shawn Willden2f3be362014-08-25 11:31:39 -060036
Shawn Willden76364712014-08-11 17:48:04 -060037bool operator==(const AuthorizationSet& a, const AuthorizationSet& b);
Shawn Willden2f3be362014-08-25 11:31:39 -060038
Shawn Willden76364712014-08-11 17:48:04 -060039std::ostream& operator<<(std::ostream& os, const AuthorizationSet& set);
Shawn Willden2f3be362014-08-25 11:31:39 -060040
41namespace test {
42
43class 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 Willden76364712014-08-11 17:48:04 -060055} // namespace keymaster
56
57#endif // SYSTEM_KEYMASTER_GOOGLE_KEYMASTER_TEST_UTILS_H_