From: j-h.choi Date: Mon, 10 Jun 2024 02:40:34 +0000 (+0900) Subject: Chaanged the TC order of LAUNCH and EXCEPTION X-Git-Tag: accepted/tizen/unified/x/20240702.121010~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da06a7b2045f0855bd61e73f586274c54a755cee;p=platform%2Fcore%2Fdotnet%2Flauncher.git Chaanged the TC order of LAUNCH and EXCEPTION Change-Id: I5f314b1891e29f74e754fdb214beec5326313337 --- diff --git a/tests/TCs/7_EXCEPTION/EXCEPTION.py b/tests/TCs/7_EXCEPTION/EXCEPTION.py new file mode 100755 index 0000000..58cd8b1 --- /dev/null +++ b/tests/TCs/7_EXCEPTION/EXCEPTION.py @@ -0,0 +1,250 @@ +#!/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) diff --git a/tests/TCs/7_LAUNCH/LAUNCH.py b/tests/TCs/7_LAUNCH/LAUNCH.py deleted file mode 100755 index b03229f..0000000 --- a/tests/TCs/7_LAUNCH/LAUNCH.py +++ /dev/null @@ -1,259 +0,0 @@ -#!/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 = "LAUNCH" - -# The `Launcher_TC_LAUNCH_01` application should run in `candidate(dotnet-loader)` mode. -def TC_01(): - sln_name = "Launcher_TC_LAUNCH_01.Tizen" - - 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_LAUNCH_01.Tizen" - - 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_LAUNCH_01.Tizen") - if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw: - return "FAIL : The application is run as a candidate mode." - - cmd(f"shell app_launcher -t {pkg_id}") - - return "PASS" - -# The `Launcher_TC_LAUNCH_01` application should run in `standalone(dotnet-launcher)` mode. -def TC_02(): - sln_name = "Launcher_TC_LAUNCH_01.Tizen" - - 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_LAUNCH_01.Tizen" - - 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_LAUNCH_01.Tizen") - if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw: - return "FAIL : The application is run as a standalone mode" - - cmd(f"shell app_launcher -t {pkg_id}") - - return "PASS" - -# The `Launcher_TC_LAUNCH_02` application should run in `candidate(dotnet-nui-loader)` mode. -def TC_03(): - sln_name = "Launcher_TC_LAUNCH_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_LAUNCH_02" - - 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-nui-loader", f"{pkg_id}"): - return f"FAIL : Candidate process should have dotnet-nui-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_LAUNCH_02") - if f"{root_path}/bin/Launcher_TC_LAUNCH_02.dll" not in raw: - return "FAIL : The application is run as a candidate mode" - - cmd(f"shell app_launcher -t {pkg_id}") - - return "PASS" - -# The `Launcher_TC_LAUNCH_03` application should run in `hydra(dotnet-hydra-loader)` mode. -def TC_04(): - sln_name = "Launcher_TC_LAUNCH_03.Tizen" - - 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_LAUNCH_03.Tizen" - - root_path = get_root_path(f"{pkg_id}") - if root_path == "None": - return f"FAIL : Get the root path for {pkg_id}" - - raw = cmd(f"pull /usr/share/aul/dotnet.loader dotnet.loader.origin") - if "1 file(s) pulled. 0 file(s) skipped." not in raw: - return "FAIL : Pull the dotnet.loader file from the target" - - f1 = open("./dotnet.loader", "w") - f2 = open("./dotnet.loader.origin", "r") - - for line in f2: - if line.startswith("EXE"): - f1.write(line.replace("EXE", "#EXE")) - elif line.startswith("#EXE"): - f1.write(line.replace("#EXE", "EXE")) - elif line.startswith("HYDRA"): - f1.write(line.replace("OFF", "ON")) - else: - f1.write(line) - f2.close() - f1.close() - - raw = cmd(f"push dotnet.loader /usr/share/aul/") - if "1 file(s) pushed. 0 file(s) skipped." not in raw: - return "FAIL : Push the dotnet.loader file to the target" - - cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader") - cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader") - - cmd(f"shell reboot -f") - sleep(60) - - if "." in serial: - subprocess.run((f"sdb connect {serial}").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout - - cmd(f"root on") - cmd(f"shell mount -o remount,rw /") - - if "OK" not in prepare_candidate_process(f"dotnet-hydra-loader", f"{pkg_id}"): - return f"FAIL : Candidate process should have dotnet-loader" - - raw = cmd(f"shell ps -ef | grep dotnet-hydra-loader") - if "/usr/bin/dotnet-hydra-loader" not in raw: - return "FAIL : Candidate process should have dotnet-hydra-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_LAUNCH_03.Tizen") - if f"{root_path}/bin/Launcher_TC_LAUNCH_03.Tizen.dll" not in raw: - return "FAIL : The application is run as a candidate mode" - - 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_LAUNCH_01.Tizen") - cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_02") - cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_03.Tizen") - - for tc in tc_array: - if f"{tc.__name__}" == "TC_04": - cmd(f"shell mount -o remount,rw /") - cmd(f"push dotnet.loader.origin /usr/share/aul/dotnet.loader") - cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader") - cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader") - cmd(f"shell reboot -f") - - subprocess.run((f"rm dotnet.loader").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout - subprocess.run((f"rm dotnet.loader.origin").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout - -# Main entry point -def main(): - parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution") - 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_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, -'LAUNCH_TC_01': TC_01, 'LAUNCH_TC_02': TC_02, 'LAUNCH_TC_03': TC_03, 'LAUNCH_TC_04': TC_04 -} - - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - print("\nExit (Pressed Ctrl+C)") - exit(1) diff --git a/tests/TCs/7_LAUNCH/README.md b/tests/TCs/7_LAUNCH/README.md deleted file mode 100644 index 849121f..0000000 --- a/tests/TCs/7_LAUNCH/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Test Case for dotnet-launcher - LAUNCH - -This script(LAUNCH.py) is a test that verifies the behavior of **application launch**. -Check the candidate, standalone and hydra mode. - -### Usage - -* Build tpk - - Must be run(./BuildTPK.py) at least once. -``` -launcher/tests/Apps$ ./BuildTPK.py -``` - -* Run **LAUNCH** test -``` -launcher/tests/TCs$ ./7_LAUNCH/LAUNCH.py -launcher/tests/TCs/7_LAUNCH$ ./LAUNCH.py -``` - -* Run individual test -``` -launcher/tests/TCs/7_LAUNCH$ ./LAUNCH.py TC_01 -``` - -### Description -* TC_01 -``` - PASS : The Launcher_TC_LAUNCH_01 application should run in candidate(dotnet-loader) mode. -``` - 1. Candidate process should have dotnet-loader. - 2. Excute the application. - 3. Get the pid value. - 4. The application is run as a candidate mode. -* TC_02 -``` - PASS : The Launcher_TC_LAUNCH_01 application should run in standalone(dotnet-launcher) mode. -``` - 1. Excute the application without the dotnet-loader. - 2. Get the pid value. - 3. The application is run as a standalone mode. -* TC_03 -``` - PASS : The Launcher_TC_LAUNCH_02 application should run in candidate(dotnet-nui-loader) mode. -``` - 1. Candidate process should have dotnet-nui-loader. - 2. Excute the application. - 3. Get the pid value. - 4. The application is run as a candidate mode. -* TC_04 -``` - PASS : The Launcher_TC_LAUNCH_03 application should run in hydra(dotnet-hydra-loader) mode. -``` - 1. Modify the dotnet.loader file. - 2. Candidate process should have dotnet-hydra-loader. - 3. Excute the application. - 4. Get the pid value. - 5. The application is run as a candidate mode. ----- - -### Note - -* Precondition - - Clone the **dotnet-launcher** repository. - - The prerequisites are **sdb** and **python3.6+**. - - The script must be run on the **host PC**. - -* SDBs - - sdb with a smart device selector. -``` -[1] 192.168.250.250 - 0 -[2] 002c02f56c7d6c66 - TW3 -Select a device [1-2]: 2 -``` diff --git a/tests/TCs/8_EXCEPTION/EXCEPTION.py b/tests/TCs/8_EXCEPTION/EXCEPTION.py deleted file mode 100755 index 6f07b39..0000000 --- a/tests/TCs/8_EXCEPTION/EXCEPTION.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/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) diff --git a/tests/TCs/8_LAUNCH/LAUNCH.py b/tests/TCs/8_LAUNCH/LAUNCH.py new file mode 100755 index 0000000..b03229f --- /dev/null +++ b/tests/TCs/8_LAUNCH/LAUNCH.py @@ -0,0 +1,259 @@ +#!/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 = "LAUNCH" + +# The `Launcher_TC_LAUNCH_01` application should run in `candidate(dotnet-loader)` mode. +def TC_01(): + sln_name = "Launcher_TC_LAUNCH_01.Tizen" + + 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_LAUNCH_01.Tizen" + + 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_LAUNCH_01.Tizen") + if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw: + return "FAIL : The application is run as a candidate mode." + + cmd(f"shell app_launcher -t {pkg_id}") + + return "PASS" + +# The `Launcher_TC_LAUNCH_01` application should run in `standalone(dotnet-launcher)` mode. +def TC_02(): + sln_name = "Launcher_TC_LAUNCH_01.Tizen" + + 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_LAUNCH_01.Tizen" + + 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_LAUNCH_01.Tizen") + if f"{root_path}/bin/Launcher_TC_LAUNCH_01.Tizen.dll" not in raw: + return "FAIL : The application is run as a standalone mode" + + cmd(f"shell app_launcher -t {pkg_id}") + + return "PASS" + +# The `Launcher_TC_LAUNCH_02` application should run in `candidate(dotnet-nui-loader)` mode. +def TC_03(): + sln_name = "Launcher_TC_LAUNCH_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_LAUNCH_02" + + 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-nui-loader", f"{pkg_id}"): + return f"FAIL : Candidate process should have dotnet-nui-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_LAUNCH_02") + if f"{root_path}/bin/Launcher_TC_LAUNCH_02.dll" not in raw: + return "FAIL : The application is run as a candidate mode" + + cmd(f"shell app_launcher -t {pkg_id}") + + return "PASS" + +# The `Launcher_TC_LAUNCH_03` application should run in `hydra(dotnet-hydra-loader)` mode. +def TC_04(): + sln_name = "Launcher_TC_LAUNCH_03.Tizen" + + 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_LAUNCH_03.Tizen" + + root_path = get_root_path(f"{pkg_id}") + if root_path == "None": + return f"FAIL : Get the root path for {pkg_id}" + + raw = cmd(f"pull /usr/share/aul/dotnet.loader dotnet.loader.origin") + if "1 file(s) pulled. 0 file(s) skipped." not in raw: + return "FAIL : Pull the dotnet.loader file from the target" + + f1 = open("./dotnet.loader", "w") + f2 = open("./dotnet.loader.origin", "r") + + for line in f2: + if line.startswith("EXE"): + f1.write(line.replace("EXE", "#EXE")) + elif line.startswith("#EXE"): + f1.write(line.replace("#EXE", "EXE")) + elif line.startswith("HYDRA"): + f1.write(line.replace("OFF", "ON")) + else: + f1.write(line) + f2.close() + f1.close() + + raw = cmd(f"push dotnet.loader /usr/share/aul/") + if "1 file(s) pushed. 0 file(s) skipped." not in raw: + return "FAIL : Push the dotnet.loader file to the target" + + cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader") + cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader") + + cmd(f"shell reboot -f") + sleep(60) + + if "." in serial: + subprocess.run((f"sdb connect {serial}").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout + + cmd(f"root on") + cmd(f"shell mount -o remount,rw /") + + if "OK" not in prepare_candidate_process(f"dotnet-hydra-loader", f"{pkg_id}"): + return f"FAIL : Candidate process should have dotnet-loader" + + raw = cmd(f"shell ps -ef | grep dotnet-hydra-loader") + if "/usr/bin/dotnet-hydra-loader" not in raw: + return "FAIL : Candidate process should have dotnet-hydra-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_LAUNCH_03.Tizen") + if f"{root_path}/bin/Launcher_TC_LAUNCH_03.Tizen.dll" not in raw: + return "FAIL : The application is run as a candidate mode" + + 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_LAUNCH_01.Tizen") + cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_02") + cmd(f"uninstall org.tizen.example.Launcher_TC_LAUNCH_03.Tizen") + + for tc in tc_array: + if f"{tc.__name__}" == "TC_04": + cmd(f"shell mount -o remount,rw /") + cmd(f"push dotnet.loader.origin /usr/share/aul/dotnet.loader") + cmd(f"shell chsmack -a _ /usr/share/aul/dotnet.loader") + cmd(f"shell chmod 644 /usr/share/aul/dotnet.loader") + cmd(f"shell reboot -f") + + subprocess.run((f"rm dotnet.loader").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout + subprocess.run((f"rm dotnet.loader.origin").split(), encoding="utf-8", stdout=subprocess.PIPE).stdout + +# Main entry point +def main(): + parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution") + 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_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, +'LAUNCH_TC_01': TC_01, 'LAUNCH_TC_02': TC_02, 'LAUNCH_TC_03': TC_03, 'LAUNCH_TC_04': TC_04 +} + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + print("\nExit (Pressed Ctrl+C)") + exit(1) diff --git a/tests/TCs/8_LAUNCH/README.md b/tests/TCs/8_LAUNCH/README.md new file mode 100644 index 0000000..849121f --- /dev/null +++ b/tests/TCs/8_LAUNCH/README.md @@ -0,0 +1,75 @@ +# Test Case for dotnet-launcher - LAUNCH + +This script(LAUNCH.py) is a test that verifies the behavior of **application launch**. +Check the candidate, standalone and hydra mode. + +### Usage + +* Build tpk + + Must be run(./BuildTPK.py) at least once. +``` +launcher/tests/Apps$ ./BuildTPK.py +``` + +* Run **LAUNCH** test +``` +launcher/tests/TCs$ ./7_LAUNCH/LAUNCH.py +launcher/tests/TCs/7_LAUNCH$ ./LAUNCH.py +``` + +* Run individual test +``` +launcher/tests/TCs/7_LAUNCH$ ./LAUNCH.py TC_01 +``` + +### Description +* TC_01 +``` + PASS : The Launcher_TC_LAUNCH_01 application should run in candidate(dotnet-loader) mode. +``` + 1. Candidate process should have dotnet-loader. + 2. Excute the application. + 3. Get the pid value. + 4. The application is run as a candidate mode. +* TC_02 +``` + PASS : The Launcher_TC_LAUNCH_01 application should run in standalone(dotnet-launcher) mode. +``` + 1. Excute the application without the dotnet-loader. + 2. Get the pid value. + 3. The application is run as a standalone mode. +* TC_03 +``` + PASS : The Launcher_TC_LAUNCH_02 application should run in candidate(dotnet-nui-loader) mode. +``` + 1. Candidate process should have dotnet-nui-loader. + 2. Excute the application. + 3. Get the pid value. + 4. The application is run as a candidate mode. +* TC_04 +``` + PASS : The Launcher_TC_LAUNCH_03 application should run in hydra(dotnet-hydra-loader) mode. +``` + 1. Modify the dotnet.loader file. + 2. Candidate process should have dotnet-hydra-loader. + 3. Excute the application. + 4. Get the pid value. + 5. The application is run as a candidate mode. +---- + +### Note + +* Precondition + - Clone the **dotnet-launcher** repository. + - The prerequisites are **sdb** and **python3.6+**. + - The script must be run on the **host PC**. + +* SDBs + + sdb with a smart device selector. +``` +[1] 192.168.250.250 - 0 +[2] 002c02f56c7d6c66 - TW3 +Select a device [1-2]: 2 +```