e2ed2f82115bbe99aad6b85169d1342877201afb
[platform/core/dotnet/launcher.git] / tests / TCs / 6_TOOL / TOOL.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 = "TOOL"
11
12 # The `dotnettool` works normally.
13 def TC_01():
14     if not exist("/usr/bin/dotnettool")
15         return "FAIL : The dotnettool works normally"
16
17     raw = cmd(f"shell dotnettool")
18     if "Dotnet Tool Version: 1.0" not in raw:
19         return "FAIL : The dotnettool works normally"
20
21     return "PASS"
22
23 # The `native image` is generated normally.
24 def TC_02():
25     cmd(f"shell dotnettool --ni-system")
26
27     if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
28         return "FAIL : Create the platform native image"
29
30     raw = cmd(f"shell find {RUNTIME_DIR} -name *.ni.dll")
31     lines1 = [l for l in raw.splitlines()]
32     raw = cmd(f"shell find {RUNTIME_DIR} -name *.dll -not -name *.ni.dll")
33     lines2 = [l for l in raw.splitlines()]
34     if (len(lines1) + 2) != len(lines2):
35         return "FAIL : The number of .dll and .ni.dll must match"
36
37     raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
38     lines1 = [l for l in raw.splitlines()]
39     raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.dll -not -name *.ni.dll")
40     lines2 = [l for l in raw.splitlines() if "/ref/" not in l]
41     if len(lines1) != len(lines2):
42         return "FAIL : The number of .dll and .ni.dll must match"
43
44     for ni in lines1:
45         is_same = False
46         for dll in lines2:
47             if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
48                 is_same = True
49                 break
50         if not is_same:
51             return "FAIL : The file name of .dll and .ni.dll must match in the platform"
52
53     return "PASS"
54
55 # Remove the `platform` native image.
56 def TC_03():
57     cmd(f"shell dotnettool --ni-reset-system")
58
59     if exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
60         return "FAIL : Remove the platform native image"
61
62     return "PASS"
63
64 # Create native image for `System.Private.CoreLib.dll`.
65 def TC_04():
66     if exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
67         cmd(f"shell rm {RUNTIME_DIR}{SPC_DLL}")
68         cmd(f"shell mv {RUNTIME_DIR}{SPC_DLL}.Backup {RUNTIME_DIR}{SPC_DLL}")
69
70     raw = cmd(f"shell dotnettool --ni-dll {RUNTIME_DIR}{SPC_DLL}")
71     if f"{SPC_DLL} (FNV)" not in raw and \
72        "System.Private.CoreLib.ni.dll generated successfully." not in raw:
73         return f"FAIL : Create native image for {SPC_DLL}"
74
75     if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
76         return f"FAIL : Create native image for {SPC_DLL}"
77
78     return "PASS"
79
80 # The file name of `.dll` and `.ni.dll` must match in the framework.
81 def TC_05():
82     cmd(f"shell dotnettool --ni-dir {FRAMEWORK_DIR}")
83     raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
84     lines1 = [l for l in raw.splitlines()]
85     raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.dll -not -name *.ni.dll")
86     lines2 = [l for l in raw.splitlines() if "/ref/" not in l]
87     if len(lines1) != len(lines2):
88         return "FAIL : The number of .dll and .ni.dll must match"
89
90     for ni in lines1:
91         is_same = False
92         for dll in lines2:
93             if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
94                 is_same = True
95                 break
96         if not is_same:
97             return "FAIL : The file name of .dll and .ni.dll must match in the {FRAMEWORK_DIR}"
98
99     return "PASS"
100
101 # The `.ni.dll` files should not exist in the framework.
102 def TC_06():
103     cmd(f"shell dotnettool --ni-reset-dir {FRAMEWORK_DIR}")
104     raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
105     lines = [l for l in raw.splitlines()]
106     if len(lines) != 0:
107         return "FAIL : The .ni.dll files should not exist"
108
109     return "PASS"
110
111 # Create native image for Tizen.dll in `R2R` mode.
112 def TC_07():
113     raw = cmd(f"shell dotnettool --r2r --ni-dll {FRAMEWORK_DIR}Tizen.dll")
114     if "Tizen.dll (R2R)" not in raw and \
115        "Tizen.ni.dll generated successfully." not in raw:
116         return "FAIL : Create native image for Tizen.dll in R2R mode"
117
118     return "PASS"
119
120 # Displays detailed information while creating native image for Tizen.Log.dll.
121 def TC_08():
122     raw = cmd(f"shell dotnettool --verbose --ni-dll {FRAMEWORK_DIR}Tizen.Log.dll")
123     if ("Opening input file" not in raw) or \
124        ("Breakdown of Indirections" not in raw) or \
125        ("Tizen.Log.ni.dll generated successfully." not in raw):
126         return "FAIL : Displays detailed information while creating native image for Tizen.Log.dll"
127
128     return "PASS"
129
130 # Create a native image for netstandard.dll by specifying the directory containing the IBC files.
131 def TC_09():
132     current_path = os.path.abspath(__file__)
133     packaging_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../packaging"))
134     ibcdata_zip = ""
135
136     raw = cmd("capability")
137     line = [l for l in raw.splitlines() if "cpu_arch" in l]
138     target_arch = line[0].split(":")[1]
139     if ("armv7" == target_arch) or \
140        ("x86" == target_arch):
141         ibcdata_zip = "ibcdata_arm.zip"
142     else:
143         ibcdata_zip = "ibcdata_aarch64.zip"
144
145     cmd(f"push {packaging_path}/{ibcdata_zip} /tmp")
146     cmd(f"shell unzip /tmp/{ibcdata_zip} -d {IBCDATA_DIR}")
147     cmd(f"shell chsmack -a _ {IBCDATA_DIR} -r")
148
149     if not exist(f"{IBCDATA_DIR}netstandard.ibc"):
150         return "FAIL : The netstandard.ibc file should exist"
151
152     raw = cmd(f"shell dotnettool --ibc-dir /usr/share/dotnet.tizen/ibcdata/ --ni-dll {RUNTIME_DIR}netstandard.dll")
153     if ("netstandard.dll (FNV)" not in raw) or \
154        ("netstandard.ni.dll generated successfully." not in raw):
155         return "FAIL : Create native image for netstandard.dll"
156
157     return "PASS"
158
159 # The `Launcher_TC_TOOL_01` application does not have native image.
160 def TC_10():
161     sln_name = "Launcher_TC_TOOL_01.Tizen"
162
163     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
164     if tpk_path == None:
165         return f"FAIL : Get the tpk path for {sln_name}"
166
167     if "OK" not in app_install(f"{tpk_path}"):
168         return f"FAIL : Install the application for {tpk_path}"
169
170     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_01.Tizen"
171
172     root_path = get_root_path(f"{pkg_id}")
173     if root_path == "None":
174         return f"FAIL : Get the root path for {pkg_id}"
175
176     if not exist(f"{root_path}/bin/.native_image"):
177         return "FAIL : The .native_image folder should exist"
178
179     cmd(f"shell dotnettool --ni-reset-pkg {pkg_id}")
180
181     if exist(f"{root_path}/bin/.native_image"):
182         return "FAIL : The .native_image folder should not exist"
183
184     raw = cmd(f"shell find {root_path}/bin/ -name *.ni.dll")
185     lines = [l for l in raw.splitlines()]
186     if len(lines) != 0:
187         return "FAIL : The .ni.dll files should not exist"
188
189     return "PASS"
190
191 # The `Launcher_TC_TOOL_02` application generates native image.
192 def TC_11():
193     sln_name = "Launcher_TC_TOOL_02.Tizen"
194
195     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
196     if tpk_path == None:
197         return f"FAIL : Get the tpk path for {sln_name}"
198
199     if "OK" not in app_install(f"{tpk_path}"):
200         return f"FAIL : Install the application for {tpk_path}"
201
202     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_02.Tizen"
203
204     root_path = get_root_path(f"{pkg_id}")
205     if root_path == "None":
206         return f"FAIL : Get the root path for {pkg_id}"
207
208     if exist(f"{root_path}/bin/.native_image"):
209         return "FAIL : The .native_image folder not should exist"
210
211     cmd(f"shell dotnettool --ni-pkg {pkg_id}")
212
213     if not exist(f"{root_path}/bin/.native_image"):
214         return "FAIL : The .native_image folder should exist"
215
216     raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
217     lines1 = [l for l in raw.splitlines()]
218     raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
219     lines2 = [l for l in raw.splitlines()]
220     if len(lines1) != len(lines2):
221         return "FAIL : The number of .dll and .ni.dll must match in the application"
222
223     for ni in lines1:
224         is_same = False
225         for dll in lines2:
226             if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
227                 is_same = True
228                 break
229         if not is_same:
230             return "FAIL : The file name of .dll and .ni.dll must match in the application"
231
232     return "PASS"
233
234 # The `prefer_dotnet_aot` metadata value of `true` will regenerates the native image in all .NET applications.
235 def TC_12():
236     sln_name = "Launcher_TC_TOOL_03.Tizen"
237
238     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
239     if tpk_path == None:
240         return f"FAIL : Get the tpk path for {sln_name}"
241
242     if "OK" not in app_install(f"{tpk_path}"):
243         return f"FAIL : Install the application for {tpk_path}"
244
245     cmd(f"shell dotnettool --ni-regen-all-app")
246
247     raw = subprocess.run((f"sdb -s {serial} shell pkginfo --metadata-flt").split(), stdout=subprocess.PIPE, input=f"http://tizen.org/metadata/prefer_dotnet_aot\ntrue\n", encoding="utf-8").stdout
248     lines = [l for l in raw.splitlines() if "appid" in l]
249     for app in lines:
250         pkg_id = app.split(": ")[1]
251         raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout
252         readonly = [l for l in raw.splitlines() if "Readonly" in l]
253         if "0" == readonly[0].split(": ")[1]:
254             path = [l for l in raw.splitlines() if "root_path" in l]
255             root_path = path[0].split(": ")[1]
256             raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
257             lines1 = [l for l in raw.splitlines()]
258             raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
259             lines2 = [l for l in raw.splitlines()]
260             if len(lines1) != len(lines2):
261                 return "FAIL : The number of .dll and .ni.dll must match in the application"
262
263             for ni in lines1:
264                 is_same = False
265                 for dll in lines2:
266                     if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
267                         is_same = True
268                         break
269                 if not is_same:
270                     return "FAIL : The file name of .dll and .ni.dll must match in the application"
271
272     return "PASS"
273
274 # The `prefer_nuget_cache` metadata value of `true` will regenerates the native image in the `TAC`.
275 def TC_13():
276     sln_name = "Launcher_TC_TOOL_04.Tizen"
277
278     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
279     if tpk_path == None:
280         return f"FAIL : Get the tpk path for {sln_name}"
281
282     if "OK" not in app_install(f"{tpk_path}"):
283         return f"FAIL : Install the application for {tpk_path}"
284
285     raw = cmd(f"shell dotnettool --tac-regen-all")
286     if ".dll (FNV)" not in raw and \
287        ".ni.dll generated successfully." not in raw:
288         return "FAIL : Create native image for TAC"
289
290     return "PASS"
291
292 # The `Launcher_TC_TOOL_05` application must not have `TAC` applied.
293 def TC_14():
294     sln_name = "Launcher_TC_TOOL_05.Tizen"
295
296     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
297     if tpk_path == None:
298         return f"FAIL : Get the tpk path for {sln_name}"
299
300     if "OK" not in app_install(f"{tpk_path}"):
301         return f"FAIL : Install the application for {tpk_path}"
302
303     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_05.Tizen"
304
305     root_path = get_root_path(f"{pkg_id}")
306     if root_path == "None":
307         return f"FAIL : Get the root path for {pkg_id}"
308
309     if not exist(f"{root_path}/bin/.tac_symlink"):
310         return "FAIL : The .tac_symlink folder should exist"
311
312     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
313     lines1 = [l for l in raw.splitlines()]
314     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
315     lines2 = [l for l in raw.splitlines()]
316     if len(lines1) != len(lines2):
317         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
318
319     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
320     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
321     for dll in lines:
322         origin_path = dll.split("->")[1].strip()
323         if not exist(f"{origin_path}"):
324             return "FAIL : The original file of the symbolic link must exist"
325
326     cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
327
328     if exist(f"{root_path}/bin/.tac_symlink"):
329         return "FAIL : The .tac_symlink folder should not exist"
330
331     raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
332     lines = [l for l in raw.splitlines()]
333     if len(lines) != 6:
334         return "FAIL : The number of .dll must exist correctly in the bin folder"
335
336     return "PASS"
337
338 # The `Launcher_TC_TOOL_06` application must have `TAC` applied.
339 def TC_15():
340     sln_name = "Launcher_TC_TOOL_06.Tizen"
341
342     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
343     if tpk_path == None:
344         return f"FAIL : Get the tpk path for {sln_name}"
345
346     if "OK" not in app_install(f"{tpk_path}"):
347         return f"FAIL : Install the application for {tpk_path}"
348
349     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_06.Tizen"
350
351     root_path = get_root_path(f"{pkg_id}")
352     if root_path == "None":
353         return f"FAIL : Get the root path for {pkg_id}"
354
355     cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
356
357     if exist(f"{root_path}/bin/.tac_symlink"):
358         return "FAIL : The .tac_symlink folder should not exist"
359
360     raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
361     lines = [l for l in raw.splitlines()]
362     if len(lines) != 6:
363         return "FAIL : The number of .dll must exist correctly in the bin folder"
364
365     cmd(f"shell dotnettool --tac-enable-pkg {pkg_id}")
366
367     if not exist(f"{root_path}/bin/.tac_symlink"):
368         return "FAIL : The .tac_symlink folder should exist"
369
370     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
371     lines1 = [l for l in raw.splitlines()]
372     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
373     lines2 = [l for l in raw.splitlines()]
374     if len(lines1) != len(lines2):
375         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
376
377     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
378     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
379     for dll in lines:
380         origin_path = dll.split("->")[1].strip()
381         if not exist(f"{origin_path}"):
382             return "FAIL : The original file of the symbolic link must exist"
383
384     return "PASS"
385
386 # The `DB` of the restored `TAC` and `TLC` must be a valid value.
387 def TC_16():
388     sln_name = "Launcher_TC_TOOL_07.Tizen"
389
390     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
391     if tpk_path == None:
392         return f"FAIL : Get the tpk path for {sln_name}"
393
394     if "OK" not in app_install(f"{tpk_path}"):
395         return f"FAIL : Install the application for {tpk_path}"
396
397     cmd(f"shell rm {DOTNET_DIR}.TAC.App.list.db*")
398     cmd(f"shell rm {DOTNET_DIR}.TLC.App.list.db*")
399
400     cmd(f"shell dotnettool --tac-restore-db")
401
402     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_07.Tizen"
403
404     raw = subprocess.run((f"sdb -s {serial} shell sqlite3 {DOTNET_DIR}.TAC.App.list.db").split(), stdout=subprocess.PIPE, input=f"select * from TAC;\n.q\n", encoding="utf-8").stdout
405     lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
406     for rcd in lines:
407         if ("SkiaSharp/2.80.2" not in rcd) and \
408            ("Xamarin.Forms/4.6.0.967" not in rcd):
409             return "FAIL : TAC database must have a valid value"
410
411     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
412     lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
413     for rcd in lines:
414         if "libSkiaSharp.so..8e2fcc43f9c49b2de7b6212ff5ed914b319bc92f125715b9fe1f35786df82f98" not in rcd:
415             return "FAIL : TLC database must have a valid value"
416
417     return "PASS"
418
419 # The prefer_dotnet_aot metadata value of true will regenerates the native image in all .NET applications of read-only type.
420 def TC_17():
421     sln_name = "Launcher_TC_TOOL_08.Tizen"
422
423     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
424     if tpk_path == None:
425         return f"FAIL : Get the tpk path for {sln_name}"
426
427     raw = cmd(f"push {tpk_path} /usr/apps/.preload-tpk/")
428     if "1 file(s) pushed. 0 file(s) skipped." in raw:
429         cmd(f"shell install_preload_pkg")
430
431     cmd(f"shell dotnettool --ni-regen-all-ro-app")
432
433     raw = subprocess.run((f"sdb -s {serial} shell pkginfo --metadata-flt").split(), stdout=subprocess.PIPE, input=f"http://tizen.org/metadata/prefer_dotnet_aot\ntrue\n", encoding="utf-8").stdout
434     lines = [l for l in raw.splitlines() if "appid" in l]
435     for app in lines:
436         pkg_id = app.split(": ")[1]
437         raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout
438         readonly = [l for l in raw.splitlines() if "Readonly" in l]
439         if "1" == readonly[0].split(": ")[1]:
440             path = [l for l in raw.splitlines() if "root_path" in l]
441             root_path = path[0].split(": ")[1]
442             raw = cmd(f"shell find {DOTNET_DIR}apps/{pkg_id}/bin/.native_image/ -name *.ni.dll")
443             lines1 = [l for l in raw.splitlines()]
444             raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
445             lines2 = [l for l in raw.splitlines()]
446             if len(lines1) != len(lines2):
447                 return "FAIL : The number of .dll and .ni.dll must match in the application"
448
449             for ni in lines1:
450                 is_same = False
451                 for dll in lines2:
452                     if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
453                         is_same = True
454                         break
455                 if not is_same:
456                     return "FAIL : The file name of .dll and .ni.dll must match in the application"
457
458     return "PASS"
459
460 # The `Launcher_TC_TOOL_08` application should load the newly generated native image.
461 def TC_18():
462     pkg_id = f"org.tizen.example.Launcher_TC_TOOL_08.Tizen"
463
464     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
465     if 0 == pid:
466         return f"FAIL : Get the pid for {pkg_id}"
467
468     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
469     if (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Platform.Tizen.ni.dll" not in raw) or \
470        (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Core.ni.dll" not in raw) or \
471        (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Platform.ni.dll" not in raw):
472         return "FAIL : The Xamarin.Forms in the application should be loaded when running the application"
473
474     cmd(f"shell app_launcher -t {pkg_id}")
475
476     return "PASS"
477
478 # It should be done together for update test.
479 def TC_17_18():
480     ret = TC_17()
481     if "PASS" != ret:
482         return f"{ret}"
483
484     ret = TC_18()
485     if  "PASS" != ret:
486         return f"{ret}"
487
488     return "PASS"
489
490 #def TC_19():
491 #dotnettool --resolve-all-app
492
493
494 # Run the test
495 def run():
496     cmd(f"root on")
497     cmd(f"shell mount -o remount,rw /")
498
499     global tpk_list
500     tpk_list = search_tpk(f"{module_name}")
501
502     p = run_tc_array(module_name, tc_array)
503     f = len(tc_array) - p
504     r = round(((p / len(tc_array)) * 100), 2)
505     print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
506
507 # Uninstall the application and restore to original state
508 def clean():
509     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_01.Tizen")
510     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_02.Tizen")
511     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_03.Tizen")
512     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_04.Tizen")
513     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_05.Tizen")
514     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_06.Tizen")
515     cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_07.Tizen")
516
517     cmd(f"shell rm {FRAMEWORK_DIR}Tizen.ni.dll")
518     cmd(f"shell rm {FRAMEWORK_DIR}Tizen.Log.ni.dll")
519     cmd(f"shell rm {RUNTIME_DIR}netstandard.ni.dll")
520
521     cmd(f"shell rm -rf {IBCDATA_DIR}")
522
523     cmd(f"shell rm -rf {DOTNET_DIR}apps/org.tizen.example.Launcher_TC_TOOL_08.Tizen")
524
525 # Main entry point
526 def main():
527     parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
528     parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
529     args = parser.parse_args()
530
531     global tc_array
532     if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
533         tc_array = []
534         for tc_num in args.TC_NUMBER:
535             if tc_num not in funcMap:
536                 print(f"There is no {tc_num} test.")
537                 exit(1)
538             else:
539                 tc_array.append(funcMap[tc_num])
540     else:
541         tc_array = [TC_01, TC_02, TC_03, TC_04, TC_05, TC_06, TC_07, TC_08, TC_09, TC_10, TC_11, TC_12, TC_13, TC_14, TC_15, TC_16, TC_17, TC_18]
542
543     global serial
544     if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
545         serial = read_serial(sys.argv[1])
546     else:
547         serial = read_serial(None)
548
549     if serial is None:
550         print("No connected device(s).")
551         exit(1)
552
553     device = get_device_type()
554     print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
555
556     run()
557     clean()
558
559
560 funcMap = {
561 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04, 'TC_05': TC_05, 'TC_06': TC_06,
562 'TC_07': TC_07, 'TC_08': TC_08, 'TC_09': TC_09, 'TC_10': TC_10, 'TC_11': TC_11, 'TC_12': TC_12,
563 'TC_13': TC_13, 'TC_14': TC_14, 'TC_15': TC_15, 'TC_16': TC_16, 'TC_17': TC_17, 'TC_18': TC_17_18,
564 'TOOL_TC_01': TC_01, 'TOOL_TC_02': TC_02, 'TOOL_TC_03': TC_03, 'TOOL_TC_04': TC_04, 'TOOL_TC_05': TC_05, 'TOOL_TC_06': TC_06,
565 'TOOL_TC_07': TC_07, 'TOOL_TC_08': TC_08, 'TOOL_TC_09': TC_09, 'TOOL_TC_10': TC_10, 'TOOL_TC_11': TC_11, 'TOOL_TC_12': TC_12,
566 'TOOL_TC_13': TC_13, 'TOOL_TC_14': TC_14, 'TOOL_TC_15': TC_15, 'TOOL_TC_16': TC_16, 'TOOL_TC_17': TC_17, 'TOOL_TC_18': TC_17_18
567 }
568
569
570 if __name__ == "__main__":
571     try:
572         main()
573     except KeyboardInterrupt:
574         print("\nExit (Pressed Ctrl+C)")
575         exit(1)