13f085823Sopenharmony_ci#!/usr/bin/env python3
23f085823Sopenharmony_ci# coding=utf-8
33f085823Sopenharmony_ci
43f085823Sopenharmony_ci#
53f085823Sopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
63f085823Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
73f085823Sopenharmony_ci# you may not use this file except in compliance with the License.
83f085823Sopenharmony_ci# You may obtain a copy of the License at
93f085823Sopenharmony_ci#
103f085823Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
113f085823Sopenharmony_ci#
123f085823Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
133f085823Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
143f085823Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
153f085823Sopenharmony_ci# See the License for the specific language governing permissions and
163f085823Sopenharmony_ci# limitations under the License.
173f085823Sopenharmony_ci#
183f085823Sopenharmony_ci
193f085823Sopenharmony_ciimport sys
203f085823Sopenharmony_ciimport os
213f085823Sopenharmony_ci
223f085823Sopenharmony_cisys.path.insert(0, os.environ.get('PYTEST_PYTESTPATH'))
233f085823Sopenharmony_ci
243f085823Sopenharmony_ciimport unittest
253f085823Sopenharmony_cifrom distributed import *
263f085823Sopenharmony_ci
273f085823Sopenharmony_ci
283f085823Sopenharmony_ciclass DbinderTest(unittest.TestCase):
293f085823Sopenharmony_ci    def setUp(self):
303f085823Sopenharmony_ci        print('setUp')
313f085823Sopenharmony_ci        self.result_path = get_result_dir(__file__)
323f085823Sopenharmony_ci        self.suits_dir = os.path.abspath(os.path.dirname(__file__))
333f085823Sopenharmony_ci        self.manager = DeviceManager()
343f085823Sopenharmony_ci        self.major = self.manager.PHONE1
353f085823Sopenharmony_ci        self.angent_list = [self.manager.WATCH1, self.manager.PHONE2]
363f085823Sopenharmony_ci
373f085823Sopenharmony_ci    def test_dbinder(self):
383f085823Sopenharmony_ci        major_target_name = "DbinderTest"
393f085823Sopenharmony_ci        agent_target_name = "DbinderTestAgent"
403f085823Sopenharmony_ci
413f085823Sopenharmony_ci        distribute = Distribute(self.suits_dir, self.major, self.angent_list)
423f085823Sopenharmony_ci
433f085823Sopenharmony_ci        for agent in self.angent_list:
443f085823Sopenharmony_ci            if not distribute.exec_agent(agent, agent_target_name):
453f085823Sopenharmony_ci                create_empty_result_file(self.result_path, major_target_name)
463f085823Sopenharmony_ci                return
473f085823Sopenharmony_ci
483f085823Sopenharmony_ci        distribute.exec_major(self.major, major_target_name)
493f085823Sopenharmony_ci
503f085823Sopenharmony_ci        source_path = "%s/%s.xml" % (self.major.test_path, major_target_name)
513f085823Sopenharmony_ci        distribute.pull_result(self.major, source_path, self.result_path)
523f085823Sopenharmony_ci
533f085823Sopenharmony_ci    def tearDown(self):
543f085823Sopenharmony_ci        print('tearDown')
553f085823Sopenharmony_ci
563f085823Sopenharmony_ci
573f085823Sopenharmony_ciif __name__ == '__main__':
583f085823Sopenharmony_ci    unittest.main()
59