[TC Fixed] Change the 'find' command
[platform/core/dotnet/launcher.git] / tests / TCs / 6_TOOL / TOOL.py
index 8d4e166..83de4ae 100755 (executable)
@@ -11,8 +11,7 @@ module_name = "TOOL"
 
 # The `dotnettool` works normally.
 def TC_01():
-    raw = cmd(f"shell find /usr/bin/ -name dotnettool")
-    if "/usr/bin/dotnettool" not in raw:
+    if not exist("/usr/bin/dotnettool")
         return "FAIL : The dotnettool works normally"
 
     raw = cmd(f"shell dotnettool")
@@ -25,8 +24,7 @@ def TC_01():
 def TC_02():
     cmd(f"shell dotnettool --ni-system")
 
-    raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
-    if f"{RUNTIME_DIR}{SPC_DLL}.Backup" not in raw:
+    if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
         return "FAIL : Create the platform native image"
 
     raw = cmd(f"shell find {RUNTIME_DIR} -name *.ni.dll")
@@ -58,16 +56,14 @@ def TC_02():
 def TC_03():
     cmd(f"shell dotnettool --ni-reset-system")
 
-    raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
-    if f"{RUNTIME_DIR}{SPC_DLL}.Backup" in raw:
+    if exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
         return "FAIL : Remove the platform native image"
 
     return "PASS"
 
 # Create native image for `System.Private.CoreLib.dll`.
 def TC_04():
-    raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
-    if f"{RUNTIME_DIR}{SPC_DLL}.Backup" in raw:
+    if exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
         cmd(f"shell rm {RUNTIME_DIR}{SPC_DLL}")
         cmd(f"shell mv {RUNTIME_DIR}{SPC_DLL}.Backup {RUNTIME_DIR}{SPC_DLL}")
 
@@ -76,8 +72,7 @@ def TC_04():
        "System.Private.CoreLib.ni.dll generated successfully." not in raw:
         return f"FAIL : Create native image for {SPC_DLL}"
 
-    raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
-    if f"{RUNTIME_DIR}{SPC_DLL}.Backup" not in raw:
+    if not exist(f"{RUNTIME_DIR}{SPC_DLL}.Backup"):
         return f"FAIL : Create native image for {SPC_DLL}"
 
     return "PASS"
@@ -151,8 +146,7 @@ def TC_09():
     cmd(f"shell unzip /tmp/{ibcdata_zip} -d {IBCDATA_DIR}")
     cmd(f"shell chsmack -a _ {IBCDATA_DIR} -r")
 
-    raw = cmd(f"shell find {IBCDATA_DIR}netstandard.ibc")
-    if f"No such file or directory" in raw:
+    if not exist(f"{IBCDATA_DIR}netstandard.ibc"):
         return "FAIL : The netstandard.ibc file should exist"
 
     raw = cmd(f"shell dotnettool --ibc-dir /usr/share/dotnet.tizen/ibcdata/ --ni-dll {RUNTIME_DIR}netstandard.dll")
@@ -179,14 +173,12 @@ def TC_10():
     if root_path == "None":
         return f"FAIL : Get the root path for {pkg_id}"
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .native_image")
-    if ".native_image" not in raw:
+    if not exist(f"{root_path}/bin/.native_image"):
         return "FAIL : The .native_image folder should exist"
 
     cmd(f"shell dotnettool --ni-reset-pkg {pkg_id}")
 
-    raw = cmd(f"shell ls {root_path}/bin/.native_image")
-    if "No such file or directory" not in raw:
+    if exist(f"{root_path}/bin/.native_image"):
         return "FAIL : The .native_image folder should not exist"
 
     raw = cmd(f"shell find {root_path}/bin/ -name *.ni.dll")
@@ -213,14 +205,12 @@ def TC_11():
     if root_path == "None":
         return f"FAIL : Get the root path for {pkg_id}"
 
-    raw = cmd(f"shell ls {root_path}/bin/.native_image")
-    if "No such file or directory" not in raw:
+    if exist(f"{root_path}/bin/.native_image"):
         return "FAIL : The .native_image folder not should exist"
 
     cmd(f"shell dotnettool --ni-pkg {pkg_id}")
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .native_image")
-    if ".native_image" not in raw:
+    if not exist(f"{root_path}/bin/.native_image"):
         return "FAIL : The .native_image folder should exist"
 
     raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll")
@@ -317,8 +307,7 @@ def TC_14():
     if root_path == "None":
         return f"FAIL : Get the root path for {pkg_id}"
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
-    if ".tac_symlink" not in raw:
+    if not exist(f"{root_path}/bin/.tac_symlink"):
         return "FAIL : The .tac_symlink folder should exist"
 
     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
@@ -332,14 +321,12 @@ def TC_14():
     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
     for dll in lines:
         origin_path = dll.split("->")[1].strip()
-        raw = cmd(f"shell ls -alZ {origin_path}")
-        if "No such file or directory" in raw:
+        if not exist(f"{origin_path}"):
             return "FAIL : The original file of the symbolic link must exist"
 
     cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
-    if ".tac_symlink" in raw:
+    if exist(f"{root_path}/bin/.tac_symlink"):
         return "FAIL : The .tac_symlink folder should not exist"
 
     raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
@@ -368,8 +355,7 @@ def TC_15():
 
     cmd(f"shell dotnettool --tac-disable-pkg {pkg_id}")
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
-    if ".tac_symlink" in raw:
+    if exist(f"{root_path}/bin/.tac_symlink"):
         return "FAIL : The .tac_symlink folder should not exist"
 
     raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll")
@@ -379,8 +365,7 @@ def TC_15():
 
     cmd(f"shell dotnettool --tac-enable-pkg {pkg_id}")
 
-    raw = cmd(f"shell find {root_path}/bin/ -name .tac_symlink")
-    if ".tac_symlink" not in raw:
+    if not exist(f"{root_path}/bin/.tac_symlink"):
         return "FAIL : The .tac_symlink folder should exist"
 
     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
@@ -394,8 +379,7 @@ def TC_15():
     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
     for dll in lines:
         origin_path = dll.split("->")[1].strip()
-        raw = cmd(f"shell ls -alZ {origin_path}")
-        if "No such file or directory" in raw:
+        if not exist(f"{origin_path}"):
             return "FAIL : The original file of the symbolic link must exist"
 
     return "PASS"