• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# Copyright (C) 2017 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
16from __future__ import print_function
17import sys
18import os
19import subprocess
20import tempfile
21
22
23def test_command(*args):
24  subprocess.check_call(args, stdout=sys.stdout, stderr=sys.stderr)
25
26
27if __name__ == '__main__':
28  if len(sys.argv) != 4:
29    print('Usage: test_proto_gen.py to/ftrace_proto_gen to/protoc to/format')
30    exit(1)
31  ftrace_proto_gen_path = sys.argv[1]
32  protoc_path = sys.argv[2]
33  format_path = sys.argv[3]
34  tmpdir = tempfile.mkdtemp()
35  proto_path = os.path.join(tmpdir, 'format.proto')
36  test_command(ftrace_proto_gen_path, format_path, proto_path)
37  test_command(protoc_path, proto_path, '--proto_path=' + tmpdir,
38               '--cpp_out=' + tmpdir)
39