2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
11 # The `dotnettool` works normally.
13 raw = cmd(f"shell find /usr/bin/ -name dotnettool")
14 if "/usr/bin/dotnettool" not in raw:
15 return "FAIL : The dotnettool works normally"
17 raw = cmd(f"shell dotnettool")
18 if "Dotnet Tool Version: 1.0" not in raw:
19 return "FAIL : The dotnettool works normally"
23 # The `native image` is generated normally.
25 cmd(f"shell dotnettool --ni-system")
27 raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
28 if f"{RUNTIME_DIR}{SPC_DLL}.Backup" not in raw:
29 return "FAIL : Create the platform native image"
31 raw = cmd(f"shell find {RUNTIME_DIR} -name *.ni.dll")
32 lines1 = [l for l in raw.splitlines()]
33 raw = cmd(f"shell find {RUNTIME_DIR} -name *.dll -not -name *.ni.dll")
34 lines2 = [l for l in raw.splitlines()]
35 if (len(lines1) + 2) != len(lines2):
36 return "FAIL : The number of .dll and .ni.dll must match"
38 raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
39 lines1 = [l for l in raw.splitlines()]
40 raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.dll -not -name *.ni.dll")
41 lines2 = [l for l in raw.splitlines() if "/ref/" not in l]
42 if len(lines1) != len(lines2):
43 return "FAIL : The number of .dll and .ni.dll must match"
48 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
52 return "FAIL : The file name of .dll and .ni.dll must match in the platform"
56 # Remove the `platform` native image.
58 cmd(f"shell dotnettool --ni-reset-system")
60 raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
61 if f"{RUNTIME_DIR}{SPC_DLL}.Backup" in raw:
62 return "FAIL : Remove the platform native image"
66 # Create native image for `System.Private.CoreLib.dll`.
68 raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
69 if f"{RUNTIME_DIR}{SPC_DLL}.Backup" in raw:
70 cmd(f"shell rm {RUNTIME_DIR}{SPC_DLL}")
71 cmd(f"shell mv {RUNTIME_DIR}{SPC_DLL}.Backup {RUNTIME_DIR}{SPC_DLL}")
73 raw = cmd(f"shell dotnettool --ni-dll {RUNTIME_DIR}{SPC_DLL}")
74 if f"{SPC_DLL} (FNV)" not in raw and \
75 "System.Private.CoreLib.ni.dll generated successfully." not in raw:
76 return f"FAIL : Create native image for {SPC_DLL}"
78 raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
79 if f"{RUNTIME_DIR}{SPC_DLL}.Backup" not in raw:
80 return f"FAIL : Create native image for {SPC_DLL}"
84 # The file name of `.dll` and `.ni.dll` must match in the framework.
86 cmd(f"shell dotnettool --ni-dir {FRAMEWORK_DIR}")
87 raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
88 lines1 = [l for l in raw.splitlines()]
89 raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.dll -not -name *.ni.dll")
90 lines2 = [l for l in raw.splitlines() if "/ref/" not in l]
91 if len(lines1) != len(lines2):
92 return "FAIL : The number of .dll and .ni.dll must match"
97 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
101 return "FAIL : The file name of .dll and .ni.dll must match in the {FRAMEWORK_DIR}"
105 # The `.ni.dll` files should not exist in the framework.
107 cmd(f"shell dotnettool --ni-reset-dir {FRAMEWORK_DIR}")
108 raw = cmd(f"shell find {FRAMEWORK_DIR} -name *.ni.dll")
109 lines = [l for l in raw.splitlines()]
111 return "FAIL : The .ni.dll files should not exist"
115 # Create native image for Tizen.dll in `R2R` mode.
117 raw = cmd(f"shell dotnettool --r2r --ni-dll {FRAMEWORK_DIR}Tizen.dll")
118 if "Tizen.dll (R2R)" not in raw and \
119 "Tizen.ni.dll generated successfully." not in raw:
120 return "FAIL : Create native image for Tizen.dll in R2R mode"
124 # The `Launcher_TC_TOOL_01` application does not have native image.
126 sln_name = "Launcher_TC_TOOL_01.Tizen"
128 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
130 return f"FAIL : Get the tpk path for {sln_name}"
132 if "OK" not in app_install(f"{tpk_path}"):
133 return f"FAIL : Install the application for {tpk_path}"
135 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_01.Tizen"
137 root_path = get_root_path(f"{pkg_id}")
138 if root_path == "None":
139 return f"FAIL : Get the root path for {pkg_id}"
141 raw = cmd(f"shell find {root_path}/bin/ -name .native_image")
142 if ".native_image" not in raw:
143 return "FAIL : The .native_image folder should exist"
145 cmd(f"shell dotnettool --ni-reset-pkg {pkg_id}")
147 raw = cmd(f"shell ls {root_path}/bin/.native_image")
148 if "No such file or directory" not in raw:
149 return "FAIL : The .native_image folder should not exist"
151 raw = cmd(f"shell find {root_path}/bin/ -name *.ni.dll")
152 lines = [l for l in raw.splitlines()]
154 return "FAIL : The .ni.dll files should not exist"
158 # The `Launcher_TC_TOOL_02` application generates native image.
160 sln_name = "Launcher_TC_TOOL_02.Tizen"
162 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
164 return f"FAIL : Get the tpk path for {sln_name}"
166 if "OK" not in app_install(f"{tpk_path}"):
167 return f"FAIL : Install the application for {tpk_path}"
169 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_02.Tizen"
171 root_path = get_root_path(f"{pkg_id}")
172 if root_path == "None":
173 return f"FAIL : Get the root path for {pkg_id}"
175 raw = cmd(f"shell ls {root_path}/bin/.native_image")
176 if "No such file or directory" not in raw:
177 return "FAIL : The .native_image folder not should exist"
179 cmd(f"shell dotnettool --ni-pkg {pkg_id}")
181 raw = cmd(f"shell find {root_path}/bin/ -name .native_image")
182 if ".native_image" not in raw:
183 return "FAIL : The .native_image folder should exist"
185 raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
186 lines1 = [l for l in raw.splitlines()]
187 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
188 lines2 = [l for l in raw.splitlines()]
189 if len(lines1) != len(lines2):
190 return "FAIL : The number of .dll and .ni.dll must match in the application"
195 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
199 return "FAIL : The file name of .dll and .ni.dll must match in the application"
203 # The `prefer_dotnet_aot` metadata value of `true` will regenerates the native image in all .NET applications.
205 sln_name = "Launcher_TC_TOOL_03.Tizen"
207 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
209 return f"FAIL : Get the tpk path for {sln_name}"
211 if "OK" not in app_install(f"{tpk_path}"):
212 return f"FAIL : Install the application for {tpk_path}"
214 cmd(f"shell dotnettool --ni-regen-all-app")
216 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
217 lines1 = [l for l in raw.splitlines() if "appid" in l]
220 pkg_id = app.split(": ")[1]
221 raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout
222 lines2 = [l for l in raw.splitlines() if "root_path" in l]
225 root_path = path.split(": ")[1]
226 raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
227 lines3 = [l for l in raw.splitlines()]
228 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
229 lines4 = [l for l in raw.splitlines()]
230 if len(lines3) != len(lines4):
231 return "FAIL : The number of .dll and .ni.dll must match in the application"
236 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
240 return "FAIL : The file name of .dll and .ni.dll must match in the application"
244 # The `prefer_nuget_cache` metadata value of `true` will regenerates the native image in the `TAC`.
246 sln_name = "Launcher_TC_TOOL_04.Tizen"
248 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
250 return f"FAIL : Get the tpk path for {sln_name}"
252 if "OK" not in app_install(f"{tpk_path}"):
253 return f"FAIL : Install the application for {tpk_path}"
255 raw = cmd(f"shell dotnettool --tac-regen-all")
256 if ".dll (FNV)" not in raw and \
257 ".ni.dll generated successfully." not in raw:
258 return "FAIL : Create native image for TAC"
262 # The `Launcher_TC_TOOL_05` application must not have `TAC` applied.
264 sln_name = "Launcher_TC_TOOL_05.Tizen"
266 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
268 return f"FAIL : Get the tpk path for {sln_name}"
270 if "OK" not in app_install(f"{tpk_path}"):
271 return f"FAIL : Install the application for {tpk_path}"
273 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_05.Tizen"
275 root_path = get_root_path(f"{pkg_id}")
276 if root_path == "None":
277 return f"FAIL : Get the root path for {pkg_id}"
279 raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
280 if ".tac_symlink" not in raw:
281 return "FAIL : The .tac_symlink folder should exist"
283 raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
284 lines1 = [l for l in raw.splitlines()]
285 raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
286 lines2 = [l for l in raw.splitlines()]
287 if len(lines1) != len(lines2):
288 return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
290 raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
291 lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
293 origin_path = dll.split("->")[1].strip()
294 raw = cmd(f"shell ls -alZ {origin_path}")
295 if "No such file or directory" in raw:
296 return "FAIL : The original file of the symbolic link must exist"
298 cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
300 raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
301 if ".tac_symlink" in raw:
302 return "FAIL : The .tac_symlink folder should not exist"
304 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
305 lines = [l for l in raw.splitlines()]
307 return "FAIL : The number of .dll must exist correctly in the bin folder"
311 # The `Launcher_TC_TOOL_06` application must have `TAC` applied.
313 sln_name = "Launcher_TC_TOOL_06.Tizen"
315 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
317 return f"FAIL : Get the tpk path for {sln_name}"
319 if "OK" not in app_install(f"{tpk_path}"):
320 return f"FAIL : Install the application for {tpk_path}"
322 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_06.Tizen"
324 root_path = get_root_path(f"{pkg_id}")
325 if root_path == "None":
326 return f"FAIL : Get the root path for {pkg_id}"
328 cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
330 raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
331 if ".tac_symlink" in raw:
332 return "FAIL : The .tac_symlink folder should not exist"
334 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
335 lines = [l for l in raw.splitlines()]
337 return "FAIL : The number of .dll must exist correctly in the bin folder"
339 cmd(f"shell dotnettool --tac-enable-pkg {pkg_id}")
341 raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
342 if ".tac_symlink" not in raw:
343 return "FAIL : The .tac_symlink folder should exist"
345 raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
346 lines1 = [l for l in raw.splitlines()]
347 raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
348 lines2 = [l for l in raw.splitlines()]
349 if len(lines1) != len(lines2):
350 return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
352 raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
353 lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
355 origin_path = dll.split("->")[1].strip()
356 raw = cmd(f"shell ls -alZ {origin_path}")
357 if "No such file or directory" in raw:
358 return "FAIL : The original file of the symbolic link must exist"
362 # The `DB` of the restored `TAC` and `TLC` must be a valid value.
364 sln_name = "Launcher_TC_TOOL_07.Tizen"
366 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
368 return f"FAIL : Get the tpk path for {sln_name}"
370 if "OK" not in app_install(f"{tpk_path}"):
371 return f"FAIL : Install the application for {tpk_path}"
373 cmd(f"shell rm {DOTNET_DIR}.TAC.App.list.db*")
374 cmd(f"shell rm {DOTNET_DIR}.TLC.App.list.db*")
376 cmd(f"shell dotnettool --tac-restore-db")
378 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_07.Tizen"
380 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
381 lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
383 if ("SkiaSharp/2.80.2" not in rcd) and \
384 ("Xamarin.Forms/4.6.0.967" not in rcd):
385 return "FAIL : TAC database must have a valid value"
387 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
388 lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
390 if "libSkiaSharp.so..8e2fcc43f9c49b2de7b6212ff5ed914b319bc92f125715b9fe1f35786df82f98" not in rcd:
391 return "FAIL : TLC database must have a valid value"
397 #dotnettool --resolve-all-app
400 #dotnettool --ibc-dir
403 #dotnettool --instrument
406 #dotnettool --compatibility
409 #dotnettool --verbose
414 cmd(f"shell mount -o remount,rw /")
417 tpk_list = search_tpk(f"{module_name}")
419 p = run_tc_array(module_name, tc_array)
420 f = len(tc_array) - p
421 r = round(((p / len(tc_array)) * 100), 2)
422 print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
424 # Uninstall the application and restore to original state
426 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_01.Tizen")
427 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_02.Tizen")
428 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_03.Tizen")
429 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_04.Tizen")
430 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_05.Tizen")
431 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_06.Tizen")
432 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_07.Tizen")
434 cmd(f"shell rm {FRAMEWORK_DIR}Tizen.ni.dll")
438 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
439 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
440 args = parser.parse_args()
443 if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
445 for tc_num in args.TC_NUMBER:
446 if tc_num not in funcMap:
447 print(f"There is no {tc_num} test.")
450 tc_array.append(funcMap[tc_num])
452 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]
455 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
456 serial = read_serial(sys.argv[1])
458 serial = read_serial(None)
461 print("No connected device(s).")
464 device = get_device_type()
465 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
472 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04, 'TC_05': TC_05, 'TC_06': TC_06, 'TC_07': TC_07,
473 'TC_08': TC_08, 'TC_09': TC_09, 'TC_10': TC_10, 'TC_11': TC_11, 'TC_12': TC_12, 'TC_13': TC_13, 'TC_14': TC_14,
474 '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, 'TOOL_TC_07': TC_07,
475 '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, 'TOOL_TC_13': TC_13, 'TOOL_TC_14': TC_14
479 if __name__ == "__main__":
482 except KeyboardInterrupt:
483 print("\nExit (Pressed Ctrl+C)")