1#!/usr/bin/env python
2#
3# Copyright 2017 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16"""VINTF-related utilities."""
17
18import logging
19
20from gsi_util.utils import cmd_utils
21
22
23def checkvintf(manifest, matrix):
24  """Invokes host command 'checkvintf' to do VINTF check.
25
26  Usage of the command: checkvintf <manifest.xml> <matrix.xml>.
27
28  Args:
29    manifest: the manifest XML file.
30    matrix: the matrix XML file.
31
32  Returns:
33    A tuple of (result_ok, stderr).
34  """
35  logging.debug('checkvintf %s %s...', manifest, matrix)
36
37  # Uses 'read_stdout' and 'read_stderr' to disable output.
38  returncode, _, stderrdata = cmd_utils.run_command(
39      ['checkvintf', manifest, matrix],
40      raise_on_error=False,
41      read_stdout=True,
42      read_stderr=True)
43  return (returncode == 0, stderrdata)
44