1#!/usr/bin/env python3
2# coding=utf-8
3
4#
5# Copyright (C) 2021 Huawei Device Co., Ltd.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19import sys
20import os
21sys.path.insert(0, os.environ.get('PYTEST_PYTESTPATH'))
22import unittest
23from distributed import *
24
25class DbinderTest(unittest.TestCase):
26    def setUp(self):
27        print('setUp')
28        self.result_path = get_result_dir(__file__)
29        self.suits_dir = os.path.abspath(os.path.dirname(__file__))
30        self.manager = DeviceManager()
31        self.major = self.manager.PHONE1
32        self.agent_list = [self.manager.PHONE2]
33
34    def test_dbinder(self):
35        major_target_name = "DbinderTest"
36        agent_target_name = "DbinderTestAgent"
37
38        distribute = Distribute(self.suits_dir, self.major, self.agent_list)
39
40        for agent in self.agent_list:
41            if not distribute.exec_agent(agent, agent_target_name):
42                create_empty_result_file(self.result_path, major_target_name)
43                return
44
45        distribute.exec_major(self.major, major_target_name)
46
47        source_path = "%s/%s.xml" % (self.major.test_path, major_target_name)
48        distribute.pull_result(self.major, source_path, self.result_path)
49
50    def tearDown(self):
51        print('tearDown')
52
53
54if __name__ == '__main__':
55    unittest.main()
56