1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16// @ts-ignore 17import {PluginConvertUtils} from "../../../../../dist/trace/component/setting/utils/PluginConvertUtils.js"; 18// @ts-ignore 19import {ProfilerSessionConfigMode} from "../../../../../dist/trace/component/setting/bean/ProfilerServiceTypes"; 20 21import { 22 ProfilerSessionConfigBufferConfig, 23 ProfilerSessionConfigBufferConfigPolicy, TracePluginConfig 24 // @ts-ignore 25} from "../../../../../dist/trace/component/setting/bean/ProfilerServiceTypes.js"; 26import { 27 HilogConfig, 28 levelFromJSON, 29 Type 30 // @ts-ignore 31} from "../../../../../dist/trace/component/setting/bean/ProfilerServiceTypes.js"; 32import { 33 MemoryConfig, 34 sysMeminfoTypeFromJSON, sysVMeminfoTypeFromJSON 35 // @ts-ignore 36} from "../../../../../dist/trace/component/setting/bean/ProfilerServiceTypes.js"; 37// @ts-ignore 38import {SpRecordTrace} from "../../../../../dist/trace/component/SpRecordTrace.js"; 39 40describe('PlugConvertUtils Test', ()=>{ 41 let bufferConfig: ProfilerSessionConfigBufferConfig = { 42 pages: 1000, 43 policy: ProfilerSessionConfigBufferConfigPolicy.RECYCLE 44 } 45 let sessionConfig = { 46 buffers: [bufferConfig], 47 sessionMode: ProfilerSessionConfigMode.OFFLINE, 48 resultFile: "/data/local/tmp/hiprofiler_data.htrace", 49 resultMaxSize: 0, 50 sampleDuration: 1000, 51 keepAliveTime: 0 52 }; 53 let tracePluginConfig: TracePluginConfig = { 54 ftraceEvents: [], 55 bytraceCategories: [], 56 bytraceApps: [], 57 bufferSizeKb: 1024, 58 flushIntervalMs: 1000, 59 flushThresholdKb: 4096, 60 parseKsyms: true, 61 clock: "mono", 62 tracePeriodMs: 200, 63 rawDataPrefix: "", 64 traceDurationMs: 0, 65 debugOn: false, 66 } 67 let hilogConfig: HilogConfig = { 68 deviceType: Type.HI3516, 69 logLevel: levelFromJSON("Info"), 70 needClear: true 71 } 72 let memoryconfig: MemoryConfig = { 73 reportProcessTree: true, 74 reportSysmemMemInfo: true, 75 sysMeminfoCounters: [], 76 reportSysmemVmemInfo: true, 77 sysVmeminfoCounters: [], 78 reportProcessMemInfo: true, 79 reportAppMemInfo: false, 80 reportAppMemByMemoryService: false, 81 pid: [] 82 } 83 84 SpRecordTrace.MEM_INFO.forEach((va: any) => { 85 memoryconfig.sysMeminfoCounters.push(sysMeminfoTypeFromJSON(va)); 86 }) 87 SpRecordTrace.VMEM_INFO.forEach(((me: any) => { 88 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)) 89 })) 90 SpRecordTrace.VMEM_INFO_SECOND.forEach(((me: any) => { 91 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)) 92 })) 93 SpRecordTrace.VMEM_INFO_THIRD.forEach(((me: any) => { 94 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)) 95 })) 96 97 let request = { 98 requestId: 1, 99 sessionConfig: sessionConfig, 100 pluginConfigs: [tracePluginConfig, hilogConfig,memoryconfig] 101 }; 102 103 it('PlugConvertUtils01', function () { 104 expect(PluginConvertUtils.createHdcCmd("aaaa", 11)).not.toBeNull() 105 }); 106 107 it('PlugConvertUtils02', function () { 108 expect(PluginConvertUtils.BeanToCmdTxt(request, true)).not.toBeNull() 109 }); 110 111 it('PlugConvertUtils03', function () { 112 expect(PluginConvertUtils.BeanToCmdTxtWithObjName(request, false,'',1)).not.toBeNull() 113 }); 114 115})