2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
6 from pathlib import Path
12 # The `dotnettool` works normally.
14 if not exist("/usr/bin/dotnettool")
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 if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
28 return "FAIL : Create the platform native image"
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"
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"
47 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
51 return "FAIL : The file name of .dll and .ni.dll must match in the platform"
55 # Remove the `platform` native image.
57 cmd(f"shell dotnettool --ni-reset-system")
59 if exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
60 return "FAIL : Remove the platform native image"
64 # Create native image for `System.Private.CoreLib.dll`.
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}")
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}"
75 if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
76 return f"FAIL : Create native image for {SPC_DLL}"
80 # The file name of `.dll` and `.ni.dll` must match in the framework.
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"
93 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
97 return "FAIL : The file name of .dll and .ni.dll must match in the {FRAMEWORK_DIR}"
101 # The `.ni.dll` files should not exist in the framework.
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()]
107 return "FAIL : The .ni.dll files should not exist"
111 # Create native image for Tizen.dll in `R2R` mode.
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"
120 # Displays detailed information while creating native image for Tizen.Log.dll.
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"
130 # Create a native image for netstandard.dll by specifying the directory containing the IBC files.
132 current_path = os.path.abspath(__file__)
133 packaging_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../packaging"))
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"
143 ibcdata_zip = "ibcdata_aarch64.zip"
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")
149 if not exist(f"{IBCDATA_DIR}netstandard.ibc"):
150 return "FAIL : The netstandard.ibc file should exist"
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"
159 # The `Launcher_TC_TOOL_01` application does not have native image.
161 sln_name = "Launcher_TC_TOOL_01.Tizen"
163 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
165 return f"FAIL : Get the tpk path for {sln_name}"
167 if "OK" not in app_install(f"{tpk_path}"):
168 return f"FAIL : Install the application for {tpk_path}"
170 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_01.Tizen"
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}"
176 if not exist(f"{root_path}/bin/.native_image"):
177 return "FAIL : The .native_image folder should exist"
179 cmd(f"shell dotnettool --ni-reset-pkg {pkg_id}")
181 if exist(f"{root_path}/bin/.native_image"):
182 return "FAIL : The .native_image folder should not exist"
184 raw = cmd(f"shell find {root_path}/bin/ -name *.ni.dll")
185 lines = [l for l in raw.splitlines()]
187 return "FAIL : The .ni.dll files should not exist"
191 # The `Launcher_TC_TOOL_02` application generates native image.
193 sln_name = "Launcher_TC_TOOL_02.Tizen"
195 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
197 return f"FAIL : Get the tpk path for {sln_name}"
199 if "OK" not in app_install(f"{tpk_path}"):
200 return f"FAIL : Install the application for {tpk_path}"
202 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_02.Tizen"
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}"
208 if exist(f"{root_path}/bin/.native_image"):
209 return "FAIL : The .native_image folder not should exist"
211 cmd(f"shell dotnettool --ni-pkg {pkg_id}")
213 if not exist(f"{root_path}/bin/.native_image"):
214 return "FAIL : The .native_image folder should exist"
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"
226 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
230 return "FAIL : The file name of .dll and .ni.dll must match in the application"
234 # The `prefer_dotnet_aot` metadata value of `true` will regenerates the native image in all .NET applications.
236 sln_name = "Launcher_TC_TOOL_03.Tizen"
238 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
240 return f"FAIL : Get the tpk path for {sln_name}"
242 if "OK" not in app_install(f"{tpk_path}"):
243 return f"FAIL : Install the application for {tpk_path}"
245 cmd(f"shell dotnettool --ni-regen-all-app")
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 lines1 = [l for l in raw.splitlines() if "appid" in l]
251 pkg_id = app.split(": ")[1]
252 raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout
253 lines2 = [l for l in raw.splitlines() if "root_path" in l]
256 root_path = path.split(": ")[1]
257 raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
258 lines3 = [l for l in raw.splitlines()]
259 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
260 lines4 = [l for l in raw.splitlines()]
261 if len(lines3) != len(lines4):
262 return "FAIL : The number of .dll and .ni.dll must match in the application"
267 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
271 return "FAIL : The file name of .dll and .ni.dll must match in the application"
275 # The `prefer_nuget_cache` metadata value of `true` will regenerates the native image in the `TAC`.
277 sln_name = "Launcher_TC_TOOL_04.Tizen"
279 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
281 return f"FAIL : Get the tpk path for {sln_name}"
283 if "OK" not in app_install(f"{tpk_path}"):
284 return f"FAIL : Install the application for {tpk_path}"
286 raw = cmd(f"shell dotnettool --tac-regen-all")
287 if ".dll (FNV)" not in raw and \
288 ".ni.dll generated successfully." not in raw:
289 return "FAIL : Create native image for TAC"
293 # The `Launcher_TC_TOOL_05` application must not have `TAC` applied.
295 sln_name = "Launcher_TC_TOOL_05.Tizen"
297 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
299 return f"FAIL : Get the tpk path for {sln_name}"
301 if "OK" not in app_install(f"{tpk_path}"):
302 return f"FAIL : Install the application for {tpk_path}"
304 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_05.Tizen"
306 root_path = get_root_path(f"{pkg_id}")
307 if root_path == "None":
308 return f"FAIL : Get the root path for {pkg_id}"
310 if not exist(f"{root_path}/bin/.tac_symlink"):
311 return "FAIL : The .tac_symlink folder should exist"
313 raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
314 lines1 = [l for l in raw.splitlines()]
315 raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
316 lines2 = [l for l in raw.splitlines()]
317 if len(lines1) != len(lines2):
318 return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
320 raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
321 lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
323 origin_path = dll.split("->")[1].strip()
324 if not exist(f"{origin_path}"):
325 return "FAIL : The original file of the symbolic link must exist"
327 cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
329 if exist(f"{root_path}/bin/.tac_symlink"):
330 return "FAIL : The .tac_symlink folder should not exist"
332 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
333 lines = [l for l in raw.splitlines()]
335 return "FAIL : The number of .dll must exist correctly in the bin folder"
339 # The `Launcher_TC_TOOL_06` application must have `TAC` applied.
341 sln_name = "Launcher_TC_TOOL_06.Tizen"
343 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
345 return f"FAIL : Get the tpk path for {sln_name}"
347 if "OK" not in app_install(f"{tpk_path}"):
348 return f"FAIL : Install the application for {tpk_path}"
350 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_06.Tizen"
352 root_path = get_root_path(f"{pkg_id}")
353 if root_path == "None":
354 return f"FAIL : Get the root path for {pkg_id}"
356 cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
358 if exist(f"{root_path}/bin/.tac_symlink"):
359 return "FAIL : The .tac_symlink folder should not exist"
361 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
362 lines = [l for l in raw.splitlines()]
364 return "FAIL : The number of .dll must exist correctly in the bin folder"
366 cmd(f"shell dotnettool --tac-enable-pkg {pkg_id}")
368 if not exist(f"{root_path}/bin/.tac_symlink"):
369 return "FAIL : The .tac_symlink folder should exist"
371 raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
372 lines1 = [l for l in raw.splitlines()]
373 raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
374 lines2 = [l for l in raw.splitlines()]
375 if len(lines1) != len(lines2):
376 return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
378 raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
379 lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
381 origin_path = dll.split("->")[1].strip()
382 if not exist(f"{origin_path}"):
383 return "FAIL : The original file of the symbolic link must exist"
387 # The `DB` of the restored `TAC` and `TLC` must be a valid value.
389 sln_name = "Launcher_TC_TOOL_07.Tizen"
391 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
393 return f"FAIL : Get the tpk path for {sln_name}"
395 if "OK" not in app_install(f"{tpk_path}"):
396 return f"FAIL : Install the application for {tpk_path}"
398 cmd(f"shell rm {DOTNET_DIR}.TAC.App.list.db*")
399 cmd(f"shell rm {DOTNET_DIR}.TLC.App.list.db*")
401 cmd(f"shell dotnettool --tac-restore-db")
403 pkg_id = f"org.tizen.example.Launcher_TC_TOOL_07.Tizen"
405 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
406 lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
408 if ("SkiaSharp/2.80.2" not in rcd) and \
409 ("Xamarin.Forms/4.6.0.967" not in rcd):
410 return "FAIL : TAC database must have a valid value"
412 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
413 lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
415 if "libSkiaSharp.so..8e2fcc43f9c49b2de7b6212ff5ed914b319bc92f125715b9fe1f35786df82f98" not in rcd:
416 return "FAIL : TLC database must have a valid value"
422 #dotnettool --resolve-all-app
425 #dotnettool --instrument
428 #dotnettool --compatibility
434 cmd(f"shell mount -o remount,rw /")
437 tpk_list = search_tpk(f"{module_name}")
439 p = run_tc_array(module_name, tc_array)
440 f = len(tc_array) - p
441 r = round(((p / len(tc_array)) * 100), 2)
442 print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
444 # Uninstall the application and restore to original state
446 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_01.Tizen")
447 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_02.Tizen")
448 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_03.Tizen")
449 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_04.Tizen")
450 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_05.Tizen")
451 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_06.Tizen")
452 cmd(f"uninstall org.tizen.example.Launcher_TC_TOOL_07.Tizen")
454 cmd(f"shell rm {FRAMEWORK_DIR}Tizen.ni.dll")
455 cmd(f"shell rm {FRAMEWORK_DIR}Tizen.Log.ni.dll")
456 cmd(f"shell rm {RUNTIME_DIR}netstandard.ni.dll")
458 cmd(f"shell rm -rf {IBCDATA_DIR}")
462 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
463 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
464 args = parser.parse_args()
467 if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
469 for tc_num in args.TC_NUMBER:
470 if tc_num not in funcMap:
471 print(f"There is no {tc_num} test.")
474 tc_array.append(funcMap[tc_num])
476 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]
479 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
480 serial = read_serial(sys.argv[1])
482 serial = read_serial(None)
485 print("No connected device(s).")
488 device = get_device_type()
489 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
496 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04, 'TC_05': TC_05,
497 'TC_06': TC_06, 'TC_07': TC_07, 'TC_08': TC_08, 'TC_09': TC_09, 'TC_10': TC_10,
498 'TC_11': TC_11, 'TC_12': TC_12, 'TC_13': TC_13, 'TC_14': TC_14, 'TC_15': TC_15, 'TC_16': TC_16,
499 '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,
500 'TOOL_TC_06': TC_06, 'TOOL_TC_07': TC_07, 'TOOL_TC_08': TC_08, 'TOOL_TC_09': TC_09, 'TOOL_TC_10': TC_10,
501 'TOOL_TC_11': TC_11, 'TOOL_TC_12': TC_12, 'TOOL_TC_13': TC_13, 'TOOL_TC_14': TC_14, 'TOOL_TC_15': TC_15, 'TOOL_TC_16': TC_16
505 if __name__ == "__main__":
508 except KeyboardInterrupt:
509 print("\nExit (Pressed Ctrl+C)")