--- /dev/null
+#!/usr/bin/env python3
+import os, subprocess, sys, argparse
+sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
+
+from time import sleep
+from Utils import *
+
+
+module_name = "EXCEPTION"
+
+# The `Launcher_TC_EXCEPTION_01` application(apptype : dotnet) should run in `candidate(dotnet-loader)` mode.
+def TC_01():
+ sln_name = "Launcher_TC_EXCEPTION_01"
+
+ tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
+ if tpk_path == None:
+ return f"FAIL : Get the tpk path for {sln_name}"
+
+ if "OK" not in app_install(f"{tpk_path}"):
+ return f"FAIL : Install the application for {tpk_path}"
+
+ pkg_id = "org.tizen.example.Launcher_TC_EXCEPTION_01"
+
+ root_path = get_root_path(f"{pkg_id}")
+ if root_path == "None":
+ return f"FAIL : Get the root path for {pkg_id}"
+
+ if "OK" not in prepare_candidate_process(f"dotnet-loader", f"{pkg_id}"):
+ return f"FAIL : Candidate process should have dotnet-loader"
+
+ pid = launch_and_get_pid(f"-s", f"{pkg_id}")
+ if 0 == pid:
+ return f"FAIL : Get the pid for {pkg_id}"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_EXCEPTION_01")
+ if f"{root_path}/bin/Launcher_TC_EXCEPTION_01.dll" not in raw:
+ return "FAIL : The application is run as a candidate mode."
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep dotnet-loader")
+ if f"/usr/bin/dotnet-loader" not in raw:
+ return "FAIL : The application is run as a candidate mode."
+
+ raw = cmd(f"shell dlogutil STDOUT | grep {pid} &")
+ lines = [l for l in raw.splitlines() if "System.NullReferenceException:" in l]
+ for log in lines:
+ if "System.NullReferenceException: Object reference not set to an instance of an object." not in log:
+ return "FAIL : The application can use the try/catch block to catch the NullReferenceException."
+
+ cmd(f"shell app_launcher -t {pkg_id}")
+
+ return "PASS"
+
+# The `Launcher_TC_EXCEPTION_01` application(apptype : dotnet) should run in `standalone(dotnet-launcher)` mode.
+def TC_02():
+ sln_name = "Launcher_TC_EXCEPTION_01"
+
+ tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
+ if tpk_path == None:
+ return f"FAIL : Get the tpk path for {sln_name}"
+
+ if "OK" not in app_install(f"{tpk_path}"):
+ return f"FAIL : Install the application for {tpk_path}"
+
+ pkg_id = "org.tizen.example.Launcher_TC_EXCEPTION_01"
+
+ root_path = get_root_path(f"{pkg_id}")
+ if root_path == "None":
+ return f"FAIL : Get the root path for {pkg_id}"
+
+ pid = launch_and_get_pid(f"-e", f"{pkg_id}")
+ if 0 == pid:
+ return f"FAIL : Get the pid for {pkg_id}"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_EXCEPTION_01")
+ if f"{root_path}/bin/Launcher_TC_EXCEPTION_01.dll" not in raw:
+ return "FAIL : The application is run as a standalone mode"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep dotnet-launcher")
+ if f"/usr/bin/dotnet-launcher" not in raw:
+ return "FAIL : The application is run as a standalone mode."
+
+ raw = cmd(f"shell dlogutil STDOUT | grep {pid} &")
+ lines = [l for l in raw.splitlines() if "System.NullReferenceException:" in l]
+ for log in lines:
+ if "System.NullReferenceException: Object reference not set to an instance of an object." not in log:
+ return "FAIL : The application can use the try/catch block to catch the NullReferenceException."
+
+ cmd(f"shell app_launcher -t {pkg_id}")
+
+ return "PASS"
+
+# The `Launcher_TC_EXCEPTION_02` application(apptype : dotnet-nui) should run in `candidate(dotnet-loader/dotnet-nui-loader)` mode.
+def TC_03():
+ sln_name = "Launcher_TC_EXCEPTION_02"
+
+ tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
+ if tpk_path == None:
+ return f"FAIL : Get the tpk path for {sln_name}"
+
+ if "OK" not in app_install(f"{tpk_path}"):
+ return f"FAIL : Install the application for {tpk_path}"
+
+ pkg_id = "org.tizen.example.Launcher_TC_EXCEPTION_02"
+
+ root_path = get_root_path(f"{pkg_id}")
+ if root_path == "None":
+ return f"FAIL : Get the root path for {pkg_id}"
+
+ loader = "dotnet-nui-loader"
+ if "NOT FOUND" in prepare_candidate_process(f"{loader}", f"{pkg_id}"):
+ loader = "dotnet-loader"
+ if "OK" not in prepare_candidate_process(f"{loader}", f"{pkg_id}"):
+ return f"FAIL : Candidate process should have {loader}"
+ elif "FAIL" not in prepare_candidate_process(f"{loader}", f"{pkg_id}"):
+ return f"FAIL : Candidate process should have {loader}"
+
+ pid = launch_and_get_pid(f"-s", f"{pkg_id}")
+ if 0 == pid:
+ return f"FAIL : Get the pid for {pkg_id}"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_EXCEPTION_02")
+ if f"{root_path}/bin/Launcher_TC_EXCEPTION_02.dll" not in raw:
+ return "FAIL : The application is run as a candidate mode"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep {loader}")
+ if f"/usr/bin/{loader}" not in raw:
+ return "FAIL : The application is run as a candidate mode."
+
+ raw = cmd(f"shell dlogutil STDOUT | grep {pid} &")
+ lines = [l for l in raw.splitlines() if "System.NullReferenceException:" in l]
+ for log in lines:
+ if "System.NullReferenceException: Object reference not set to an instance of an object." not in log:
+ return "FAIL : The application can use the try/catch block to catch the NullReferenceException."
+
+ cmd(f"shell app_launcher -t {pkg_id}")
+
+ return "PASS"
+
+# The `Launcher_TC_EXCEPTION_02` application(apptype : dotnet-nui) should run in `standalone(dotnet-launcher)` mode.
+def TC_04():
+ sln_name = "Launcher_TC_EXCEPTION_02"
+
+ tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
+ if tpk_path == None:
+ return f"FAIL : Get the tpk path for {sln_name}"
+
+ if "OK" not in app_install(f"{tpk_path}"):
+ return f"FAIL : Install the application for {tpk_path}"
+
+ pkg_id = "org.tizen.example.Launcher_TC_EXCEPTION_02"
+
+ root_path = get_root_path(f"{pkg_id}")
+ if root_path == "None":
+ return f"FAIL : Get the root path for {pkg_id}"
+
+ pid = launch_and_get_pid(f"-e", f"{pkg_id}")
+ if 0 == pid:
+ return f"FAIL : Get the pid for {pkg_id}"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep Launcher_TC_EXCEPTION_02")
+ if f"{root_path}/bin/Launcher_TC_EXCEPTION_02.dll" not in raw:
+ return "FAIL : The application is run as a standalone mode"
+
+ raw = cmd(f"shell cat /proc/{pid}/smaps | grep dotnet-launcher")
+ if f"/usr/bin/dotnet-launcher" not in raw:
+ return "FAIL : The application is run as a standalone mode."
+
+ raw = cmd(f"shell dlogutil STDOUT | grep {pid} &")
+ lines = [l for l in raw.splitlines() if "System.NullReferenceException:" in l]
+ for log in lines:
+ if "System.NullReferenceException: Object reference not set to an instance of an object." not in log:
+ return "FAIL : The application can use the try/catch block to catch the NullReferenceException."
+
+ cmd(f"shell app_launcher -t {pkg_id}")
+
+ return "PASS"
+
+# Run the test
+def run():
+ cmd(f"root on")
+ cmd(f"shell mount -o remount,rw /")
+
+ global tpk_list
+ tpk_list = search_tpk(f"{module_name}")
+
+ pn = run_tc_array(module_name, tc_array)
+ n = int(pn.split(":")[0])
+ f = int(pn.split(":")[1])
+ p = int(pn.split(":")[2])
+ r = 0.0
+ if (len(tc_array) - n) != 0:
+ r = round(((p / (len(tc_array) - n)) * 100), 2)
+ print(f"--- {module_name} TCT Result ---\nNONE : [{n}] / FAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
+
+ with open(f"{RESULT_PATH}", "a+") as file:
+ file.write(f"| {module_name} | {p} | {f} | {n} | {r} |\n")
+
+# Uninstall the application and restore to original state
+def clean():
+ cmd(f"uninstall org.tizen.example.Launcher_TC_EXCEPTION_01")
+ cmd(f"uninstall org.tizen.example.Launcher_TC_EXCEPTION_02")
+
+# Main entry point
+def main():
+ parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
+ parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual execution")
+ args = parser.parse_args()
+
+ global tc_array
+ if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
+ tc_array = []
+ for tc_num in args.TC_NUMBER:
+ if tc_num not in funcMap:
+ print(f"There is no {tc_num} test.")
+ exit(1)
+ else:
+ tc_array.append(funcMap[tc_num])
+ else:
+ tc_array = [TC_01, TC_02, TC_03, TC_04]
+ #skip TC_03(dotnet-nui-loader)
+
+ global serial
+ if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
+ serial = read_serial(sys.argv[1])
+ else:
+ serial = read_serial(None)
+
+ if serial is None:
+ print("No connected device(s).")
+ exit(1)
+
+ device = get_device_type()
+ print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
+
+ run()
+ clean()
+
+
+funcMap = {
+'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04,
+'EXCEPTION_TC_01': TC_01, 'EXCEPTION_TC_02': TC_02, 'EXCEPTION_TC_03': TC_03, 'EXCEPTION_TC_04': TC_04
+}
+
+
+if __name__ == "__main__":
+ try:
+ main()
+ except KeyboardInterrupt:
+ print("\nExit (Pressed Ctrl+C)")
+ exit(1)