@webos-tools/cli 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/.eslintignore +1 -1
  2. package/.eslintrc.js +52 -52
  3. package/APIs.js +79 -79
  4. package/CHANGELOG.md +128 -128
  5. package/LICENSE +201 -201
  6. package/README.md +218 -218
  7. package/bin/ares-config.js +199 -199
  8. package/bin/ares-device-info.js +30 -30
  9. package/bin/ares-device.js +219 -219
  10. package/bin/ares-generate.js +270 -270
  11. package/bin/ares-inspect.js +179 -179
  12. package/bin/ares-install.js +223 -223
  13. package/bin/ares-launch.js +318 -318
  14. package/bin/ares-log.js +255 -255
  15. package/bin/ares-novacom.js +223 -223
  16. package/bin/ares-package.js +336 -336
  17. package/bin/ares-pull.js +156 -156
  18. package/bin/ares-push.js +155 -155
  19. package/bin/ares-server.js +174 -174
  20. package/bin/ares-setup-device.js +520 -520
  21. package/bin/ares-shell.js +132 -132
  22. package/bin/ares.js +166 -166
  23. package/files/conf/ares.json +49 -49
  24. package/files/conf/command-service.json +73 -73
  25. package/files/conf/config.json +22 -22
  26. package/files/conf/ipk.json +30 -30
  27. package/files/conf/novacom-devices.json +35 -35
  28. package/files/conf/query/query-app.json +14 -14
  29. package/files/conf/query/query-hosted.json +18 -18
  30. package/files/conf/query/query-package.json +10 -10
  31. package/files/conf/query/query-service.json +6 -6
  32. package/files/conf/sdk.json +8 -8
  33. package/files/conf/template.json +57 -57
  34. package/files/conf/webos_emul +27 -27
  35. package/files/conf-base/env/sdk-ose.json +8 -8
  36. package/files/conf-base/env/sdk-tv.json +8 -8
  37. package/files/conf-base/profile/config-ose.json +21 -21
  38. package/files/conf-base/profile/config-tv.json +22 -22
  39. package/files/conf-base/query/query-app.json +14 -14
  40. package/files/conf-base/query/query-hosted.json +18 -18
  41. package/files/conf-base/query/query-package.json +10 -10
  42. package/files/conf-base/query/query-service.json +6 -6
  43. package/files/conf-base/template-conf/ose-templates.json +67 -67
  44. package/files/conf-base/template-conf/tv-sdk-templates.json +57 -57
  45. package/files/help/ares-config.help +43 -43
  46. package/files/help/ares-device.help +94 -94
  47. package/files/help/ares-generate.help +65 -65
  48. package/files/help/ares-inspect.help +70 -70
  49. package/files/help/ares-install.help +90 -90
  50. package/files/help/ares-launch.help +100 -100
  51. package/files/help/ares-log-pmlogd.help +84 -84
  52. package/files/help/ares-log.help +101 -101
  53. package/files/help/ares-novacom.help +68 -68
  54. package/files/help/ares-package.help +101 -101
  55. package/files/help/ares-pull.help +38 -38
  56. package/files/help/ares-push.help +38 -38
  57. package/files/help/ares-server.help +39 -39
  58. package/files/help/ares-setup-device.help +75 -75
  59. package/files/help/ares-shell.help +42 -42
  60. package/files/help/ares.help +47 -47
  61. package/files/help/readme.help +23 -23
  62. package/files/schema/ApplicationDescription.schema +319 -319
  63. package/files/schema/NovacomDevices.schema +61 -61
  64. package/files/templates/ose-sdk-templates/appinfo/appinfo.json +10 -10
  65. package/files/templates/ose-sdk-templates/bootplate-web/index.html +88 -88
  66. package/files/templates/ose-sdk-templates/hosted-webapp/index.html +13 -13
  67. package/files/templates/ose-sdk-templates/icon/icon.png +0 -0
  68. package/files/templates/ose-sdk-templates/js-service/helloclient.js +31 -31
  69. package/files/templates/ose-sdk-templates/js-service/helloworld_webos_service.js +188 -188
  70. package/files/templates/ose-sdk-templates/qml-app/main.qml +68 -68
  71. package/files/templates/ose-sdk-templates/qmlappinfo/appinfo.json +10 -10
  72. package/files/templates/ose-sdk-templates/serviceinfo/package.json +11 -11
  73. package/files/templates/ose-sdk-templates/serviceinfo/services.json +8 -8
  74. package/files/templates/tv-sdk-templates/appinfo/appinfo.json +10 -10
  75. package/files/templates/tv-sdk-templates/bootplate-web/index.html +58 -58
  76. package/files/templates/tv-sdk-templates/bootplate-web/webOSTVjs-1.2.10/LICENSE-2.0.txt +202 -202
  77. package/files/templates/tv-sdk-templates/hosted-webapp/index.html +14 -14
  78. package/files/templates/tv-sdk-templates/js-service/helloworld_service.js +39 -39
  79. package/files/templates/tv-sdk-templates/packageinfo/packageinfo.json +3 -3
  80. package/files/templates/tv-sdk-templates/serviceinfo/package.json +11 -11
  81. package/files/templates/tv-sdk-templates/serviceinfo/services.json +8 -8
  82. package/files/templates/tv-sdk-templates/webicon/icon.png +0 -0
  83. package/files/templates/tv-sdk-templates/webicon/largeIcon.png +0 -0
  84. package/lib/base/ares.html +40 -40
  85. package/lib/base/cli-appdata.js +290 -290
  86. package/lib/base/cli-control.js +44 -44
  87. package/lib/base/common-tools.js +29 -29
  88. package/lib/base/error-handler.js +265 -265
  89. package/lib/base/file-watcher.js +155 -155
  90. package/lib/base/help-format.js +147 -147
  91. package/lib/base/luna.js +178 -178
  92. package/lib/base/novacom.js +1191 -1191
  93. package/lib/base/sdkenv.js +59 -59
  94. package/lib/base/server.js +137 -137
  95. package/lib/base/setup-device.js +328 -328
  96. package/lib/base/version-tools.js +79 -79
  97. package/lib/device.js +1419 -1419
  98. package/lib/generator.js +377 -377
  99. package/lib/inspect.js +494 -494
  100. package/lib/install.js +463 -463
  101. package/lib/launch.js +605 -605
  102. package/lib/log.js +584 -584
  103. package/lib/package.js +2129 -2129
  104. package/lib/pull.js +231 -231
  105. package/lib/pusher.js +210 -210
  106. package/lib/session.js +74 -74
  107. package/lib/shell.js +193 -193
  108. package/lib/tar-filter-pack.js +62 -62
  109. package/lib/util/copy.js +31 -31
  110. package/lib/util/createFileName.js +40 -40
  111. package/lib/util/eof.js +30 -30
  112. package/lib/util/json.js +63 -63
  113. package/lib/util/merge.js +14 -14
  114. package/lib/util/objclone.js +40 -40
  115. package/lib/util/spinner.js +37 -37
  116. package/npm-shrinkwrap.json +9115 -9115
  117. package/package.json +100 -100
  118. package/scripts/postinstall.js +24 -24
  119. package/spec/helpers/reporter.js +65 -65
  120. package/spec/jsSpecs/apiTest/generator.spec.js +372 -372
  121. package/spec/jsSpecs/apiTest/inspector.spec.js +89 -89
  122. package/spec/jsSpecs/apiTest/installer.spec.js +67 -67
  123. package/spec/jsSpecs/apiTest/launcher.spec.js +150 -150
  124. package/spec/jsSpecs/apiTest/packager.spec.js +194 -194
  125. package/spec/jsSpecs/apiTest/puller.spec.js +101 -101
  126. package/spec/jsSpecs/apiTest/pusher.spec.js +103 -103
  127. package/spec/jsSpecs/apiTest/server.spec.js +115 -115
  128. package/spec/jsSpecs/apiTest/setupDevice.spec.js +93 -93
  129. package/spec/jsSpecs/apiTest/shell.spec.js +49 -49
  130. package/spec/jsSpecs/ares-config.spec.js +78 -78
  131. package/spec/jsSpecs/ares-device.spec.js +443 -443
  132. package/spec/jsSpecs/ares-generate.spec.js +397 -397
  133. package/spec/jsSpecs/ares-inspect.spec.js +252 -252
  134. package/spec/jsSpecs/ares-install.spec.js +150 -150
  135. package/spec/jsSpecs/ares-launch.spec.js +301 -301
  136. package/spec/jsSpecs/ares-log.spec.js +824 -824
  137. package/spec/jsSpecs/ares-novacom.spec.js +149 -149
  138. package/spec/jsSpecs/ares-package.spec.js +1211 -1211
  139. package/spec/jsSpecs/ares-pull.spec.js +157 -157
  140. package/spec/jsSpecs/ares-push.spec.js +146 -146
  141. package/spec/jsSpecs/ares-server.spec.js +160 -160
  142. package/spec/jsSpecs/ares-setup-device.spec.js +281 -281
  143. package/spec/jsSpecs/ares-shell.spec.js +220 -220
  144. package/spec/jsSpecs/ares.spec.js +83 -83
  145. package/spec/jsSpecs/common-spec.js +169 -169
  146. package/spec/support/jasmine.json +22 -22
  147. package/spec/tempFiles/nativeApp/auto/pkg_arm64/GLES2 +0 -0
  148. package/spec/tempFiles/nativeApp/auto/pkg_arm64/appinfo.json +9 -9
  149. package/spec/tempFiles/nativeApp/ose/pkg_arm/Hello +0 -0
  150. package/spec/tempFiles/nativeApp/ose/pkg_arm/appinfo.json +8 -8
  151. package/spec/tempFiles/nativeApp/ose/pkg_arm/package.properties +2 -2
  152. package/spec/tempFiles/nativeApp/oseEmul/pkg_x86/Hello +0 -0
  153. package/spec/tempFiles/nativeApp/oseEmul/pkg_x86/appinfo.json +9 -9
  154. package/spec/tempFiles/nativeApp/rsi/pkg_x86/GLES2 +0 -0
  155. package/spec/tempFiles/nativeApp/rsi/pkg_x86/appinfo.json +9 -9
  156. package/spec/tempFiles/sign/sign.crt +32 -32
  157. package/spec/tempFiles/sign/signPriv.key +52 -52
  158. package/spec/test_data/ares-generate.json +41 -41
  159. package/spec/test_data/ares.json +33 -33
