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