• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright (C) 2024 Huawei Device Co., Ltd.
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.
15import subprocess
16import time
17
18def IsLogVersion():
19    output = subprocess.check_output("hdc shell param get const.product.software.version", shell=True, text=True, encoding="utf-8").strip()
20    return "log" in output
21
22def IsRootVersion():
23    output = subprocess.check_output("hdc shell param get const.debuggable", shell=True, text=True, encoding="utf-8").strip()
24    return output == "1"
25
26def IsOpenHarmonyVersion():
27    output = subprocess.check_output("hdc shell param get const.product.software.version", shell=True, text=True, encoding="utf-8").strip()
28    return "OpenHarmony" in output
29
30def pytest_sessionstart(session):
31    print("start install jsleakwatcher.hap")
32    subprocess.check_call("hdc install testModule/resource/jsleakwatcher.hap", shell=True)
33
34def pytest_sessionfinish(session, exitstatus):
35    print("start uinstall jsleakwatcher.hap")
36    subprocess.check_call("hdc uninstall com.example.jsleakwatcher", shell=True)