2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
11 # The `Launcher_TC_LAUNCH_01` application should run in `candidate(dotnet-loader)` mode.
13 sln_name = "Launcher_TC_LAUNCH_01.Tizen"
15 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
17 return f"FAIL : Get the tpk path for {sln_name}"
19 if "OK" not in app_install(f"{tpk_path}"):
20 return f"FAIL : Install the application for {tpk_path}"
22 pkg_id = "org.tizen.example.Launcher_TC_LAUNCH_01.Tizen"
24 root_path = get_root_path(f"{pkg_id}")
25 if root_path == "None":
26 return f"FAIL : Get the root path for {pkg_id}"
28 if "OK" not in prepare_candidate_process(f"dotnet-loader", f"{pkg_id}"):
29 return f"FAIL : Candidate process should have dotnet-loader"
31 pid = launch_and_get_pid(f"-s", f"{pkg_id}")
33 return f"FAIL : Get the pid for {pkg_id}"
35 raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_LAUNCH_01.Tizen")
36 if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw:
37 return "FAIL : The application is run as a candidate mode."
39 cmd(f"shell app_launcher -t {pkg_id}")
43 # The `Launcher_TC_LAUNCH_01` application should run in `standalone(dotnet-launcher)` mode.
45 sln_name = "Launcher_TC_LAUNCH_01.Tizen"
47 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
49 return f"FAIL : Get the tpk path for {sln_name}"
51 if "OK" not in app_install(f"{tpk_path}"):
52 return f"FAIL : Install the application for {tpk_path}"
54 pkg_id = "org.tizen.example.Launcher_TC_LAUNCH_01.Tizen"
56 root_path = get_root_path(f"{pkg_id}")
57 if root_path == "None":
58 return f"FAIL : Get the root path for {pkg_id}"
60 pid = launch_and_get_pid(f"-e", f"{pkg_id}")
62 return f"FAIL : Get the pid for {pkg_id}"
64 raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_LAUNCH_01.Tizen")
65 if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw:
66 return "FAIL : The application is run as a standalone mode"
68 cmd(f"shell app_launcher -t {pkg_id}")
72 # The `Launcher_TC_LAUNCH_02` application should run in `candidate(dotnet-nui-loader)` mode.
74 sln_name = "Launcher_TC_LAUNCH_02"
76 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
78 return f"FAIL : Get the tpk path for {sln_name}"
80 if "OK" not in app_install(f"{tpk_path}"):
81 return f"FAIL : Install the application for {tpk_path}"
83 pkg_id = "org.tizen.example.Launcher_TC_LAUNCH_02"
85 root_path = get_root_path(f"{pkg_id}")
86 if root_path == "None":
87 return f"FAIL : Get the root path for {pkg_id}"
89 if "OK" not in prepare_candidate_process(f"dotnet-nui-loader", f"{pkg_id}"):
90 return f"FAIL : Candidate process should have dotnet-nui-loader"
92 pid = launch_and_get_pid(f"-s", f"{pkg_id}")
94 return f"FAIL : Get the pid for {pkg_id}"
96 raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_LAUNCH_02")
97 if f"{root_path}/bin/Launcher_TC_LAUNCH_02.dll" not in raw:
98 return "FAIL : The application is run as a candidate mode"
100 cmd(f"shell app_launcher -t {pkg_id}")
104 # The `Launcher_TC_LAUNCH_03` application should run in `hydra(dotnet-hydra-loader)` mode.
106 sln_name = "Launcher_TC_LAUNCH_03.Tizen"
108 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
110 return f"FAIL : Get the tpk path for {sln_name}"
112 if "OK" not in app_install(f"{tpk_path}"):
113 return f"FAIL : Install the application for {tpk_path}"
115 pkg_id = "org.tizen.example.Launcher_TC_LAUNCH_03.Tizen"
117 root_path = get_root_path(f"{pkg_id}")
118 if root_path == "None":
119 return f"FAIL : Get the root path for {pkg_id}"
121 raw = cmd(f"pull /usr/share/aul/dotnet.loader dotnet.loader.origin")
122 if "1 file(s) pulled. 0 file(s) skipped." not in raw:
123 return "FAIL : Pull the dotnet.loader file from the target"
125 f1 = open("./dotnet.loader", "w")
126 f2 = open("./dotnet.loader.origin", "r")
129 if line.startswith("EXE "):
130 f1.write(line.replace("EXE", "#EXE"))
131 elif line.startswith("#EXE "):
132 f1.write(line.replace("#EXE", "EXE"))
133 elif line.startswith("HYDRA "):
134 f1.write(line.replace("OFF", "ON"))
140 raw = cmd(f"push dotnet.loader /usr/share/aul/")
141 if "1 file(s) pushed. 0 file(s) skipped." not in raw:
142 return "FAIL : Push the dotnet.loader file to the target"
144 cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader")
145 cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader")
147 cmd(f"shell reboot -f")
151 subprocess.run((f"sdb connect {serial}").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout
154 cmd(f"shell mount -o remount,rw /")
156 if "OK" not in prepare_candidate_process(f"dotnet-loader", f"{pkg_id}"):
157 return f"FAIL : Candidate process should have dotnet-loader"
159 raw = cmd(f"shell ps -ef | grep dotnet-hydra-loader")
160 if "/usr/bin/dotnet-hydra-loader" not in raw:
161 return "FAIL : Candidate process should have dotnet-hydra-loader"
163 pid = launch_and_get_pid(f"-s", f"{pkg_id}")
165 return f"FAIL : Get the pid for {pkg_id}"
167 raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_LAUNCH_03.Tizen")
168 if f"{root_path}/bin/Launcher_TC_LAUNCH_03.Tizen.dll" not in raw:
169 return "FAIL : The application is run as a candidate mode"
171 cmd(f"shell app_launcher -t {pkg_id}")
178 cmd(f"shell mount -o remount,rw /")
181 tpk_list = search_tpk(f"{module_name}")
183 pn = run_tc_array(module_name, tc_array)
184 n = int(pn.split(":")[0])
185 f = int(pn.split(":")[1])
186 p = int(pn.split(":")[2])
188 if (len(tc_array) - n) != 0:
189 r = round(((p / (len(tc_array) - n)) * 100), 2)
190 print(f"--- {module_name} TCT Result ---\nNONE : [{n}] / FAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
192 # Uninstall the application and restore to original state
194 cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_01.Tizen")
195 cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_02")
196 cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_03.Tizen")
199 if f"{tc.__name__}" == "TC_04":
200 cmd(f"shell mount -o remount,rw /")
201 cmd(f"push dotnet.loader.origin /usr/share/aul/dotnet.loader")
202 cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader")
203 cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader")
204 cmd(f"shell reboot -f")
206 subprocess.run((f"rm dotnet.loader").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout
207 subprocess.run((f"rm dotnet.loader.origin").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout
211 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
212 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
213 args = parser.parse_args()
216 if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
218 for tc_num in args.TC_NUMBER:
219 if tc_num not in funcMap:
220 print(f"There is no {tc_num} test.")
223 tc_array.append(funcMap[tc_num])
225 tc_array = [TC_01, TC_02, TC_03, TC_04]
228 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
229 serial = read_serial(sys.argv[1])
231 serial = read_serial(None)
234 print("No connected device(s).")
237 device = get_device_type()
238 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
245 'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04,
246 'LAUNCH_TC_01': TC_01, 'LAUNCH_TC_02': TC_02, 'LAUNCH_TC_03': TC_03, 'LAUNCH_TC_04': TC_04
250 if __name__ == "__main__":
253 except KeyboardInterrupt:
254 print("\nExit (Pressed Ctrl+C)")