1#!/usr/bin/env python3 2#-*- coding: utf-8 -*- 3 4# Copyright (c) 2025 Huawei Device Co., Ltd. 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 17from devicetest.utils.file_util import get_resource_path 18 19 20def get_source_path(need_source, casename): 21 """ 22 @func: get the resource path required for a case 23 @param need_source: the resources required for a case 24 @param casename: the case name 25 @return: source absolute paths 26 """ 27 28 source_path = {} 29 if need_source["cfg"]: 30 cfg_relative_path = "resource/" + casename + "/listen_test.cfg" 31 json_relative_path = "resource/" + casename + "/listen_test.json" 32 sa_listen_cfg_path = get_resource_path( 33 cfg_relative_path, 34 isdir=None) 35 sa_listen_json_path = get_resource_path( 36 json_relative_path, 37 isdir=None) 38 source_path["sa_listen_cfg_path"] = sa_listen_cfg_path 39 source_path["sa_listen_json_path"] = sa_listen_json_path 40 41 42 if need_source["listen_test"]: 43 sa_lib_listen_test_path = get_resource_path( 44 "resource/soResource/liblisten_test.z.so", 45 isdir=None) 46 source_path["sa_lib_listen_test_path"] = sa_lib_listen_test_path 47 48 if need_source["audio_ability"]: 49 sa_lib_audio_ability = get_resource_path( 50 "resource/soResource/libtest_audio_ability.z.so", 51 isdir=None) 52 source_path["sa_lib_audio_ability"] = sa_lib_audio_ability 53 54 if need_source["ondemand"]: 55 sa_ondemand_path = get_resource_path( 56 "resource/soResource/ondemand", 57 isdir=None) 58 source_path["sa_ondemand_path"] = sa_ondemand_path 59 60 if need_source["proxy"]: 61 sa_proxy_path = get_resource_path( 62 "resource/soResource/libtest_sa_proxy_cache.z.so", 63 isdir=None) 64 source_path["sa_proxy_path"] = sa_proxy_path 65 66 if need_source["para"]: 67 sa_para_path = get_resource_path( 68 "resource/level0/case13_param001/samgr.para", 69 isdir=None) 70 sa_para_dac_path = get_resource_path( 71 "resource/level0/case13_param001/samgr.para.dac", 72 isdir=None) 73 sa_para_origin = get_resource_path( 74 "resource/originFile/samgr.para", 75 isdir=None) 76 sa_para_dac_origin = get_resource_path( 77 "resource/originFile/samgr.para.dac", 78 isdir=None) 79 source_path["sa_para_path"] = sa_para_path 80 source_path["sa_para_dac_path"] = sa_para_dac_path 81 source_path["sa_para_origin"] = sa_para_origin 82 source_path["sa_para_dac_origin"] = sa_para_dac_origin 83 84 return source_path 85