2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
9 module_name = "PRELOAD"
11 # All the `.dlls` in the .preload file must be loaded in the memory.
13 sln_name = "Launcher_TC_PRELOAD_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 = f"org.tizen.example.Launcher_TC_PRELOAD_01.Tizen"
24 raw = prepare_candidate_process(f"dotnet-loader", f"{pkg_id}")
26 return f"FAIL : Candidate process should have dotnet-loader"
28 pid = raw.split(":")[1].strip()
30 raw = cmd(f"shell find {PRELOAD_DIR} -name *.preload")
31 lines = [l for l in raw.splitlines() if "NUI" not in l]
33 return "FAIL : The .preload file should exist"
35 raw = cmd(f"shell cat /proc/{pid}/smaps | grep {FRAMEWORK_DIR}")
36 if len([l for l in raw.splitlines()]) == 0:
37 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
39 if (f"{FRAMEWORK_DIR}Tizen.Runtime." not in raw) or \
40 (f"{FRAMEWORK_DIR}Tizen." not in raw) or \
41 (f"{FRAMEWORK_DIR}ElmSharp." not in raw) or \
42 (f"{FRAMEWORK_DIR}Tizen.Applications.Common." not in raw) or \
43 (f"{FRAMEWORK_DIR}Tizen.Applications.UI." not in raw) or \
44 (f"{FRAMEWORK_DIR}Tizen.Log." not in raw) or \
45 (f"{FRAMEWORK_DIR}Tizen.System.Information." not in raw) or \
46 (f"{FRAMEWORK_DIR}XSF." not in raw):
47 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
51 # All the `.dlls` in the .preload file must be loaded in the memory.
53 sln_name = "Launcher_TC_PRELOAD_02"
55 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
57 return f"FAIL : Get the tpk path for {sln_name}"
59 if "OK" not in app_install(f"{tpk_path}"):
60 return f"FAIL : Install the application for {tpk_path}"
62 pkg_id = f"org.tizen.example.Launcher_TC_PRELOAD_02"
64 raw = prepare_candidate_process(f"dotnet-nui-loader", f"{pkg_id}")
66 return f"FAIL : Candidate process should have dotnet-nui-loader"
68 pid = raw.split(":")[1].strip()
70 raw = cmd(f"shell find {PRELOAD_DIR} -name *.preload")
71 lines = [l for l in raw.splitlines() if "XSF" not in l and "ElmSharp" not in l]
73 return "FAIL : The .preload file should exist"
75 raw = cmd(f"shell cat /proc/{pid}/smaps | grep {FRAMEWORK_DIR}")
76 if len([l for l in raw.splitlines()]) == 0:
77 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
79 if (f"{FRAMEWORK_DIR}Tizen.Runtime." not in raw) or \
80 (f"{FRAMEWORK_DIR}Tizen." not in raw) or \
81 (f"{FRAMEWORK_DIR}Tizen.Applications.Common." not in raw) or \
82 (f"{FRAMEWORK_DIR}Tizen.Applications.UI." not in raw) or \
83 (f"{FRAMEWORK_DIR}Tizen.Log." not in raw) or \
84 (f"{FRAMEWORK_DIR}Tizen.NUI." not in raw) or \
85 (f"{FRAMEWORK_DIR}Tizen.System.Information." not in raw):
86 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
93 cmd(f"shell mount -o remount,rw /")
96 tpk_list = search_tpk(f"{module_name}")
98 p = run_tc_array(module_name, tc_array)
100 r = round(((p / len(tc_array)) * 100), 2)
101 print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
103 # Uninstall the application and restore to original state
105 cmd(f"uninstall org.tizen.example.Launcher_TC_PRELOAD_01.Tizen")
106 cmd(f"uninstall org.tizen.example.Launcher_TC_PRELOAD_02")
110 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
111 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
112 args = parser.parse_args()
115 if "TC_" in args.TC_NUMBER[0]:
117 for tc_num in args.TC_NUMBER:
118 if tc_num not in funcMap:
119 print(f"There is no {tc_num} test.")
122 tc_array.append(funcMap[tc_num])
124 tc_array = [TC_01, TC_02]
127 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
128 serial = read_serial(sys.argv[1])
130 serial = read_serial(None)
133 print("No connected device(s).")
136 device = get_device_type()
137 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
144 'TC_01': TC_01, 'TC_02': TC_02,
145 'PRELOAD_TC_01': TC_01, 'PRELOAD_TC_02': TC_02
149 if __name__ == "__main__":
152 except KeyboardInterrupt:
153 print("\nExit (Pressed Ctrl+C)")