@@ -1,824 +1,824 @@
1
- /*
2
- * Copyright (c) 2021-2024 LG Electronics Inc.
3
- *
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- /* eslint-disable no-useless-escape */
8
-
9
- const exec = require('child_process').exec,
10
- path = require('path'),
11
- fs = require('fs'),
12
- common = require('./common-spec');
13
-
14
- const aresCmd = 'ares-log',
15
- savedlogPath = path.join(__dirname, "..", "tempFiles", "savedlog.log"),
16
- journalLogRegExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ [\w\d\.\-]+\[\d+]:/g,
17
- pmLogRegExp = /\d*-\d*-\d*T\d*:\d*:\d*.\d*Z \[\d*.\d*\] \w*.\w* \w*/g,
18
- savedFileExp = /\d+_\d+.log/g,
19
- testAppId = "com.logtest.web.app",
20
- testAppFileName = "com.logtest.web.app_1.0.0_all.ipk",
21
- testAppPath = path.join(__dirname, "..", "tempFiles", testAppFileName);
22
-
23
- let cmd,
24
- options,
25
- hasSession = false,
26
- targetLogDaemon;
27
-
28
- beforeAll(function(done) {
29
- cmd = common.makeCmd(aresCmd);
30
- common.removeOutDir(savedlogPath);
31
- common.getOptions()
32
- .then(function(result) {
33
- options = result;
34
- done();
35
- });
36
- });
37
-
38
- afterAll(function(done) {
39
- common.removeOutDir(savedlogPath);
40
- done();
41
- });
42
-
43
- describe(aresCmd + " -h -v", function() {
44
- it("Print help message with verbose log", function(done) {
45
- if (options.profile === "tv") {
46
- pending(options.skipTxt);
47
- }
48
- exec(cmd + " -h -v", function(error, stdout, stderr) {
49
- if (stderr && stderr.length > 0) {
50
- common.detectNodeMessage(stderr);
51
- expect(stderr).toContain("verb argv");
52
- }
53
- expect(stdout).toContain("SYNOPSIS");
54
- expect(error).toBeNull();
55
- done();
56
- });
57
- });
58
- });
59
-
60
- describe(aresCmd, function() {
61
- it("Add device with ares-setup-device", function(done) {
62
- if (options.profile === "tv") {
63
- pending(options.skipTxt);
64
- }
65
- common.resetDeviceList()
66
- .then(function() {
67
- return common.addDeviceInfo();
68
- }).then(function(result) {
69
- expect(result).toContain(options.device);
70
- done();
71
- }).catch(function(err) {
72
- expect(err).toContain("The specified value already exist");
73
- done();
74
- });
75
- });
76
- });
77
-
78
- describe(aresCmd + " --device-list(-D)", function() {
79
- it("Show available device list", function(done) {
80
- if (options.profile === "tv") {
81
- pending(options.skipTxt);
82
- }
83
- exec(cmd + " -D", function(error, stdout, stderr) {
84
- if (stderr && stderr.length > 0) {
85
- common.detectNodeMessage(stderr);
86
- }
87
- expect(stdout).toContain(options.device);
88
- expect(stdout).toContain(options.profile);
89
- done();
90
- });
91
- });
92
- });
93
-
94
- describe(aresCmd + " -cd", function() {
95
- it("Print current logging daemon", function(done) {
96
- if (options.profile === "tv") {
97
- pending(options.skipTxt);
98
- }
99
- exec(cmd + " -cd", function(error, stdout, stderr) {
100
- if (stderr && stderr.length > 0) {
101
- common.detectNodeMessage(stderr);
102
- }
103
- expect(stdout).toContain(`CLI's current logging daemon :`);
104
-
105
- const splitedStr = stdout.split(":");
106
- targetLogDaemon = splitedStr[splitedStr.length - 1].trim();
107
-
108
- if (!stdout.includes("The target's current logging daemon")) {
109
- targetLogDaemon = targetLogDaemon === "journald" ? "pmlogd" : "journald";
110
- }
111
- done();
112
- });
113
- });
114
- });
115
-
116
- describe(aresCmd + " -sd", function() {
117
- it("Print switch logging daemon", function(done) {
118
- if (options.profile === "tv") {
119
- pending(options.skipTxt);
120
- }
121
- exec(cmd + ` -sd ${targetLogDaemon}`, function(error, stdout, stderr) {
122
- if (stderr && stderr.length > 0) {
123
- common.detectNodeMessage(stderr);
124
- }
125
- expect(stdout).toContain(`CLI's current logging daemon : ${targetLogDaemon}`);
126
- done();
127
- });
128
- });
129
- });
130
-
131
- describe('Set and check configuration for this test', function() {
132
- it('Check if there are sessions on the device', function(done) {
133
- if (options.profile === "tv") {
134
- pending(options.skipTxt);
135
- }
136
- const deviceCmd = common.makeCmd('ares-device');
137
- exec(deviceCmd + ` -s ${options.device}`, function(error, stdout, stderr) {
138
- if (stderr && stderr.length > 0) {
139
- common.detectNodeMessage(stderr);
140
- }
141
-
142
- if (stdout.includes("sessionId")) {
143
- hasSession = true;
144
- }
145
- done();
146
- });
147
- });
148
-
149
- it("Install sample app to device with ares-install", function(done) {
150
- if (options.profile === "tv") {
151
- pending(options.skipTxt);
152
- }
153
- const installCmd = common.makeCmd("ares-install");
154
- exec(installCmd + ` ${testAppPath}`, function(error, stdout, stderr) {
155
- if (stderr && stderr.length > 0) {
156
- common.detectNodeMessage(stderr);
157
- } else {
158
- expect(stdout).toContain("Success", stderr);
159
- }
160
- done();
161
- });
162
- });
163
- });
164
-
165
- describe(aresCmd + " -n 2", function() {
166
- it('Show log with --lines option', function(done) {
167
- if (options.profile === "tv") {
168
- pending(options.skipTxt);
169
- }
170
- exec(cmd + " -n 2", function(error, stdout, stderr) {
171
- if (stderr && stderr.length > 0) {
172
- common.detectNodeMessage(stderr);
173
- if (options.device === "emulator") {
174
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
175
- }
176
- } else if (targetLogDaemon === "journald") {
177
- expect(stdout).not.toContain("[Info] Set target device : " + options.device);
178
- expect(stdout.match(journalLogRegExp).length).toBe(2);
179
- } else if (targetLogDaemon === "pmlogd") {
180
- expect(stdout).not.toContain("[Info] Set target device : " + options.device);
181
- expect(stdout.match(pmLogRegExp).length).toBe(2);
182
- }
183
- done();
184
- });
185
- });
186
- });
187
-
188
- describe(aresCmd + "save option cases", function() {
189
- it("Save log to specific name file", function(done) {
190
- if (options.profile === "tv") {
191
- pending(options.skipTxt);
192
- }
193
- exec(cmd + ` -n 2 -s ${savedlogPath}`, function(error, stdout, stderr) {
194
- if (stderr && stderr.length > 0) {
195
- common.detectNodeMessage(stderr);
196
- if (options.device === "emulator") {
197
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
198
- }
199
- } else {
200
- expect(fs.existsSync(savedlogPath)).toBe(true);
201
- expect(stdout).toContain("Created");
202
- }
203
- done();
204
- });
205
- });
206
-
207
- it("Save log to default file name format", function(done) {
208
- if (options.profile === "tv") {
209
- pending(options.skipTxt);
210
- }
211
- exec(cmd + ` -n 2 -s`, function(error, stdout, stderr) {
212
- if (stderr && stderr.length > 0) {
213
- common.detectNodeMessage(stderr);
214
- if (options.device === "emulator") {
215
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
216
- }
217
- } else {
218
- const generatedFile = path.join(path.resolve('.'), stdout.match(savedFileExp)[0]);
219
- expect(fs.existsSync(generatedFile)).toBe(true);
220
- expect(stdout).toContain("Created");
221
- common.removeOutDir(generatedFile);
222
- }
223
- done();
224
- });
225
- });
226
- });
227
-
228
- describe(aresCmd + " -cl", function() {
229
- it("Launch sample App", function(done) {
230
- if (options.profile === "tv") {
231
- pending(options.skipTxt);
232
- }
233
- if (targetLogDaemon === "journald") {
234
- pending("In case of pmlogd, skip this test case");
235
- }
236
- const launchCmd = common.makeCmd("ares-launch");
237
- exec(launchCmd + ` ${testAppId}`, function(error, stdout, stderr) {
238
- if (stderr && stderr.length > 0) {
239
- common.detectNodeMessage(stderr);
240
- } else {
241
- expect(stdout).toContain(`Launched application ${testAppId}`, error);
242
- }
243
- setTimeout(function() {
244
- done();
245
- }, 1000);
246
- });
247
- });
248
-
249
- it("Print context list", function(done) {
250
- if (options.profile === "tv") {
251
- pending(options.skipTxt);
252
- }
253
- if (targetLogDaemon === "journald") {
254
- pending("In case of journald, skip this test case");
255
- }
256
- exec(cmd + " -cl", function(error, stdout, stderr) {
257
- if (stderr && stderr.length > 0) {
258
- common.detectNodeMessage(stderr);
259
- if (options.device === "emulator") {
260
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
261
- }
262
- } else {
263
- expect(stdout).toContain(`${testAppId} = `);
264
- }
265
- done();
266
- });
267
- });
268
- });
269
-
270
- describe(aresCmd + ` -id ${testAppId}`, function() {
271
- it(`Show logs from ${testAppId}`, function(done) {
272
- if (options.profile === "tv") {
273
- pending(options.skipTxt);
274
- }
275
- if (targetLogDaemon === "journald") {
276
- pending("In case of journald, skip this test case");
277
- }
278
- exec(cmd + `-id ${testAppId}`, function(error, stdout, stderr) {
279
- if (stderr && stderr.length > 0) {
280
- common.detectNodeMessage(stderr);
281
- if (options.device === "emulator") {
282
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
283
- }
284
- } else {
285
- expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
286
- }
287
- done();
288
- });
289
- });
290
- });
291
-
292
- describe(aresCmd + ` -sl ${testAppId} debug`, function() {
293
- it("Change specific context log level", function(done) {
294
- if (options.profile === "tv") {
295
- pending(options.skipTxt);
296
- }
297
- if (targetLogDaemon === "journald") {
298
- pending("In case of journald, skip this test case");
299
- }
300
- exec(cmd + ` -sl ${testAppId} debug`, function(error, stdout, stderr) {
301
- if (stderr && stderr.length > 0) {
302
- common.detectNodeMessage(stderr);
303
- if (options.device === "emulator") {
304
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
305
- }
306
- } else {
307
- expect(stdout).toContain(`Setting context level for \'${testAppId}\'`);
308
- }
309
- done();
310
- });
311
- });
312
-
313
- it("Print context list", function(done) {
314
- if (options.profile === "tv") {
315
- pending(options.skipTxt);
316
- }
317
- if (targetLogDaemon === "journald") {
318
- pending("In case of journald, skip this test case");
319
- }
320
- exec(cmd + " -cl", function(error, stdout, stderr) {
321
- if (stderr && stderr.length > 0) {
322
- common.detectNodeMessage(stderr);
323
- if (options.device === "emulator") {
324
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
325
- }
326
- } else {
327
- expect(stdout).toContain(`${testAppId} = debug`);
328
- }
329
- done();
330
- });
331
- });
332
- });
333
-
334
- describe(aresCmd + " -fl", function() {
335
- it("Print .journal log file list", function(done) {
336
- if (options.profile === "tv") {
337
- pending(options.skipTxt);
338
- }
339
- if (targetLogDaemon === "pmlogd") {
340
- pending("In case of pmlogd, skip this test case");
341
- }
342
- exec(cmd + " -fl", function(error, stdout, stderr) {
343
- if (stderr && stderr.length > 0) {
344
- common.detectNodeMessage(stderr);
345
- if (options.device === "emulator") {
346
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
347
- }
348
- } else {
349
- expect(stdout).toContain("system.journal");
350
- }
351
- done();
352
- });
353
- });
354
- });
355
-
356
- describe(aresCmd + " --file", function() {
357
- it("Show log with --file option", function(done) {
358
- if (options.profile === "tv") {
359
- pending(options.skipTxt);
360
- }
361
- if (targetLogDaemon === "pmlogd") {
362
- pending("In case of pmlogd, skip this test case");
363
- }
364
- exec(cmd + " --file system.journal", function(error, stdout, stderr) {
365
- if (stderr && stderr.length > 0) {
366
- common.detectNodeMessage(stderr);
367
- if (options.device === "emulator") {
368
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
369
- }
370
- } else {
371
- expect(stdout.match(journalLogRegExp).length > 0).toBeTrue();
372
- }
373
- done();
374
- });
375
- });
376
-
377
- it("Show log with --file and --output option", function(done) {
378
- if (options.profile === "tv") {
379
- pending(options.skipTxt);
380
- }
381
- if (targetLogDaemon === "pmlogd") {
382
- pending("In case of pmlogd, skip this test case");
383
- }
384
- exec(cmd + " --file system.journal --output json", function(error, stdout, stderr) {
385
- if (stderr && stderr.length > 0) {
386
- common.detectNodeMessage(stderr);
387
- if (options.device === "emulator") {
388
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
389
- }
390
- } else {
391
- expect(typeof JSON.parse(stdout.split("\n")[0])).toBe('object');
392
- }
393
- done();
394
- });
395
- });
396
- });
397
-
398
- describe(aresCmd + " -ul", function() {
399
- it("Print unit list", function(done) {
400
- if (options.profile === "tv") {
401
- pending(options.skipTxt);
402
- }
403
- if (targetLogDaemon === "pmlogd") {
404
- pending("In case of pmlogd, skip this test case");
405
- }
406
- exec(cmd + " -ul", function(error, stdout, stderr) {
407
- if (stderr && stderr.length > 0) {
408
- common.detectNodeMessage(stderr);
409
- if (options.device === "emulator") {
410
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
411
- }
412
- } else {
413
- expect(stdout).toContain("bootd.service");
414
- }
415
- done();
416
- });
417
- });
418
- });
419
-
420
- describe(aresCmd + " -ul -dp 1", function() {
421
- it("Print unit list with dp option", function(done) {
422
- if (options.profile === "tv") {
423
- pending(options.skipTxt);
424
- }
425
- if (targetLogDaemon === "pmlogd") {
426
- pending("In case of pmlogd, skip this test case");
427
- }
428
- exec(cmd + " -ul -dp 1", function(error, stdout, stderr) {
429
- if (stderr && stderr.length > 0) {
430
- common.detectNodeMessage(stderr);
431
- if (options.device === "emulator") {
432
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
433
- } else if (options.device !== "emulator" && !hasSession) {
434
- expect(stderr).toContain("ares-log ERR! [Tips]: This device does not support multiple sessions");
435
- }
436
- } else {
437
- expect(stdout).toContain("sam.service");
438
- }
439
- done();
440
- });
441
- });
442
- });
443
-
444
- describe(aresCmd + " -n 1 -o json", function() {
445
- it("Show log with output option", function(done) {
446
- if (options.profile === "tv") {
447
- pending(options.skipTxt);
448
- }
449
- if (targetLogDaemon === "pmlogd") {
450
- pending("In case of pmlogd, skip this test case");
451
- }
452
- exec(cmd + " -n 1 -o json", function(error, stdout, stderr) {
453
- if (stderr && stderr.length > 0) {
454
- common.detectNodeMessage(stderr);
455
- if (options.device === "emulator") {
456
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
457
- }
458
- } else {
459
- expect(typeof JSON.parse(stdout)).toBe('object');
460
- }
461
- done();
462
- });
463
- });
464
- });
465
-
466
- describe(aresCmd + " -k", function() {
467
- it("Show kenel log with --kernel option", function(done) {
468
- if (options.profile === "tv") {
469
- pending(options.skipTxt);
470
- }
471
- if (targetLogDaemon === "pmlogd") {
472
- pending("In case of pmlogd, skip this test case");
473
- }
474
- exec(cmd + " -k", function(error, stdout, stderr) {
475
- if (stderr && stderr.length > 0) {
476
- common.detectNodeMessage(stderr);
477
- if (options.device === "emulator") {
478
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
479
- }
480
- } else {
481
- expect(stdout).toContain("kernel:");
482
- }
483
- done();
484
- });
485
- });
486
- });
487
-
488
- describe(aresCmd + " -b", function() {
489
- it("Show boot log with --boot option", function(done) {
490
- if (options.profile === "tv") {
491
- pending(options.skipTxt);
492
- }
493
- if (targetLogDaemon === "pmlogd") {
494
- pending("In case of pmlogd, skip this test case");
495
- }
496
- exec(cmd + " -b", function(error, stdout, stderr) {
497
- if (stderr && stderr.length > 0) {
498
- common.detectNodeMessage(stderr);
499
- if (options.device === "emulator") {
500
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
501
- }
502
- } else {
503
- expect(stdout.length).not.toBe(0);
504
- }
505
- done();
506
- });
507
- });
508
- });
509
-
510
- describe(aresCmd + " --pid", function() {
511
- let pid;
512
- it("Get a pid from log", function(done) {
513
- if (options.profile === "tv") {
514
- pending(options.skipTxt);
515
- }
516
- if (targetLogDaemon === "pmlogd") {
517
- pending("In case of pmlogd, skip this test case");
518
- }
519
- const pidExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ [\w\d\.\-]+\[(\d+)]:/;
520
- exec(cmd + " -n 1", function(error, stdout, stderr) {
521
- if (stderr && stderr.length > 0) {
522
- common.detectNodeMessage(stderr);
523
- if (options.device === "emulator") {
524
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
525
- }
526
- } else {
527
- expect(stdout.match(pidExp).length > 0).toBeTrue();
528
- pid = stdout.match(pidExp)[1];
529
- }
530
- done();
531
- });
532
- });
533
- it("Show log with --pid option", function(done) {
534
- if (options.profile === "tv") {
535
- pending(options.skipTxt);
536
- }
537
- if (targetLogDaemon === "pmlogd") {
538
- pending("In case of pmlogd, skip this test case");
539
- }
540
- exec(cmd + ` --pid ${pid} -n 3`, function(error, stdout, stderr) {
541
- const expectedPid = `[${pid}]`;
542
- if (stderr && stderr.length > 0) {
543
- common.detectNodeMessage(stderr);
544
- if (options.device === "emulator") {
545
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
546
- }
547
- } else {
548
- expect(stdout.match(expectedPid).length > 0).toBeTrue();
549
- }
550
- done();
551
- });
552
- });
553
- });
554
-
555
- describe(aresCmd + " --unit memorymanager", function() {
556
- it("Launch sample App", function(done) {
557
- if (options.profile === "tv") {
558
- pending(options.skipTxt);
559
- }
560
- if (targetLogDaemon === "pmlogd") {
561
- pending("In case of pmlogd, skip this test case");
562
- }
563
- const launchCmd = common.makeCmd("ares-launch");
564
- exec(launchCmd + ` ${testAppId}`, function(error, stdout, stderr) {
565
- if (stderr && stderr.length > 0) {
566
- common.detectNodeMessage(stderr);
567
- } else {
568
- expect(stdout).toContain(`Launched application ${testAppId}`, error);
569
- }
570
- setTimeout(function() {
571
- done();
572
- }, 1000);
573
- });
574
- });
575
-
576
- it("Show log with --unit option", function(done) {
577
- if (options.profile === "tv") {
578
- pending(options.skipTxt);
579
- }
580
- if (targetLogDaemon === "pmlogd") {
581
- pending("In case of pmlogd, skip this test case");
582
- }
583
- exec(cmd + " --unit memorymanager", function(error, stdout, stderr) {
584
- if (stderr && stderr.length > 0) {
585
- common.detectNodeMessage(stderr);
586
- if (options.device === "emulator") {
587
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
588
- }
589
- } else {
590
- const unitExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ memorymanager/g;
591
- expect(stdout.match(unitExp).length > 0).toBeTrue();
592
- }
593
- done();
594
- });
595
- });
596
- });
597
-
598
- describe(aresCmd +" -u sam -dp 1", function() {
599
- it("Show log with unit and dp option", function(done) {
600
- if (options.profile === "tv") {
601
- pending(options.skipTxt);
602
- }
603
- if (targetLogDaemon === "pmlogd") {
604
- pending("In case of pmlogd, skip this test case");
605
- }
606
- exec(cmd + " -u sam -dp 1", function(error, stdout, stderr) {
607
- if (stderr && stderr.length > 0) {
608
- common.detectNodeMessage(stderr);
609
- if (options.device === "emulator") {
610
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
611
- } else if (options.device !== "emulator" && !hasSession) {
612
- expect(stderr).toContain("ares-log ERR! [Tips]: This device does not support multiple sessions");
613
- }
614
- } else {
615
- const unitExp = /\w+ \d+ \d\d:\d\d:\d\d [\w|\d]+ sam/g;
616
- expect(stdout.match(unitExp).length > 0).toBeTrue();
617
- }
618
- done();
619
- });
620
- });
621
- });
622
-
623
- describe(aresCmd + " -S today", function() {
624
- it("Show log with --since option", function(done) {
625
- if (options.profile === "tv") {
626
- pending(options.skipTxt);
627
- }
628
- if (targetLogDaemon === "pmlogd") {
629
- pending("In case of pmlogd, skip this test case");
630
- }
631
- exec(cmd + " -S today", function(error, stdout, stderr) {
632
- if (stderr && stderr.length > 0) {
633
- common.detectNodeMessage(stderr);
634
- if (options.device === "emulator") {
635
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
636
- }
637
- } else {
638
- expect(stdout.length).not.toBe(0);
639
- }
640
- done();
641
- });
642
- });
643
- });
644
-
645
- describe(aresCmd + " -U yesterday", function() {
646
- it("Show log with --until option", function(done) {
647
- if (options.profile === "tv") {
648
- pending(options.skipTxt);
649
- }
650
- if (targetLogDaemon === "pmlogd") {
651
- pending("In case of pmlogd, skip this test case");
652
- }
653
- exec(cmd + " -U yesterday", function(error, stdout, stderr) {
654
- if (stderr && stderr.length > 0) {
655
- common.detectNodeMessage(stderr);
656
- if (options.device === "emulator") {
657
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
658
- }
659
- } else {
660
- expect(stdout.length).not.toBe(0);
661
- }
662
- done();
663
- });
664
- });
665
- });
666
-
667
- describe(aresCmd + " negative tc", function() {
668
- it("Not support option", function(done) {
669
- if (options.profile === "tv") {
670
- pending(options.skipTxt);
671
- }
672
- exec(cmd + " -aaa", function(error, stdout, stderr) {
673
- if (stderr && stderr.length > 0) {
674
- common.detectNodeMessage(stderr);
675
- expect(stderr).toContain(`ares-log ERR! [Tips]: ${targetLogDaemon} does not support the option <aaa>`);
676
- }
677
- done();
678
- });
679
- });
680
-
681
- it("Invalid save path", function(done) {
682
- if (options.profile === "tv") {
683
- pending(options.skipTxt);
684
- }
685
- exec(cmd + ` -n 2 -s invalid/aaa.log`, function(error, stdout, stderr) {
686
- if (stderr && stderr.length > 0) {
687
- common.detectNodeMessage(stderr);
688
- if (options.device === "emulator") {
689
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
690
- } else {
691
- expect(stderr).toContain("ares-log ERR! [syscall failure]: ENOENT: no such file or directory");
692
- expect(stderr).toContain("ares-log ERR! [Tips]: Please check if the path is valid");
693
- }
694
- }
695
- done();
696
- });
697
- });
698
-
699
- it("Not exist id value", function(done) {
700
- if (options.profile === "tv") {
701
- pending(options.skipTxt);
702
- }
703
- if (targetLogDaemon === "journald") {
704
- pending("In case of journald, skip this test case");
705
- }
706
- exec(cmd + ` -id`, function(error, stdout, stderr) {
707
- if (stderr && stderr.length > 0) {
708
- common.detectNodeMessage(stderr);
709
- if (options.device === "emulator") {
710
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
711
- } else {
712
- expect(stderr).toContain("ares-log ERR! [Tips]: Please specify a value <id-filter>");
713
- }
714
- } else {
715
- expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
716
- }
717
- done();
718
- });
719
- });
720
-
721
- it("Not exist filtered logs by id", function(done) {
722
- if (options.profile === "tv") {
723
- pending(options.skipTxt);
724
- }
725
- if (targetLogDaemon === "journald") {
726
- pending("In case of journald, skip this test case");
727
- }
728
- exec(cmd + ` -id com.domain.app`, function(error, stdout, stderr) {
729
- if (stderr && stderr.length > 0) {
730
- common.detectNodeMessage(stderr);
731
- if (options.device === "emulator") {
732
- expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
733
- } else {
734
- expect(stderr).toContain("ares-log ERR! [Tips]: There are no logs from the ID");
735
- expect(stderr).toContain("ares-log ERR! [Tips]: Please check if the combination of options or the ID are valid");
736
- }
737
- } else {
738
- expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
739
- }
740
- done();
741
- });
742
- });
743
- });
744
-
745
- describe(aresCmd + " -f", function() {
746
- it("Show log with --follow option", function(done) {
747
- if (options.profile === "tv") {
748
- pending(options.skipTxt);
749
- }
750
- const child = exec(cmd + " -f");
751
- let result = "";
752
-
753
- child.stdout.on("data", function(data) {
754
- result += data;
755
- });
756
-
757
- child.stderr.on("data", function(data) {
758
- if (data && data.length > 0) {
759
- common.detectNodeMessage(data);
760
- }
761
- result += data;
762
- });
763
-
764
- setTimeout(() => {
765
- child.kill();
766
- if (options.device === "emulator") {
767
- expect(result).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
768
- } else if (targetLogDaemon === "journald") {
769
- expect(result.match(journalLogRegExp).length > 0).toBeTrue();
770
- } else if (targetLogDaemon === "pmlogd") {
771
- expect(result.match(pmLogRegExp).length > 0).toBeTrue();
772
- }
773
- done();
774
- }, 1000);
775
- });
776
- });
777
-
778
- describe(aresCmd + " -r", function() {
779
- it("Show log with --reverse option", function(done) {
780
- if (options.profile === "tv") {
781
- pending(options.skipTxt);
782
- }
783
- const child = exec(cmd + " -r");
784
- let result = "";
785
-
786
- child.stdout.on('data', function(data) {
787
- result += data;
788
- });
789
-
790
- child.stderr.on('data', function(data) {
791
- if (data && data.length > 0) {
792
- common.detectNodeMessage(data);
793
- }
794
- result += data;
795
- });
796
-
797
- setTimeout(() => {
798
- child.kill();
799
- if (options.device === "emulator") {
800
- expect(result).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
801
- } else if (targetLogDaemon === "journald") {
802
- expect(result.match(journalLogRegExp).length > 0).toBeTrue();
803
- }
804
- done();
805
- }, 1000);
806
- });
807
- });
808
-
809
- describe('Set default configuration', function() {
810
- it("Install sample app to device with ares-install", function(done) {
811
- if (options.profile === "tv") {
812
- pending(options.skipTxt);
813
- }
814
- const installCmd = common.makeCmd("ares-install");
815
- exec(installCmd + ` -r ${testAppPath}`, function(error, stdout, stderr) {
816
- if (stderr && stderr.length > 0) {
817
- common.detectNodeMessage(stderr);
818
- } else {
819
- expect(stdout).toContain(`Removed package ${testAppId}`, stderr);
820
- }
821
- done();
822
- });
823
- });
824
- });
1
+ /*
2
+ * Copyright (c) 2021-2024 LG Electronics Inc.
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ /* eslint-disable no-useless-escape */
8
+
9
+ const exec = require('child_process').exec,
10
+ path = require('path'),
11
+ fs = require('fs'),
12
+ common = require('./common-spec');
13
+
14
+ const aresCmd = 'ares-log',
15
+ savedlogPath = path.join(__dirname, "..", "tempFiles", "savedlog.log"),
16
+ journalLogRegExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ [\w\d\.\-]+\[\d+]:/g,
17
+ pmLogRegExp = /\d*-\d*-\d*T\d*:\d*:\d*.\d*Z \[\d*.\d*\] \w*.\w* \w*/g,
18
+ savedFileExp = /\d+_\d+.log/g,
19
+ testAppId = "com.logtest.web.app",
20
+ testAppFileName = "com.logtest.web.app_1.0.0_all.ipk",
21
+ testAppPath = path.join(__dirname, "..", "tempFiles", testAppFileName);
22
+
23
+ let cmd,
24
+ options,
25
+ hasSession = false,
26
+ targetLogDaemon;
27
+
28
+ beforeAll(function(done) {
29
+ cmd = common.makeCmd(aresCmd);
30
+ common.removeOutDir(savedlogPath);
31
+ common.getOptions()
32
+ .then(function(result) {
33
+ options = result;
34
+ done();
35
+ });
36
+ });
37
+
38
+ afterAll(function(done) {
39
+ common.removeOutDir(savedlogPath);
40
+ done();
41
+ });
42
+
43
+ describe(aresCmd + " -h -v", function() {
44
+ it("Print help message with verbose log", function(done) {
45
+ if (options.profile === "tv") {
46
+ pending(options.skipTxt);
47
+ }
48
+ exec(cmd + " -h -v", function(error, stdout, stderr) {
49
+ if (stderr && stderr.length > 0) {
50
+ common.detectNodeMessage(stderr);
51
+ expect(stderr).toContain("verb argv");
52
+ }
53
+ expect(stdout).toContain("SYNOPSIS");
54
+ expect(error).toBeNull();
55
+ done();
56
+ });
57
+ });
58
+ });
59
+
60
+ describe(aresCmd, function() {
61
+ it("Add device with ares-setup-device", function(done) {
62
+ if (options.profile === "tv") {
63
+ pending(options.skipTxt);
64
+ }
65
+ common.resetDeviceList()
66
+ .then(function() {
67
+ return common.addDeviceInfo();
68
+ }).then(function(result) {
69
+ expect(result).toContain(options.device);
70
+ done();
71
+ }).catch(function(err) {
72
+ expect(err).toContain("The specified value already exist");
73
+ done();
74
+ });
75
+ });
76
+ });
77
+
78
+ describe(aresCmd + " --device-list(-D)", function() {
79
+ it("Show available device list", function(done) {
80
+ if (options.profile === "tv") {
81
+ pending(options.skipTxt);
82
+ }
83
+ exec(cmd + " -D", function(error, stdout, stderr) {
84
+ if (stderr && stderr.length > 0) {
85
+ common.detectNodeMessage(stderr);
86
+ }
87
+ expect(stdout).toContain(options.device);
88
+ expect(stdout).toContain(options.profile);
89
+ done();
90
+ });
91
+ });
92
+ });
93
+
94
+ describe(aresCmd + " -cd", function() {
95
+ it("Print current logging daemon", function(done) {
96
+ if (options.profile === "tv") {
97
+ pending(options.skipTxt);
98
+ }
99
+ exec(cmd + " -cd", function(error, stdout, stderr) {
100
+ if (stderr && stderr.length > 0) {
101
+ common.detectNodeMessage(stderr);
102
+ }
103
+ expect(stdout).toContain(`CLI's current logging daemon :`);
104
+
105
+ const splitedStr = stdout.split(":");
106
+ targetLogDaemon = splitedStr[splitedStr.length - 1].trim();
107
+
108
+ if (!stdout.includes("The target's current logging daemon")) {
109
+ targetLogDaemon = targetLogDaemon === "journald" ? "pmlogd" : "journald";
110
+ }
111
+ done();
112
+ });
113
+ });
114
+ });
115
+
116
+ describe(aresCmd + " -sd", function() {
117
+ it("Print switch logging daemon", function(done) {
118
+ if (options.profile === "tv") {
119
+ pending(options.skipTxt);
120
+ }
121
+ exec(cmd + ` -sd ${targetLogDaemon}`, function(error, stdout, stderr) {
122
+ if (stderr && stderr.length > 0) {
123
+ common.detectNodeMessage(stderr);
124
+ }
125
+ expect(stdout).toContain(`CLI's current logging daemon : ${targetLogDaemon}`);
126
+ done();
127
+ });
128
+ });
129
+ });
130
+
131
+ describe('Set and check configuration for this test', function() {
132
+ it('Check if there are sessions on the device', function(done) {
133
+ if (options.profile === "tv") {
134
+ pending(options.skipTxt);
135
+ }
136
+ const deviceCmd = common.makeCmd('ares-device');
137
+ exec(deviceCmd + ` -s ${options.device}`, function(error, stdout, stderr) {
138
+ if (stderr && stderr.length > 0) {
139
+ common.detectNodeMessage(stderr);
140
+ }
141
+
142
+ if (stdout.includes("sessionId")) {
143
+ hasSession = true;
144
+ }
145
+ done();
146
+ });
147
+ });
148
+
149
+ it("Install sample app to device with ares-install", function(done) {
150
+ if (options.profile === "tv") {
151
+ pending(options.skipTxt);
152
+ }
153
+ const installCmd = common.makeCmd("ares-install");
154
+ exec(installCmd + ` ${testAppPath}`, function(error, stdout, stderr) {
155
+ if (stderr && stderr.length > 0) {
156
+ common.detectNodeMessage(stderr);
157
+ } else {
158
+ expect(stdout).toContain("Success", stderr);
159
+ }
160
+ done();
161
+ });
162
+ });
163
+ });
164
+
165
+ describe(aresCmd + " -n 2", function() {
166
+ it('Show log with --lines option', function(done) {
167
+ if (options.profile === "tv") {
168
+ pending(options.skipTxt);
169
+ }
170
+ exec(cmd + " -n 2", function(error, stdout, stderr) {
171
+ if (stderr && stderr.length > 0) {
172
+ common.detectNodeMessage(stderr);
173
+ if (options.device === "emulator") {
174
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
175
+ }
176
+ } else if (targetLogDaemon === "journald") {
177
+ expect(stdout).not.toContain("[Info] Set target device : " + options.device);
178
+ expect(stdout.match(journalLogRegExp).length).toBe(2);
179
+ } else if (targetLogDaemon === "pmlogd") {
180
+ expect(stdout).not.toContain("[Info] Set target device : " + options.device);
181
+ expect(stdout.match(pmLogRegExp).length).toBe(2);
182
+ }
183
+ done();
184
+ });
185
+ });
186
+ });
187
+
188
+ describe(aresCmd + "save option cases", function() {
189
+ it("Save log to specific name file", function(done) {
190
+ if (options.profile === "tv") {
191
+ pending(options.skipTxt);
192
+ }
193
+ exec(cmd + ` -n 2 -s ${savedlogPath}`, function(error, stdout, stderr) {
194
+ if (stderr && stderr.length > 0) {
195
+ common.detectNodeMessage(stderr);
196
+ if (options.device === "emulator") {
197
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
198
+ }
199
+ } else {
200
+ expect(fs.existsSync(savedlogPath)).toBe(true);
201
+ expect(stdout).toContain("Created");
202
+ }
203
+ done();
204
+ });
205
+ });
206
+
207
+ it("Save log to default file name format", function(done) {
208
+ if (options.profile === "tv") {
209
+ pending(options.skipTxt);
210
+ }
211
+ exec(cmd + ` -n 2 -s`, function(error, stdout, stderr) {
212
+ if (stderr && stderr.length > 0) {
213
+ common.detectNodeMessage(stderr);
214
+ if (options.device === "emulator") {
215
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
216
+ }
217
+ } else {
218
+ const generatedFile = path.join(path.resolve('.'), stdout.match(savedFileExp)[0]);
219
+ expect(fs.existsSync(generatedFile)).toBe(true);
220
+ expect(stdout).toContain("Created");
221
+ common.removeOutDir(generatedFile);
222
+ }
223
+ done();
224
+ });
225
+ });
226
+ });
227
+
228
+ describe(aresCmd + " -cl", function() {
229
+ it("Launch sample App", function(done) {
230
+ if (options.profile === "tv") {
231
+ pending(options.skipTxt);
232
+ }
233
+ if (targetLogDaemon === "journald") {
234
+ pending("In case of pmlogd, skip this test case");
235
+ }
236
+ const launchCmd = common.makeCmd("ares-launch");
237
+ exec(launchCmd + ` ${testAppId}`, function(error, stdout, stderr) {
238
+ if (stderr && stderr.length > 0) {
239
+ common.detectNodeMessage(stderr);
240
+ } else {
241
+ expect(stdout).toContain(`Launched application ${testAppId}`, error);
242
+ }
243
+ setTimeout(function() {
244
+ done();
245
+ }, 1000);
246
+ });
247
+ });
248
+
249
+ it("Print context list", function(done) {
250
+ if (options.profile === "tv") {
251
+ pending(options.skipTxt);
252
+ }
253
+ if (targetLogDaemon === "journald") {
254
+ pending("In case of journald, skip this test case");
255
+ }
256
+ exec(cmd + " -cl", function(error, stdout, stderr) {
257
+ if (stderr && stderr.length > 0) {
258
+ common.detectNodeMessage(stderr);
259
+ if (options.device === "emulator") {
260
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
261
+ }
262
+ } else {
263
+ expect(stdout).toContain(`${testAppId} = `);
264
+ }
265
+ done();
266
+ });
267
+ });
268
+ });
269
+
270
+ describe(aresCmd + ` -id ${testAppId}`, function() {
271
+ it(`Show logs from ${testAppId}`, function(done) {
272
+ if (options.profile === "tv") {
273
+ pending(options.skipTxt);
274
+ }
275
+ if (targetLogDaemon === "journald") {
276
+ pending("In case of journald, skip this test case");
277
+ }
278
+ exec(cmd + `-id ${testAppId}`, function(error, stdout, stderr) {
279
+ if (stderr && stderr.length > 0) {
280
+ common.detectNodeMessage(stderr);
281
+ if (options.device === "emulator") {
282
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
283
+ }
284
+ } else {
285
+ expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
286
+ }
287
+ done();
288
+ });
289
+ });
290
+ });
291
+
292
+ describe(aresCmd + ` -sl ${testAppId} debug`, function() {
293
+ it("Change specific context log level", function(done) {
294
+ if (options.profile === "tv") {
295
+ pending(options.skipTxt);
296
+ }
297
+ if (targetLogDaemon === "journald") {
298
+ pending("In case of journald, skip this test case");
299
+ }
300
+ exec(cmd + ` -sl ${testAppId} debug`, function(error, stdout, stderr) {
301
+ if (stderr && stderr.length > 0) {
302
+ common.detectNodeMessage(stderr);
303
+ if (options.device === "emulator") {
304
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
305
+ }
306
+ } else {
307
+ expect(stdout).toContain(`Setting context level for \'${testAppId}\'`);
308
+ }
309
+ done();
310
+ });
311
+ });
312
+
313
+ it("Print context list", function(done) {
314
+ if (options.profile === "tv") {
315
+ pending(options.skipTxt);
316
+ }
317
+ if (targetLogDaemon === "journald") {
318
+ pending("In case of journald, skip this test case");
319
+ }
320
+ exec(cmd + " -cl", function(error, stdout, stderr) {
321
+ if (stderr && stderr.length > 0) {
322
+ common.detectNodeMessage(stderr);
323
+ if (options.device === "emulator") {
324
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
325
+ }
326
+ } else {
327
+ expect(stdout).toContain(`${testAppId} = debug`);
328
+ }
329
+ done();
330
+ });
331
+ });
332
+ });
333
+
334
+ describe(aresCmd + " -fl", function() {
335
+ it("Print .journal log file list", function(done) {
336
+ if (options.profile === "tv") {
337
+ pending(options.skipTxt);
338
+ }
339
+ if (targetLogDaemon === "pmlogd") {
340
+ pending("In case of pmlogd, skip this test case");
341
+ }
342
+ exec(cmd + " -fl", function(error, stdout, stderr) {
343
+ if (stderr && stderr.length > 0) {
344
+ common.detectNodeMessage(stderr);
345
+ if (options.device === "emulator") {
346
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
347
+ }
348
+ } else {
349
+ expect(stdout).toContain("system.journal");
350
+ }
351
+ done();
352
+ });
353
+ });
354
+ });
355
+
356
+ describe(aresCmd + " --file", function() {
357
+ it("Show log with --file option", function(done) {
358
+ if (options.profile === "tv") {
359
+ pending(options.skipTxt);
360
+ }
361
+ if (targetLogDaemon === "pmlogd") {
362
+ pending("In case of pmlogd, skip this test case");
363
+ }
364
+ exec(cmd + " --file system.journal", function(error, stdout, stderr) {
365
+ if (stderr && stderr.length > 0) {
366
+ common.detectNodeMessage(stderr);
367
+ if (options.device === "emulator") {
368
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
369
+ }
370
+ } else {
371
+ expect(stdout.match(journalLogRegExp).length > 0).toBeTrue();
372
+ }
373
+ done();
374
+ });
375
+ });
376
+
377
+ it("Show log with --file and --output option", function(done) {
378
+ if (options.profile === "tv") {
379
+ pending(options.skipTxt);
380
+ }
381
+ if (targetLogDaemon === "pmlogd") {
382
+ pending("In case of pmlogd, skip this test case");
383
+ }
384
+ exec(cmd + " --file system.journal --output json", function(error, stdout, stderr) {
385
+ if (stderr && stderr.length > 0) {
386
+ common.detectNodeMessage(stderr);
387
+ if (options.device === "emulator") {
388
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
389
+ }
390
+ } else {
391
+ expect(typeof JSON.parse(stdout.split("\n")[0])).toBe('object');
392
+ }
393
+ done();
394
+ });
395
+ });
396
+ });
397
+
398
+ describe(aresCmd + " -ul", function() {
399
+ it("Print unit list", function(done) {
400
+ if (options.profile === "tv") {
401
+ pending(options.skipTxt);
402
+ }
403
+ if (targetLogDaemon === "pmlogd") {
404
+ pending("In case of pmlogd, skip this test case");
405
+ }
406
+ exec(cmd + " -ul", function(error, stdout, stderr) {
407
+ if (stderr && stderr.length > 0) {
408
+ common.detectNodeMessage(stderr);
409
+ if (options.device === "emulator") {
410
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
411
+ }
412
+ } else {
413
+ expect(stdout).toContain("bootd.service");
414
+ }
415
+ done();
416
+ });
417
+ });
418
+ });
419
+
420
+ describe(aresCmd + " -ul -dp 1", function() {
421
+ it("Print unit list with dp option", function(done) {
422
+ if (options.profile === "tv") {
423
+ pending(options.skipTxt);
424
+ }
425
+ if (targetLogDaemon === "pmlogd") {
426
+ pending("In case of pmlogd, skip this test case");
427
+ }
428
+ exec(cmd + " -ul -dp 1", function(error, stdout, stderr) {
429
+ if (stderr && stderr.length > 0) {
430
+ common.detectNodeMessage(stderr);
431
+ if (options.device === "emulator") {
432
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
433
+ } else if (options.device !== "emulator" && !hasSession) {
434
+ expect(stderr).toContain("ares-log ERR! [Tips]: This device does not support multiple sessions");
435
+ }
436
+ } else {
437
+ expect(stdout).toContain("sam.service");
438
+ }
439
+ done();
440
+ });
441
+ });
442
+ });
443
+
444
+ describe(aresCmd + " -n 1 -o json", function() {
445
+ it("Show log with output option", function(done) {
446
+ if (options.profile === "tv") {
447
+ pending(options.skipTxt);
448
+ }
449
+ if (targetLogDaemon === "pmlogd") {
450
+ pending("In case of pmlogd, skip this test case");
451
+ }
452
+ exec(cmd + " -n 1 -o json", function(error, stdout, stderr) {
453
+ if (stderr && stderr.length > 0) {
454
+ common.detectNodeMessage(stderr);
455
+ if (options.device === "emulator") {
456
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
457
+ }
458
+ } else {
459
+ expect(typeof JSON.parse(stdout)).toBe('object');
460
+ }
461
+ done();
462
+ });
463
+ });
464
+ });
465
+
466
+ describe(aresCmd + " -k", function() {
467
+ it("Show kenel log with --kernel option", function(done) {
468
+ if (options.profile === "tv") {
469
+ pending(options.skipTxt);
470
+ }
471
+ if (targetLogDaemon === "pmlogd") {
472
+ pending("In case of pmlogd, skip this test case");
473
+ }
474
+ exec(cmd + " -k", function(error, stdout, stderr) {
475
+ if (stderr && stderr.length > 0) {
476
+ common.detectNodeMessage(stderr);
477
+ if (options.device === "emulator") {
478
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
479
+ }
480
+ } else {
481
+ expect(stdout).toContain("kernel:");
482
+ }
483
+ done();
484
+ });
485
+ });
486
+ });
487
+
488
+ describe(aresCmd + " -b", function() {
489
+ it("Show boot log with --boot option", function(done) {
490
+ if (options.profile === "tv") {
491
+ pending(options.skipTxt);
492
+ }
493
+ if (targetLogDaemon === "pmlogd") {
494
+ pending("In case of pmlogd, skip this test case");
495
+ }
496
+ exec(cmd + " -b", function(error, stdout, stderr) {
497
+ if (stderr && stderr.length > 0) {
498
+ common.detectNodeMessage(stderr);
499
+ if (options.device === "emulator") {
500
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
501
+ }
502
+ } else {
503
+ expect(stdout.length).not.toBe(0);
504
+ }
505
+ done();
506
+ });
507
+ });
508
+ });
509
+
510
+ describe(aresCmd + " --pid", function() {
511
+ let pid;
512
+ it("Get a pid from log", function(done) {
513
+ if (options.profile === "tv") {
514
+ pending(options.skipTxt);
515
+ }
516
+ if (targetLogDaemon === "pmlogd") {
517
+ pending("In case of pmlogd, skip this test case");
518
+ }
519
+ const pidExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ [\w\d\.\-]+\[(\d+)]:/;
520
+ exec(cmd + " -n 1", function(error, stdout, stderr) {
521
+ if (stderr && stderr.length > 0) {
522
+ common.detectNodeMessage(stderr);
523
+ if (options.device === "emulator") {
524
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
525
+ }
526
+ } else {
527
+ expect(stdout.match(pidExp).length > 0).toBeTrue();
528
+ pid = stdout.match(pidExp)[1];
529
+ }
530
+ done();
531
+ });
532
+ });
533
+ it("Show log with --pid option", function(done) {
534
+ if (options.profile === "tv") {
535
+ pending(options.skipTxt);
536
+ }
537
+ if (targetLogDaemon === "pmlogd") {
538
+ pending("In case of pmlogd, skip this test case");
539
+ }
540
+ exec(cmd + ` --pid ${pid} -n 3`, function(error, stdout, stderr) {
541
+ const expectedPid = `[${pid}]`;
542
+ if (stderr && stderr.length > 0) {
543
+ common.detectNodeMessage(stderr);
544
+ if (options.device === "emulator") {
545
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
546
+ }
547
+ } else {
548
+ expect(stdout.match(expectedPid).length > 0).toBeTrue();
549
+ }
550
+ done();
551
+ });
552
+ });
553
+ });
554
+
555
+ describe(aresCmd + " --unit memorymanager", function() {
556
+ it("Launch sample App", function(done) {
557
+ if (options.profile === "tv") {
558
+ pending(options.skipTxt);
559
+ }
560
+ if (targetLogDaemon === "pmlogd") {
561
+ pending("In case of pmlogd, skip this test case");
562
+ }
563
+ const launchCmd = common.makeCmd("ares-launch");
564
+ exec(launchCmd + ` ${testAppId}`, function(error, stdout, stderr) {
565
+ if (stderr && stderr.length > 0) {
566
+ common.detectNodeMessage(stderr);
567
+ } else {
568
+ expect(stdout).toContain(`Launched application ${testAppId}`, error);
569
+ }
570
+ setTimeout(function() {
571
+ done();
572
+ }, 1000);
573
+ });
574
+ });
575
+
576
+ it("Show log with --unit option", function(done) {
577
+ if (options.profile === "tv") {
578
+ pending(options.skipTxt);
579
+ }
580
+ if (targetLogDaemon === "pmlogd") {
581
+ pending("In case of pmlogd, skip this test case");
582
+ }
583
+ exec(cmd + " --unit memorymanager", function(error, stdout, stderr) {
584
+ if (stderr && stderr.length > 0) {
585
+ common.detectNodeMessage(stderr);
586
+ if (options.device === "emulator") {
587
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
588
+ }
589
+ } else {
590
+ const unitExp = /\w+ \d+ \d\d:\d\d:\d\d [\w\d\-]+ memorymanager/g;
591
+ expect(stdout.match(unitExp).length > 0).toBeTrue();
592
+ }
593
+ done();
594
+ });
595
+ });
596
+ });
597
+
598
+ describe(aresCmd +" -u sam -dp 1", function() {
599
+ it("Show log with unit and dp option", function(done) {
600
+ if (options.profile === "tv") {
601
+ pending(options.skipTxt);
602
+ }
603
+ if (targetLogDaemon === "pmlogd") {
604
+ pending("In case of pmlogd, skip this test case");
605
+ }
606
+ exec(cmd + " -u sam -dp 1", function(error, stdout, stderr) {
607
+ if (stderr && stderr.length > 0) {
608
+ common.detectNodeMessage(stderr);
609
+ if (options.device === "emulator") {
610
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
611
+ } else if (options.device !== "emulator" && !hasSession) {
612
+ expect(stderr).toContain("ares-log ERR! [Tips]: This device does not support multiple sessions");
613
+ }
614
+ } else {
615
+ const unitExp = /\w+ \d+ \d\d:\d\d:\d\d [\w|\d]+ sam/g;
616
+ expect(stdout.match(unitExp).length > 0).toBeTrue();
617
+ }
618
+ done();
619
+ });
620
+ });
621
+ });
622
+
623
+ describe(aresCmd + " -S today", function() {
624
+ it("Show log with --since option", function(done) {
625
+ if (options.profile === "tv") {
626
+ pending(options.skipTxt);
627
+ }
628
+ if (targetLogDaemon === "pmlogd") {
629
+ pending("In case of pmlogd, skip this test case");
630
+ }
631
+ exec(cmd + " -S today", function(error, stdout, stderr) {
632
+ if (stderr && stderr.length > 0) {
633
+ common.detectNodeMessage(stderr);
634
+ if (options.device === "emulator") {
635
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
636
+ }
637
+ } else {
638
+ expect(stdout.length).not.toBe(0);
639
+ }
640
+ done();
641
+ });
642
+ });
643
+ });
644
+
645
+ describe(aresCmd + " -U yesterday", function() {
646
+ it("Show log with --until option", function(done) {
647
+ if (options.profile === "tv") {
648
+ pending(options.skipTxt);
649
+ }
650
+ if (targetLogDaemon === "pmlogd") {
651
+ pending("In case of pmlogd, skip this test case");
652
+ }
653
+ exec(cmd + " -U yesterday", function(error, stdout, stderr) {
654
+ if (stderr && stderr.length > 0) {
655
+ common.detectNodeMessage(stderr);
656
+ if (options.device === "emulator") {
657
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
658
+ }
659
+ } else {
660
+ expect(stdout.length).not.toBe(0);
661
+ }
662
+ done();
663
+ });
664
+ });
665
+ });
666
+
667
+ describe(aresCmd + " negative tc", function() {
668
+ it("Not support option", function(done) {
669
+ if (options.profile === "tv") {
670
+ pending(options.skipTxt);
671
+ }
672
+ exec(cmd + " -aaa", function(error, stdout, stderr) {
673
+ if (stderr && stderr.length > 0) {
674
+ common.detectNodeMessage(stderr);
675
+ expect(stderr).toContain(`ares-log ERR! [Tips]: ${targetLogDaemon} does not support the option <aaa>`);
676
+ }
677
+ done();
678
+ });
679
+ });
680
+
681
+ it("Invalid save path", function(done) {
682
+ if (options.profile === "tv") {
683
+ pending(options.skipTxt);
684
+ }
685
+ exec(cmd + ` -n 2 -s invalid/aaa.log`, function(error, stdout, stderr) {
686
+ if (stderr && stderr.length > 0) {
687
+ common.detectNodeMessage(stderr);
688
+ if (options.device === "emulator") {
689
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
690
+ } else {
691
+ expect(stderr).toContain("ares-log ERR! [syscall failure]: ENOENT: no such file or directory");
692
+ expect(stderr).toContain("ares-log ERR! [Tips]: Please check if the path is valid");
693
+ }
694
+ }
695
+ done();
696
+ });
697
+ });
698
+
699
+ it("Not exist id value", function(done) {
700
+ if (options.profile === "tv") {
701
+ pending(options.skipTxt);
702
+ }
703
+ if (targetLogDaemon === "journald") {
704
+ pending("In case of journald, skip this test case");
705
+ }
706
+ exec(cmd + ` -id`, function(error, stdout, stderr) {
707
+ if (stderr && stderr.length > 0) {
708
+ common.detectNodeMessage(stderr);
709
+ if (options.device === "emulator") {
710
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
711
+ } else {
712
+ expect(stderr).toContain("ares-log ERR! [Tips]: Please specify a value <id-filter>");
713
+ }
714
+ } else {
715
+ expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
716
+ }
717
+ done();
718
+ });
719
+ });
720
+
721
+ it("Not exist filtered logs by id", function(done) {
722
+ if (options.profile === "tv") {
723
+ pending(options.skipTxt);
724
+ }
725
+ if (targetLogDaemon === "journald") {
726
+ pending("In case of journald, skip this test case");
727
+ }
728
+ exec(cmd + ` -id com.domain.app`, function(error, stdout, stderr) {
729
+ if (stderr && stderr.length > 0) {
730
+ common.detectNodeMessage(stderr);
731
+ if (options.device === "emulator") {
732
+ expect(stderr).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
733
+ } else {
734
+ expect(stderr).toContain("ares-log ERR! [Tips]: There are no logs from the ID");
735
+ expect(stderr).toContain("ares-log ERR! [Tips]: Please check if the combination of options or the ID are valid");
736
+ }
737
+ } else {
738
+ expect(stdout.match(pmLogRegExp).length).toBeGreaterThan(3);
739
+ }
740
+ done();
741
+ });
742
+ });
743
+ });
744
+
745
+ describe(aresCmd + " -f", function() {
746
+ it("Show log with --follow option", function(done) {
747
+ if (options.profile === "tv") {
748
+ pending(options.skipTxt);
749
+ }
750
+ const child = exec(cmd + " -f");
751
+ let result = "";
752
+
753
+ child.stdout.on("data", function(data) {
754
+ result += data;
755
+ });
756
+
757
+ child.stderr.on("data", function(data) {
758
+ if (data && data.length > 0) {
759
+ common.detectNodeMessage(data);
760
+ }
761
+ result += data;
762
+ });
763
+
764
+ setTimeout(() => {
765
+ child.kill();
766
+ if (options.device === "emulator") {
767
+ expect(result).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
768
+ } else if (targetLogDaemon === "journald") {
769
+ expect(result.match(journalLogRegExp).length > 0).toBeTrue();
770
+ } else if (targetLogDaemon === "pmlogd") {
771
+ expect(result.match(pmLogRegExp).length > 0).toBeTrue();
772
+ }
773
+ done();
774
+ }, 1000);
775
+ });
776
+ });
777
+
778
+ describe(aresCmd + " -r", function() {
779
+ it("Show log with --reverse option", function(done) {
780
+ if (options.profile === "tv") {
781
+ pending(options.skipTxt);
782
+ }
783
+ const child = exec(cmd + " -r");
784
+ let result = "";
785
+
786
+ child.stdout.on('data', function(data) {
787
+ result += data;
788
+ });
789
+
790
+ child.stderr.on('data', function(data) {
791
+ if (data && data.length > 0) {
792
+ common.detectNodeMessage(data);
793
+ }
794
+ result += data;
795
+ });
796
+
797
+ setTimeout(() => {
798
+ child.kill();
799
+ if (options.device === "emulator") {
800
+ expect(result).toContain("ares-log ERR! [Tips]: Unable to connect to the target device. root access required");
801
+ } else if (targetLogDaemon === "journald") {
802
+ expect(result.match(journalLogRegExp).length > 0).toBeTrue();
803
+ }
804
+ done();
805
+ }, 1000);
806
+ });
807
+ });
808
+
809
+ describe('Set default configuration', function() {
810
+ it("Install sample app to device with ares-install", function(done) {
811
+ if (options.profile === "tv") {
812
+ pending(options.skipTxt);
813
+ }
814
+ const installCmd = common.makeCmd("ares-install");
815
+ exec(installCmd + ` -r ${testAppPath}`, function(error, stdout, stderr) {
816
+ if (stderr && stderr.length > 0) {
817
+ common.detectNodeMessage(stderr);
818
+ } else {
819
+ expect(stdout).toContain(`Removed package ${testAppId}`, stderr);
820
+ }
821
+ done();
822
+ });
823
+ });
824
+ });