• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2#
3# Copyright (C) 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#
17
18import logging
19
20from vts.runners.host import asserts
21from vts.runners.host import base_test
22from vts.runners.host import const
23from vts.runners.host import test_runner
24from vts.utils.python.controllers import android_device
25from vts.utils.python.file import file_utils
26
27HWBINDER_PATH = "/dev/hwbinder"
28
29class VtsKernelHwBinderTest(base_test.BaseTestClass):
30    """Test case to validate existence of hwbinder node.
31    """
32
33    def setUpClass(self):
34        self.dut = self.registerController(android_device)[0]
35        self.dut.shell.InvokeTerminal(
36            "VtsKernelHwBinderTest")  # creates a remote shell instance.
37        self.shell = self.dut.shell.VtsKernelHwBinderTest
38
39    def testHwbinderExistence(self):
40        """Checks that hwbinder node exists.
41        """
42        logging.info("Testing existence of %s", HWBINDER_PATH)
43        asserts.assertTrue(
44            file_utils.Exists(HWBINDER_PATH, self.shell),
45            "%s: File does not exist." % HWBINDER_PATH)
46
47        try:
48            permissions = file_utils.GetPermission(HWBINDER_PATH, self.shell)
49            asserts.assertTrue(file_utils.IsReadWrite(permissions),
50                               "%s: File has invalid permissions (%s)" %
51                               (HWBINDER_PATH, permissions))
52        except (ValueError, IOError) as e:
53            asserts.fail("Failed to assert permissions: %s" % str(e))
54
55if __name__ == "__main__":
56    test_runner.main()
57