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 16import { PluginConvertUtils } from '../../../../../src/trace/component/setting/utils/PluginConvertUtils'; 17import { ProfilerSessionConfigMode } from '../../../../../src/trace/component/setting/bean/ProfilerServiceTypes'; 18 19import { 20 ProfilerSessionConfigBufferConfig, 21 ProfilerSessionConfigBufferConfigPolicy, 22 TracePluginConfig, 23 // @ts-ignore 24} from '../../../../../src/trace/component/setting/bean/ProfilerServiceTypes'; 25import { 26 HilogConfig, 27 levelFromJSON, 28 Type, 29 // @ts-ignore 30} from '../../../../../src/trace/component/setting/bean/ProfilerServiceTypes'; 31import { 32 MemoryConfig, 33 sysMeminfoTypeFromJSON, 34 sysVMeminfoTypeFromJSON, 35 // @ts-ignore 36} from '../../../../../src/trace/component/setting/bean/ProfilerServiceTypes'; 37import { SpRecordTrace } from '../../../../../src/trace/component/SpRecordTrace'; 38 39describe('PlugConvertUtils Test', () => { 40 let bufferConfig: ProfilerSessionConfigBufferConfig = { 41 pages: 1000, 42 policy: ProfilerSessionConfigBufferConfigPolicy.RECYCLE, 43 }; 44 let sessionConfig = { 45 buffers: [bufferConfig], 46 sessionMode: ProfilerSessionConfigMode.OFFLINE, 47 resultFile: '/data/local/tmp/hiprofiler_data.htrace', 48 resultMaxSize: 0, 49 sampleDuration: 1000, 50 keepAliveTime: 0, 51 }; 52 let tracePluginConfig: TracePluginConfig = { 53 ftraceEvents: [], 54 bytraceCategories: [], 55 bytraceApps: [], 56 bufferSizeKb: 1024, 57 flushIntervalMs: 1000, 58 flushThresholdKb: 4096, 59 parseKsyms: true, 60 clock: 'mono', 61 tracePeriodMs: 200, 62 rawDataPrefix: '', 63 traceDurationMs: 0, 64 debugOn: false, 65 }; 66 let hilogConfig: HilogConfig = { 67 deviceType: Type.HI3516, 68 logLevel: levelFromJSON('Info'), 69 needClear: true, 70 }; 71 let memoryconfig: MemoryConfig = { 72 reportProcessTree: true, 73 reportSysmemMemInfo: true, 74 sysMeminfoCounters: [], 75 reportSysmemVmemInfo: true, 76 sysVmeminfoCounters: [], 77 reportProcessMemInfo: true, 78 reportAppMemInfo: false, 79 reportAppMemByMemoryService: false, 80 pid: [], 81 }; 82 83 SpRecordTrace.MEM_INFO.forEach((va: any) => { 84 memoryconfig.sysMeminfoCounters.push(sysMeminfoTypeFromJSON(va)); 85 }); 86 SpRecordTrace.VMEM_INFO.forEach((me: any) => { 87 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); 88 }); 89 SpRecordTrace.VMEM_INFO_SECOND.forEach((me: any) => { 90 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); 91 }); 92 SpRecordTrace.VMEM_INFO_THIRD.forEach((me: any) => { 93 memoryconfig.sysVmeminfoCounters.push(sysVMeminfoTypeFromJSON(me)); 94 }); 95 96 let request = { 97 requestId: 1, 98 sessionConfig: sessionConfig, 99 pluginConfigs: [tracePluginConfig, hilogConfig, memoryconfig], 100 }; 101 102 it('PlugConvertUtils01', function () { 103 expect(PluginConvertUtils.createHdcCmd('aaaa', 11)).not.toBeNull(); 104 }); 105 106 it('PlugConvertUtils02', function () { 107 expect(PluginConvertUtils.BeanToCmdTxt(request, true)).not.toBeNull(); 108 }); 109 110 it('PlugConvertUtils03', function () { 111 expect(PluginConvertUtils.BeanToCmdTxtWithObjName(request, false, '', 1)).not.toBeNull(); 112 }); 113}); 114