[TC Fixed] Modify the log when the tc fails
[platform/core/dotnet/launcher.git] / tests / TCs / 5_TLC / TLC.py
index 2da7cf6..1cf3367 100755 (executable)
@@ -11,6 +11,9 @@ module_name = "TLC"
 
 # The `Launcher_TC_TLC_01` application must have TLC applied.
 def TC_01():
+    if not check_tc_support():
+        return "NONE - TC_01 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_01.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -38,7 +41,7 @@ def TC_01():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
         return "FAIL : The arch of the target and the arch of the library must match"
@@ -57,6 +60,9 @@ def TC_01():
 
 # The `Launcher_TC_TLC_02` application must have TLC applied.
 def TC_02():
+    if not check_tc_support():
+        return "NONE - TC_02 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_02.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -84,7 +90,7 @@ def TC_02():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
         return "FAIL : The arch of the target and the arch of the library must match"
@@ -103,6 +109,9 @@ def TC_02():
 
 # The `Launcher_TC_TLC_03` application should not apply TLC when updating.
 def TC_03():
+    if not check_tc_support():
+        return "NONE - TC_03 is not supported on this platform"
+
     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
 
     root_path = get_root_path(f"{pkg_id}")
@@ -134,7 +143,7 @@ def TC_03():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha in raw:
-        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}Libraries"
 
     if exist(f"{root_path}/bin/libSkiaSharp.so"):
         return "FAIL : The libSkiaSharp.so library should not exist in the application"
@@ -165,6 +174,9 @@ def TC_02_03():
 
 # The `Launcher_TC_TLC_04` application is normally TLC applied when updating.
 def TC_04():
+    if not check_tc_support():
+        return "NONE - TC_04 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_04.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -192,7 +204,7 @@ def TC_04():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
         return "FAIL : The arch of the target and the arch of the library must match"
@@ -211,6 +223,9 @@ def TC_04():
 
 # The `Launcher_TC_TLC_05` application is normally TLC applied when updating.
 def TC_05():
+    if not check_tc_support():
+        return "NONE - TC_05 is not supported on this platform"
+
     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
 
     root_path = get_root_path(f"{pkg_id}")
@@ -242,7 +257,7 @@ def TC_05():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha in raw:
-        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}Libraries"
 
     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
         return "FAIL : The libSkiaSharp.so library should exist in the application"
@@ -256,7 +271,7 @@ def TC_05():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     if "OK" not in check_library_arch(f"{root_path}", "libSkiaSharp.so"):
         return "FAIL : The arch of the target and the arch of the library must match"
@@ -287,6 +302,9 @@ def TC_04_05():
 
 # The `Launcher_TC_TLC_06` application should not apply TLC when updating.
 def TC_06():
+    if not check_tc_support():
+        return "NONE - TC_06 is not supported on this platform"
+
     pkg_id = f"org.tizen.example.Launcher_TC_TLC_00.Tizen"
 
     root_path = get_root_path(f"{pkg_id}")
@@ -318,7 +336,7 @@ def TC_06():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha in raw:
-        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}Libraries"
 
     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
         return "FAIL : The libSkiaSharp.so library should exist only in the application"
@@ -361,6 +379,9 @@ def TC_04_05_06():
 
 # The `Launcher_TC_TLC_07`, `Launcher_TC_TLC_08` applications using the same nuget are normally TLC applied.
 def TC_07():
+    if not check_tc_support():
+        return "NONE - TC_07 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_07.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -388,7 +409,7 @@ def TC_07():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libHarfBuzzSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     sln_name = "Launcher_TC_TLC_08.Tizen"
 
@@ -424,7 +445,7 @@ def TC_07():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libHarfBuzzSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libHarfBuzzSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     if "OK" not in check_library_arch(f"{root_path}", "libHarfBuzzSharp.so"):
         return "FAIL : The arch of the target and the arch of the library must match"
@@ -443,6 +464,9 @@ def TC_07():
 
 # The `Launcher_TC_TLC_09` application is normally TLC applied when uninstall.
 def TC_08():
+    if not check_tc_support():
+        return "NONE - TC_08 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_09.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -459,7 +483,7 @@ def TC_08():
         return f"FAIL : Get the root path for {pkg_id}"
 
     if not exist(f"{root_path}/bin/libSkiaSharp.so"):
-        return "FAIL : The libSkiaSharp.so library should exist"
+        return "FAIL : The libSkiaSharp.so library should exist in the application"
 
     raw = cmd(f"shell ls -alZ {root_path}/bin/libSkiaSharp.so")
     if (f"{root_path}/bin/libSkiaSharp.so" not in raw) or \
@@ -473,7 +497,7 @@ def TC_08():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha not in raw:
-        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should exist in {DOTNET_DIR}Libraries"
 
     raw = cmd(f"uninstall {pkg_id}")
     if "key[end] val[ok]" not in raw:
@@ -481,12 +505,15 @@ def TC_08():
 
     raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name libSkiaSharp.so*")
     if sha in raw:
-       return f"FAIL : The libSkiaSharp.so library should not exist in {DONTET_DIR}"
+        return f"FAIL : The libSkiaSharp.so library should not exist in {DOTNET_DIR}Libraries"
 
     return "PASS"
 
 # The `Launcher_TC_TLC_10` application should match the information of nuget with the value of TLC database.
 def TC_09():
+    if not check_tc_support():
+        return "NONE - TC_09 is not supported on this platform"
+
     sln_name = "Launcher_TC_TLC_10.Tizen"
 
     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
@@ -505,7 +532,7 @@ def TC_09():
     raw = cmd(f"shell find {root_path}/bin/ -name lib*.so*")
     lines1 = [l for l in raw.splitlines()]
     if len(lines1) == 0:
-        return "FAIL : The library should exist in the application"
+        return "FAIL : The libraries should exist in the application"
 
     raw = subprocess.run((f"sdb -s {serial} shell sqlite3 {DOTNET_DIR}.TLC.App.list.db").split(), stdout=subprocess.PIPE, input=f"select * from TLC;\n.q\n", encoding="utf-8").stdout
     lines2 = [l for l in raw.splitlines() if f"{pkg_id}" in l]
@@ -525,7 +552,7 @@ def TC_09():
 
         raw = cmd(f"shell find {DOTNET_DIR}Libraries/ -name {name}..{sha}")
         if f"{DOTNET_DIR}Libraries/{name}..{sha}" not in raw:
-            return f"FAIL : The {name} library should exist in {DOTNET_DIR}"
+            return f"FAIL : The {name} library should exist in {DOTNET_DIR}Libraries"
 
         is_exist = False
         for rcd in lines2:
@@ -546,10 +573,14 @@ def run():
     global tpk_list
     tpk_list = search_tpk(f"{module_name}")
 
-    p = run_tc_array(module_name, tc_array)
-    f = len(tc_array) - p
-    r = round(((p / len(tc_array)) * 100), 2)
-    print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
+    pn = run_tc_array(module_name, tc_array)
+    p = int(pn.split(":")[0])
+    n = int(pn.split(":")[1])
+    r = 0.0
+    f = len(tc_array) - p - n
+    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")
 
 # Uninstall the application and restore to original state
 def clean():