1#!/usr/bin/env python
2#
3# Copyright (C) 2022 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 os
19import time
20import unittest
21
22from vts.testcases.kernel.utils import adb
23from vts.testcases.vndk import utils
24
25class VtsKernelFuseBpfTest(unittest.TestCase):
26
27    def setUp(self):
28        serial_number = os.environ.get("ANDROID_SERIAL")
29        self.assertTrue(serial_number, "$ANDROID_SERIAL is empty.")
30        self.dut = utils.AndroidDevice(serial_number)
31        self.adb = adb.ADB(serial_number)
32
33    def testFuseBpfEnabled(self):
34        out_api, err, return_code = self.dut.Execute("getprop ro.vendor.api_level")
35        first_api_level = 0
36        try:
37            first_api_level = int(out_api)
38        except:
39            pass
40        out_running, err, return_code = self.dut.Execute("getprop ro.fuse.bpf.is_running")
41        self.assertTrue(first_api_level < 34 or out_running.strip() == "true",
42                           "fuse-bpf is disabled")
43
44
45if __name__ == "__main__":
46    # Setting verbosity is required to generate output that the TradeFed test
47    # runner can parse.
48    unittest.main(verbosity=3)
49