1 // Copyright (c) 2018 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef QUICHE_COMMON_PLATFORM_API_QUICHE_TEST_OUTPUT_H_
6 #define QUICHE_COMMON_PLATFORM_API_QUICHE_TEST_OUTPUT_H_
7
8 #include "quiche_platform_impl/quiche_test_output_impl.h"
9
10 #include "absl/strings/string_view.h"
11
12 namespace quiche {
13
14 // Save |data| into ${QUICHE_TEST_OUTPUT_DIR}/filename. If a file with the same
15 // path already exists, overwrite it.
QuicheSaveTestOutput(absl::string_view filename,absl::string_view data)16 inline void QuicheSaveTestOutput(absl::string_view filename,
17 absl::string_view data) {
18 QuicheSaveTestOutputImpl(filename, data);
19 }
20
21 // Load the content of ${QUICHE_TEST_OUTPUT_DIR}/filename into |*data|.
22 // Return whether it is successfully loaded.
QuicheLoadTestOutput(absl::string_view filename,std::string * data)23 inline bool QuicheLoadTestOutput(absl::string_view filename,
24 std::string* data) {
25 return QuicheLoadTestOutputImpl(filename, data);
26 }
27
28 // Records a QUIC trace file(.qtr) into a directory specified by the
29 // QUICHE_TEST_OUTPUT_DIR environment variable. Assumes that it's called from a
30 // unit test.
31 //
32 // The |identifier| is a human-readable identifier that will be combined with
33 // the name of the unit test and a timestamp. |data| is the serialized
34 // quic_trace.Trace protobuf that is being recorded into the file.
QuicheRecordTrace(absl::string_view identifier,absl::string_view data)35 inline void QuicheRecordTrace(absl::string_view identifier,
36 absl::string_view data) {
37 QuicheRecordTraceImpl(identifier, data);
38 }
39
40 } // namespace quiche
41 #endif // QUICHE_COMMON_PLATFORM_API_QUICHE_TEST_OUTPUT_H_
42