Zi Lin | 171ee1e | 2021-10-13 03:12:18 +0000 | [diff] [blame^] | 1 | /* test_util.h |
| 2 | * Copyright 2021 The Chromium OS Authors. All rights reserved. |
| 3 | * Use of this source code is governed by a BSD-style license that can be |
| 4 | * found in the LICENSE file. |
| 5 | * |
| 6 | * Utility functions in testing. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _TEST_UTIL_H_ |
| 10 | #define _TEST_UTIL_H_ |
| 11 | |
| 12 | #include <string> |
| 13 | |
| 14 | /* |
| 15 | * write_to_pipe: write a string as the file content into a pipe based |
| 16 | * file handle. This is particularly useful when testing with temporary data |
| 17 | * files, without dealing with complexities such as relative file path, file |
| 18 | * permission and etc. However, a pipe has limited capacity so write_to_pipe |
| 19 | * will hang when a big enough string is written. This is for use in testing |
| 20 | * only. |
| 21 | * |
| 22 | * Returns a FILE* that contains @content. |
| 23 | */ |
| 24 | |
| 25 | FILE *write_to_pipe(std::string content); |
| 26 | |
| 27 | #endif /* _TEST_UTIL_H_ */ |