Skip to content

Commit 4391e10

Browse files
committed
auto install memdumper
Signed-off-by: code-sunbo <[email protected]>
1 parent bf211c7 commit 4391e10

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/device/hdc.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,22 @@ import { getLogger } from 'log4js';
2222
const logger = getLogger();
2323

2424
export const NEWLINE = /\r\n|\n/;
25+
const MEMDUMPER = '/data/local/tmp/memdumper';
2526

2627
export class Hdc {
2728
private connectkey: string | undefined;
2829

2930
constructor(connectkey: string | undefined = undefined) {
3031
this.connectkey = connectkey;
32+
this.initDeviceEnv();
33+
}
34+
35+
private initDeviceEnv(): void {
36+
if (!this.hasFile(MEMDUMPER)) {
37+
let memdumpFile = path.join(__dirname, '..', '..', 'res/memdumper/memdumper');
38+
this.sendFile(memdumpFile, MEMDUMPER);
39+
this.excuteShellCommand(`chmod +x ${MEMDUMPER}`);
40+
}
3141
}
3242

3343
sendFile(local: string, remote: string): number {
@@ -217,7 +227,7 @@ export class Hdc {
217227
idxMap.set(map.file, idx);
218228
let out = this.excuteShellCommand(
219229
...[
220-
'/data/local/tmp/memdumper',
230+
MEMDUMPER,
221231
'-s',
222232
map.start,
223233
'-n',

test/unit/glob_match.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2024 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+
import { describe, it, expect } from 'vitest';
17+
import { GlobMatch } from '../../src/utils/glob_match';
18+
19+
describe('GlobMatch Test', () => {
20+
it('test()', async () => {
21+
let match = new GlobMatch(['com.huawei.*', 'com.ohos.*']);
22+
expect(match.match('com.huawei.ouc')).eq(true);
23+
expect(match.match('com.ohos.ouc')).eq(true);
24+
expect(match.match('com.qq.ouc')).eq(false);
25+
});
26+
});

0 commit comments

Comments
 (0)