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 `Launcher_TC_AOT_01` application does not generate native image.
14 if "OK" not in create_spc_ni():
15 return f"FAIL : Create native image for {SPC_DLL}"
17 sln_name = "Launcher_TC_AOT_01.Tizen"
19 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
21 return f"FAIL : Get the tpk path for {sln_name}"
23 if "OK" not in app_install(f"{tpk_path}"):
24 return f"FAIL : Install the application for {tpk_path}"
26 pkg_id = "org.tizen.example.Launcher_TC_AOT_01.Tizen"
28 root_path = get_root_path(f"{pkg_id}")
29 if root_path == "None":
30 return f"FAIL : Get the root path for {pkg_id}"
32 if exist(f"{root_path}/bin/.native_image"):
33 return "FAIL : The .native_image folder should not exist"
35 raw = cmd(f"shell find {root_path}/bin/ -name *.ni.dll")
36 lines = [l for l in raw.splitlines()]
38 return "FAIL : The .ni.dll files should not exist"
42 # The `Launcher_TC_AOT_02` application generates native image when the SPC.ni.dll exists.
44 if "OK" not in create_spc_ni():
45 return f"FAIL : Create native image for {SPC_DLL}"
47 sln_name = "Launcher_TC_AOT_02.Tizen"
49 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
51 return f"FAIL : Get the tpk path for {sln_name}"
53 if "OK" not in app_install(f"{tpk_path}"):
54 return f"FAIL : Install the application for {tpk_path}"
56 pkg_id = "org.tizen.example.Launcher_TC_AOT_02.Tizen"
58 root_path = get_root_path(f"{pkg_id}")
59 if root_path == "None":
60 return f"FAIL : Get the root path for {pkg_id}"
62 if not exist(f"{root_path}/bin/.native_image"):
63 return "FAIL : The .native_image folder should exist"
65 raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
66 lines1 = [l for l in raw.splitlines()]
67 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
68 lines2 = [l for l in raw.splitlines()]
69 if len(lines1) != len(lines2):
70 return "FAIL : The number of .dll and .ni.dll must match in the application"
75 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
79 return "FAIL : The file name of .dll and .ni.dll must match in the application"
83 # The `Launcher_TC_AOT_03` application generates native image when the SPC.ni.dll doesn't exist.
85 if "OK" not in remove_system_ni():
86 return "FAIL : Remove the platform native image"
88 sln_name = "Launcher_TC_AOT_03.Tizen"
90 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
92 return f"FAIL : Get the tpk path for {sln_name}"
94 if "OK" not in app_install(f"{tpk_path}"):
95 return f"FAIL : Install the application for {tpk_path}"
97 pkg_id = "org.tizen.example.Launcher_TC_AOT_03.Tizen"
99 root_path = get_root_path(f"{pkg_id}")
100 if root_path == "None":
101 return f"FAIL : Get the root path for {pkg_id}"
103 if not exist(f"{root_path}/bin/.native_image"):
104 return "FAIL : The .native_image folder should exist"
106 raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
107 lines1 = [l for l in raw.splitlines()]
108 raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
109 lines2 = [l for l in raw.splitlines()]
110 if len(lines1) != len(lines2):
111 return "FAIL : The number of .dll and .ni.dll must match in the application"
116 if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""):
120 return "FAIL : The file name of .dll and .ni.dll must match in the application"
127 cmd(f"shell mount -o remount,rw /")
130 tpk_list = search_tpk(f"{module_name}")
132 pn = run_tc_array(module_name, tc_array)
133 n = int(pn.split(":")[0])
134 f = int(pn.split(":")[1])
135 p = int(pn.split(":")[2])
137 if (len(tc_array) - n) != 0:
138 r = round(((p / (len(tc_array) - n)) * 100), 2)
139 print(f"--- {module_name} TCT Result ---\nNONE : [{n}] / FAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
141 # Uninstall the application and restore to original state
143 cmd(f"uninstall org.tizen.example.Launcher_TC_AOT_01.Tizen")
144 cmd(f"uninstall org.tizen.example.Launcher_TC_AOT_02.Tizen")
145 cmd(f"uninstall org.tizen.example.Launcher_TC_AOT_03.Tizen")
151 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
152 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
153 args = parser.parse_args()
156 if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
158 for tc_num in args.TC_NUMBER:
159 if tc_num not in funcMap:
160 print(f"There is no {tc_num} test.")
163 tc_array.append(funcMap[tc_num])
165 tc_array = [TC_01, TC_02, TC_03]
168 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
169 serial = read_serial(sys.argv[1])
171 serial = read_serial(None)
174 print("No connected device(s).")
177 device = get_device_type()
178 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
185 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03,
186 'AOT_TC_01': TC_01, 'AOT_TC_02': TC_02, 'AOT_TC_03': TC_03
190 if __name__ == "__main__":
193 except KeyboardInterrupt:
194 print("\nExit (Pressed Ctrl+C)")