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"
40 if ("XSF" in preload) and (f"{FRAMEWORK_DIR}XSF." not in raw):
41 return "FAIL : The assembly of XSF.preload file should be loaded in the candidate process"
43 if (f"{FRAMEWORK_DIR}Tizen.Runtime." not in raw) or \
44 (f"{FRAMEWORK_DIR}Tizen." not in raw) or \
45 (f"{FRAMEWORK_DIR}ElmSharp." not in raw) or \
46 (f"{FRAMEWORK_DIR}Tizen.Applications.Common." not in raw) or \
47 (f"{FRAMEWORK_DIR}Tizen.Applications.UI." not in raw) or \
48 (f"{FRAMEWORK_DIR}Tizen.Log." not in raw) or \
49 (f"{FRAMEWORK_DIR}Tizen.System.Information." not in raw):
50 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
54 # All the `.dlls` in the .preload file must be loaded in the memory.
56 sln_name = "Launcher_TC_PRELOAD_02"
58 tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
60 return f"FAIL : Get the tpk path for {sln_name}"
62 if "OK" not in app_install(f"{tpk_path}"):
63 return f"FAIL : Install the application for {tpk_path}"
65 pkg_id = f"org.tizen.example.Launcher_TC_PRELOAD_02"
67 raw = prepare_candidate_process(f"dotnet-nui-loader", f"{pkg_id}")
69 return f"FAIL : Candidate process should have dotnet-nui-loader"
71 pid = raw.split(":")[1].strip()
73 raw = cmd(f"shell find {PRELOAD_DIR} -name *.preload")
74 lines = [l for l in raw.splitlines() if "XSF" not in l and "ElmSharp" not in l]
76 return "FAIL : The .preload file should exist"
78 raw = cmd(f"shell cat /proc/{pid}/smaps | grep {FRAMEWORK_DIR}")
79 if len([l for l in raw.splitlines()]) == 0:
80 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
82 if (f"{FRAMEWORK_DIR}Tizen.Runtime." not in raw) or \
83 (f"{FRAMEWORK_DIR}Tizen." not in raw) or \
84 (f"{FRAMEWORK_DIR}Tizen.Applications.Common." not in raw) or \
85 (f"{FRAMEWORK_DIR}Tizen.Applications.UI." not in raw) or \
86 (f"{FRAMEWORK_DIR}Tizen.Log." not in raw) or \
87 (f"{FRAMEWORK_DIR}Tizen.NUI." not in raw) or \
88 (f"{FRAMEWORK_DIR}Tizen.System.Information." not in raw):
89 return "FAIL : The assembly of .preload file should be loaded in the candidate process"
96 cmd(f"shell mount -o remount,rw /")
99 tpk_list = search_tpk(f"{module_name}")
101 pn = run_tc_array(module_name, tc_array)
102 n = int(pn.split(":")[0])
103 f = int(pn.split(":")[1])
104 p = int(pn.split(":")[2])
106 if (len(tc_array) - n) != 0:
107 r = round(((p / (len(tc_array) - n)) * 100), 2)
108 print(f"--- {module_name} TCT Result ---\nNONE : [{n}] / FAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
110 # Uninstall the application and restore to original state
112 cmd(f"uninstall org.tizen.example.Launcher_TC_PRELOAD_01.Tizen")
113 cmd(f"uninstall org.tizen.example.Launcher_TC_PRELOAD_02")
117 parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
118 parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
119 args = parser.parse_args()
122 if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
124 for tc_num in args.TC_NUMBER:
125 if tc_num not in funcMap:
126 print(f"There is no {tc_num} test.")
129 tc_array.append(funcMap[tc_num])
131 tc_array = [TC_01, TC_02]
134 if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
135 serial = read_serial(sys.argv[1])
137 serial = read_serial(None)
140 print("No connected device(s).")
143 device = get_device_type()
144 print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
151 'TC_01': TC_01, 'TC_02': TC_02,
152 'PRELOAD_TC_01': TC_01, 'PRELOAD_TC_02': TC_02
156 if __name__ == "__main__":
159 except KeyboardInterrupt:
160 print("\nExit (Pressed Ctrl+C)")