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