summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/qpack/qpack_offline_decoder_bin.cc
blob: 851efe736333519d953f6a5a04fd0000060eaa4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cstddef>
#include <iostream>

#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_flags.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h"

int main(int argc, char* argv[]) {
  const char* usage =
      "Usage: qpack_offline_decoder input_filename expected_headers_filename "
      "....";
  std::vector<std::string> args =
      quic::QuicParseCommandLineFlags(usage, argc, argv);

  if (args.size() < 2 || args.size() % 2 != 0) {
    quic::QuicPrintCommandLineFlagHelp(usage);
    return 1;
  }

  size_t i;
  size_t success_count = 0;
  for (i = 0; 2 * i < args.size(); ++i) {
    const absl::string_view input_filename(args[2 * i]);
    const absl::string_view expected_headers_filename(args[2 * i + 1]);

    // Every file represents a different connection,
    // therefore every file needs a fresh decoding context.
    quic::QpackOfflineDecoder decoder;
    if (decoder.DecodeAndVerifyOfflineData(input_filename,
                                           expected_headers_filename)) {
      ++success_count;
    }
  }

  std::cout << "Processed " << i << " pairs of input files, " << success_count
            << " passed, " << (i - success_count) << " failed." << std::endl;

  // Return success if all input files pass.
  return (success_count == i) ? 0 : 1;
}