[TC Fixed] Change the 'find' command
[platform/core/dotnet/launcher.git] / tests / TCs / 5_TLC / TLC.py
1 #!/usr/bin/env python3
2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
4
5 from time import sleep
6 from pathlib import Path
7 from Utils import *
8
9
10 module_name = "TLC"
11
12 # The `Launcher_TC_TLC_01` application must have TLC applied.
13 def TC_01():
14     sln_name = "Launcher_TC_TLC_01.Tizen"
15
16     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
17     if tpk_path == None:
18         return f"FAIL : Get the tpk path for {sln_name}"
19
20     if "OK" not in app_install(f"{tpk_path}"):
21         return f"FAIL : Install the application for {tpk_path}"
22
23     pkg_id = f"org.tizen.example.Launcher_TC_TLC_01.Tizen"
24
25     root_path = get_root_path(f"{pkg_id}")
26     if root_path == "None":
27         return f"FAIL : Get the root path for {pkg_id}"
28
29     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
30         return "FAIL : The libSkiaSharp.so library should exist in the application"
31
32     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
33     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
34        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
35         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
36
37     sha = raw.split("..")[1].rstrip()
38
39     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
40     if sha not in raw:
41         return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
42
43     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
44         return "FAIL : The arch of the target and the arch of the library must match"
45
46     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
47     if 0 == pid:
48         return f"FAIL : Get the pid for {pkg_id}"
49
50     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
51     if (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." + sha) not in raw:
52         return "FAIL : TThe libSkiaSharp.so library in the TLC should be loaded when running the application"
53
54     cmd(f"shell app_launcher -t {pkg_id}")
55
56     return "PASS"
57
58 # The `Launcher_TC_TLC_02` application must have TLC applied.
59 def TC_02():
60     sln_name = "Launcher_TC_TLC_02.Tizen"
61
62     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
63     if tpk_path == None:
64         return f"FAIL : Get the tpk path for {sln_name}"
65
66     if "OK" not in app_install(f"{tpk_path}"):
67         return f"FAIL : Install the application for {tpk_path}"
68
69     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
70
71     root_path = get_root_path(f"{pkg_id}")
72     if root_path == "None":
73         return f"FAIL : Get the root path for {pkg_id}"
74
75     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
76         return "FAIL : The libSkiaSharp.so library should exist in the application"
77
78     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
79     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
80        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
81         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
82
83     sha = raw.split("..")[1].rstrip()
84
85     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
86     if sha not in raw:
87         return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
88
89     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
90         return "FAIL : The arch of the target and the arch of the library must match"
91
92     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
93     if 0 == pid:
94         return f"FAIL : Get the pid for {pkg_id}"
95
96     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
97     if (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." + sha) not in raw:
98         return "FAIL : The libSkiaSharp.so library in the TLC should be loaded when running the application"
99
100     cmd(f"shell app_launcher -t {pkg_id}")
101
102     return "PASS"
103
104 # The `Launcher_TC_TLC_03` application should not apply TLC when updating.
105 def TC_03():
106     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
107
108     root_path = get_root_path(f"{pkg_id}")
109     if root_path == "None":
110         return f"FAIL : Get the root path for {pkg_id}"
111
112     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
113         return "FAIL : The libSkiaSharp.so library should exist in the application"
114
115     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
116     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
117        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
118         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
119
120     sha = raw.split("..")[1].rstrip()
121
122     sln_name = "Launcher_TC_TLC_03.Tizen"
123
124     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
125     if tpk_path == None:
126         return f"FAIL : Get the tpk path for {sln_name}"
127
128     if "OK" not in app_install(f"{tpk_path}"):
129         return f"FAIL : Install the application for {tpk_path}"
130
131     root_path = get_root_path(f"{pkg_id}")
132     if root_path == "None":
133         return f"FAIL : Get the root path for {pkg_id}"
134
135     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
136     if sha in raw:
137         return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
138
139     if exist(f"{root_path}/bin/libSkiaSharp.so"):
140         return "FAIL : The libSkiaSharp.so library should not exist in the application"
141
142     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
143     if 0 == pid:
144         return f"FAIL : Get the pid for {pkg_id}"
145
146     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
147     if f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." in raw:
148         return "FAIL : The libSkiaSharp.so library should not be loaded when running the application"
149
150     cmd(f"shell app_launcher -t {pkg_id}")
151
152     return "PASS"
153
154 # It should be done together for update test.
155 def TC_02_03():
156     ret = TC_02()
157     if "PASS" != ret:
158         return f"{ret}"
159
160     ret = TC_03()
161     if  "PASS" != ret:
162         return f"{ret}"
163
164     return "PASS"
165
166 # The `Launcher_TC_TLC_04` application is normally TLC applied when updating.
167 def TC_04():
168     sln_name = "Launcher_TC_TLC_04.Tizen"
169
170     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
171     if tpk_path == None:
172         return f"FAIL : Get the tpk path for {sln_name}"
173
174     if "OK" not in app_install(f"{tpk_path}"):
175         return f"FAIL : Install the application for {tpk_path}"
176
177     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
178
179     root_path = get_root_path(f"{pkg_id}")
180     if root_path == "None":
181         return f"FAIL : Get the root path for {pkg_id}"
182
183     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
184         return "FAIL : The libSkiaSharp.so library should exist in the application"
185
186     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
187     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
188        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
189         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
190
191     sha = raw.split("..")[1].rstrip()
192
193     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
194     if sha not in raw:
195         return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
196
197     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
198         return "FAIL : The arch of the target and the arch of the library must match"
199
200     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
201     if 0 == pid:
202         return f"FAIL : Get the pid for {pkg_id}"
203
204     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
205     if (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." + sha) not in raw:
206         return "FAIL : The libSkiaSharp.so library in the TLC should be loaded when running the application"
207
208     cmd(f"shell app_launcher -t {pkg_id}")
209
210     return "PASS"
211
212 # The `Launcher_TC_TLC_05` application is normally TLC applied when updating.
213 def TC_05():
214     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
215
216     root_path = get_root_path(f"{pkg_id}")
217     if root_path == "None":
218         return f"FAIL : Get the root path for {pkg_id}"
219
220     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
221         return "FAIL : The libSkiaSharp.so library should exist in the application"
222
223     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
224     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
225        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
226         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
227
228     sha = raw.split("..")[1].rstrip()
229
230     sln_name = "Launcher_TC_TLC_05.Tizen"
231
232     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
233     if tpk_path == None:
234         return f"FAIL : Get the tpk path for {sln_name}"
235
236     if "OK" not in app_install(f"{tpk_path}"):
237         return f"FAIL : Install the application for {tpk_path}"
238
239     root_path = get_root_path(f"{pkg_id}")
240     if root_path == "None":
241         return f"FAIL : Get the root path for {pkg_id}"
242
243     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
244     if sha in raw:
245         return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
246
247     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
248         return "FAIL : The libSkiaSharp.so library should exist in the application"
249
250     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
251     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
252        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
253         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
254
255     sha = raw.split("..")[1].rstrip()
256
257     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
258     if sha not in raw:
259         return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
260
261     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
262         return "FAIL : The arch of the target and the arch of the library must match"
263
264     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
265     if 0 == pid:
266         return f"FAIL : Get the pid for {pkg_id}"
267
268     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
269     if (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." + sha) not in raw:
270         return "FAIL : The libSkiaSharp.so library in the TLC should be loaded when running the application"
271
272     cmd(f"shell app_launcher -t {pkg_id}")
273
274     return "PASS"
275
276 # It should be done together for update test.
277 def TC_04_05():
278     ret = TC_04()
279     if "PASS" != ret:
280         return f"{ret}"
281
282     ret = TC_05()
283     if  "PASS" != ret:
284         return f"{ret}"
285
286     return "PASS"
287
288 # The `Launcher_TC_TLC_06` application should not apply TLC when updating.
289 def TC_06():
290     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
291
292     root_path = get_root_path(f"{pkg_id}")
293     if root_path == "None":
294         return f"FAIL : Get the root path for {pkg_id}"
295
296     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
297         return "FAIL : The libSkiaSharp.so library should exist in the application"
298
299     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
300     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
301        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
302         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
303
304     sha = raw.split("..")[1].rstrip()
305
306     sln_name = "Launcher_TC_TLC_06.Tizen"
307
308     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
309     if tpk_path == None:
310         return f"FAIL : Get the tpk path for {sln_name}"
311
312     if "OK" not in app_install(f"{tpk_path}"):
313         return f"FAIL : Install the application for {tpk_path}"
314
315     root_path = get_root_path(f"{pkg_id}")
316     if root_path == "None":
317         return f"FAIL : Get the root path for {pkg_id}"
318
319     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
320     if sha in raw:
321         return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
322
323     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
324         return "FAIL : The libSkiaSharp.so library should exist only in the application"
325
326     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
327     if "->" in raw:
328         return "FAIL : The libSkiaSharp.so library should not be a symbolic link"
329
330     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
331         return "FAIL : The arch of the target and the arch of the library must match"
332
333     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
334     if 0 == pid:
335         return f"FAIL : Get the pid for {pkg_id}"
336
337     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libSkiaSharp.so")
338     if (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." in raw) or \
339        (f"{root_path}/bin/libSkiaSharp.so" not in raw):
340         return "FAIL : The libSkiaSharp.so library in the application should be loaded when running the application"
341
342     cmd(f"shell app_launcher -t {pkg_id}")
343
344     return "PASS"
345
346 # It should be done together for update test.
347 def TC_04_05_06():
348     ret = TC_04()
349     if "PASS" != ret:
350         return f"{ret}"
351
352     ret = TC_05()
353     if  "PASS" != ret:
354         return f"{ret}"
355
356     ret = TC_06()
357     if "PASS" != ret:
358         return f"{ret}"
359
360     return "PASS"
361
362 # The `Launcher_TC_TLC_07`, `Launcher_TC_TLC_08` applications using the same nuget are normally TLC applied.
363 def TC_07():
364     sln_name = "Launcher_TC_TLC_07.Tizen"
365
366     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
367     if tpk_path == None:
368         return f"FAIL : Get the tpk path for {sln_name}"
369
370     if "OK" not in app_install(f"{tpk_path}"):
371         return f"FAIL : Install the application for {tpk_path}"
372
373     pkg_id1 = f"org.tizen.example.Launcher_TC_TLC_07.Tizen"
374
375     root_path = get_root_path(f"{pkg_id1}")
376     if root_path == "None":
377         return f"FAIL : Get the root path for {pkg_id1}"
378
379     if not exist(f"{root_path}/bin/libHarfBuzzSharp.so"):
380         return "FAIL : The libHarfBuzzSharp.so library should exist in the application"
381
382     raw = cmd(f"shell ls -alZ {root_path}/bin/libHarfBuzzSharp.so")
383     if (f"{root_path}/bin/libHarfBuzzSharp.so" not in raw) or \
384        (f"{DOTNET_DIR}Libraries/libHarfBuzzSharp.so.." not in raw):
385         return "FAIL : The libHarfBuzzSharp.so library should exist or be a symbolic link"
386
387     sha = raw.split("..")[1].rstrip()
388
389     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libHarfBuzzSharp.so*")
390     if sha not in raw:
391         return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}"
392
393     sln_name = "Launcher_TC_TLC_08.Tizen"
394
395     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
396     if tpk_path == None:
397         return f"FAIL : Get the tpk path for {sln_name}"
398
399     if "OK" not in app_install(f"{tpk_path}"):
400         return f"FAIL : Install the application for {tpk_path}"
401
402     pkg_id2 = f"org.tizen.example.Launcher_TC_TLC_08.Tizen"
403
404     root_path = get_root_path(f"{pkg_id2}")
405     if root_path == "None":
406         return f"FAIL : Get the root path for {pkg_id2}"
407
408     if not exist(f"{root_path}/bin/libHarfBuzzSharp.so"):
409         return "FAIL : The libHarfBuzzSharp.so library should exist"
410
411     raw = cmd(f"shell ls -alZ {root_path}/bin/libHarfBuzzSharp.so")
412     if (f"{root_path}/bin/libHarfBuzzSharp.so" not in raw) or \
413        (f"{DOTNET_DIR}Libraries/libHarfBuzzSharp.so.." not in raw):
414         return "FAIL : The libHarfBuzzSharp.so library should exist or be a symbolic link"
415
416     if "OK" not in check_library_arch(f"{root_path}", "libHarfBuzzSharp.so"):
417         return "FAIL : The arch of the target and the arch of the library must match"
418
419     sha = raw.split("..")[1].rstrip()
420
421     raw = cmd(f"uninstall {pkg_id1}")
422     if "key[end] val[ok]" not in raw:
423         return f"FAIL : Uninstall the application for {pkg_id1}"
424
425     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libHarfBuzzSharp.so*")
426     if sha not in raw:
427         return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}"
428
429     if "OK" not in check_library_arch(f"{root_path}", "libHarfBuzzSharp.so"):
430         return "FAIL : The arch of the target and the arch of the library must match"
431
432     pid = launch_and_get_pid(f"-e", f"{pkg_id2}")
433     if 0 == pid:
434         return f"FAIL : Get the pid for {pkg_id2}"
435
436     raw = cmd(f"shell cat /proc/{pid}/smaps | grep libHarfBuzzSharp.so")
437     if (f"{DOTNET_DIR}Libraries/libHarfBuzzSharp.so.." + sha) not in raw:
438         return "FAIL : The libHarfBuzzSharp.so library in the TLC should be loaded when running the application"
439
440     cmd(f"shell app_launcher -t {pkg_id2}")
441
442     return "PASS"
443
444 # The `Launcher_TC_TLC_09` application is normally TLC applied when uninstall.
445 def TC_08():
446     sln_name = "Launcher_TC_TLC_09.Tizen"
447
448     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
449     if tpk_path == None:
450         return f"FAIL : Get the tpk path for {sln_name}"
451
452     if "OK" not in app_install(f"{tpk_path}"):
453         return f"FAIL : Install the application for {tpk_path}"
454
455     pkg_id = f"org.tizen.example.Launcher_TC_TLC_09.Tizen"
456
457     root_path = get_root_path(f"{pkg_id}")
458     if root_path == "None":
459         return f"FAIL : Get the root path for {pkg_id}"
460
461     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
462         return "FAIL : The libSkiaSharp.so library should exist"
463
464     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
465     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
466        (f"{DOTNET_DIR}Libraries/libSkiaSharp.so.." not in raw):
467         return "FAIL : The libSkiaSharp.so library should exist or be a symbolic link"
468
469     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
470         return "FAIL : The arch of the target and the arch of the library must match"
471
472     sha = raw.split("..")[1].rstrip()
473
474     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
475     if sha not in raw:
476         return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
477
478     raw = cmd(f"uninstall {pkg_id}")
479     if "key[end] val[ok]" not in raw:
480         return f"FAIL : Uninstall the application for {pkg_id}"
481
482     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
483     if sha in raw:
484        return f"FAIL : The libSkiaSharp.so library should not exist in {DONTET_DIR}"
485
486     return "PASS"
487
488 # The `Launcher_TC_TLC_10` application should match the information of nuget with the value of TLC database.
489 def TC_09():
490     sln_name = "Launcher_TC_TLC_10.Tizen"
491
492     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
493     if tpk_path == None:
494         return f"FAIL : Get the tpk path for {sln_name}"
495
496     if "OK" not in app_install(f"{tpk_path}"):
497         return f"FAIL : Install the application for {tpk_path}"
498
499     pkg_id = f"org.tizen.example.Launcher_TC_TLC_10.Tizen"
500
501     root_path = get_root_path(f"{pkg_id}")
502     if root_path == "None":
503         return f"FAIL : Get the root path for {pkg_id}"
504
505     raw = cmd(f"shell find {root_path}/bin/ -name lib*.so*")
506     lines1 = [l for l in raw.splitlines()]
507     if len(lines1) == 0:
508         return "FAIL : The library should exist in the application"
509
510     raw = subprocess.run((f"sdb -s {serial} shell sqlite3 {DOTNET_DIR}.TLC.App.list.db").split(), stdout=subprocess.PIPE, input=f"select * from TLC;\n.q\n", encoding="utf-8").stdout
511     lines2 = [l for l in raw.splitlines() if f"{pkg_id}" in l]
512     if len(lines2) == 0:
513         return "FAIL : TLC database must have a valid value"
514
515     for lib in lines1:
516         raw = cmd(f"shell ls -alZ {lib}")
517         if "->" not in raw:
518             return f"FAIL : The {name} library should be a symbolic link"
519
520         name = Path(lib).name
521         if "OK" not in check_library_arch(f"{root_path}", f"{name}"):
522             return "FAIL : The arch of the target and the arch of the library must match"
523
524         sha = raw.split("..")[1].rstrip()
525
526         raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name {name}..{sha}")
527         if f"{DOTNET_DIR}Libraries/{name}..{sha}" not in raw:
528             return f"FAIL : The {name} library should exist in {DOTNET_DIR}"
529
530         is_exist = False
531         for rcd in lines2:
532             if f"{name}..{sha}" in raw:
533                 is_exist = True
534                 break
535
536         if not is_exist:
537             return "FAIL : TLC database must have a valid value"
538
539     return "PASS"
540
541 # Run the test
542 def run():
543     cmd(f"root on")
544     cmd(f"shell mount -o remount,rw /")
545
546     global tpk_list
547     tpk_list = search_tpk(f"{module_name}")
548
549     p = run_tc_array(module_name, tc_array)
550     f = len(tc_array) - p
551     r = round(((p / len(tc_array)) * 100), 2)
552     print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
553
554 # Uninstall the application and restore to original state
555 def clean():
556     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_01.Tizen")
557     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_00.Tizen")
558     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_07.Tizen")
559     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_08.Tizen")
560     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_09.Tizen")
561     cmd(f"uninstall org.tizen.example.Launcher_TC_TLC_10.Tizen")
562
563 # Main entry point
564 def main():
565     parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
566     parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
567     args = parser.parse_args()
568
569     global tc_array
570     if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
571         tc_array = []
572         for tc_num in args.TC_NUMBER:
573             if tc_num not in funcMap:
574                 print(f"There is no {tc_num} test.")
575                 exit(1)
576             else:
577                 tc_array.append(funcMap[tc_num])
578     else:
579         tc_array = [TC_01, TC_02, TC_03, TC_04, TC_05, TC_06, TC_07, TC_08, TC_09]
580
581     global serial
582     if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
583         serial = read_serial(sys.argv[1])
584     else:
585         serial = read_serial(None)
586
587     if serial is None:
588         print("No connected device(s).")
589         exit(1)
590
591     device = get_device_type()
592     print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
593
594     run()
595     clean()
596
597
598 funcMap = {
599 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_02_03, 'TC_04': TC_04, 'TC_05': TC_04_05, 'TC_06': TC_04_05_06, 'TC_07': TC_07, 'TC_08': TC_08, 'TC_09': TC_09,
600 'TLC_TC_01': TC_01, 'TLC_TC_02': TC_02, 'TLC_TC_03': TC_02_03, 'TLC_TC_04': TC_04, 'TLC_TC_05': TC_04_05,
601 'TLC_TC_06': TC_04_05_06, 'TLC_TC_07': TC_07, 'TLC_TC_08': TC_08, 'TLC_TC_09': TC_09
602 }
603
604
605 if __name__ == "__main__":
606     try:
607         main()
608     except KeyboardInterrupt:
609         print("\nExit (Pressed Ctrl+C)")
610         exit(1)