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 #include <cstddef> 6 #include <iostream> 7 8 #include "absl/strings/string_view.h" 9 #include "quiche/quic/platform/api/quic_flags.h" 10 #include "quiche/quic/platform/api/quic_logging.h" 11 #include "quiche/quic/test_tools/qpack/qpack_offline_decoder.h" 12 #include "quiche/common/platform/api/quiche_command_line_flags.h" 13 main(int argc,char * argv[])14int main(int argc, char* argv[]) { 15 const char* usage = 16 "Usage: qpack_offline_decoder input_filename expected_headers_filename " 17 "...."; 18 std::vector<std::string> args = 19 quiche::QuicheParseCommandLineFlags(usage, argc, argv); 20 21 if (args.size() < 2 || args.size() % 2 != 0) { 22 quiche::QuichePrintCommandLineFlagHelp(usage); 23 return 1; 24 } 25 26 size_t i; 27 size_t success_count = 0; 28 for (i = 0; 2 * i < args.size(); ++i) { 29 const absl::string_view input_filename(args[2 * i]); 30 const absl::string_view expected_headers_filename(args[2 * i + 1]); 31 32 // Every file represents a different connection, 33 // therefore every file needs a fresh decoding context. 34 quic::QpackOfflineDecoder decoder; 35 if (decoder.DecodeAndVerifyOfflineData(input_filename, 36 expected_headers_filename)) { 37 ++success_count; 38 } 39 } 40 41 std::cout << "Processed " << i << " pairs of input files, " << success_count 42 << " passed, " << (i - success_count) << " failed." << std::endl; 43 44 // Return success if all input files pass. 45 return (success_count == i) ? 0 : 1; 46 } 47