Added TC to check NullReferenceException (#537)
author최종헌/MDE Lab(SR)/삼성전자 <j-h.choi@samsung.com>
Wed, 29 May 2024 07:43:20 +0000 (16:43 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 29 May 2024 07:43:20 +0000 (16:43 +0900)
Change-Id: I98a7d6273f86a60f259299d291f497c58a2e0676

12 files changed:
tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.sln [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.cs [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.csproj [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/shared/res/Launcher_TC_EXCEPTION_01.png [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/tizen-manifest.xml [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.sln [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.cs [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.csproj [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/shared/res/Launcher_TC_EXCEPTION_02.png [new file with mode: 0755]
tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/tizen-manifest.xml [new file with mode: 0755]
tests/TCs/8_EXCEPTION/EXCEPTION.py [new file with mode: 0755]
tests/TCs/Utils.py

diff --git a/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.sln b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.sln
new file mode 100755 (executable)
index 0000000..543df3d
--- /dev/null
@@ -0,0 +1,27 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Version 17\r
+VisualStudioVersion = 17.5.33627.172\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher_TC_EXCEPTION_01", "Launcher_TC_EXCEPTION_01\Launcher_TC_EXCEPTION_01.csproj", "{54606EFF-D558-4127-97BF-7020DCED4DA7}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {54606EFF-D558-4127-97BF-7020DCED4DA7}.Release|Any CPU.Deploy.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityGlobals) = postSolution\r
+               SolutionGuid = {988BEE6E-FFA8-4340-BED5-A5CD6478EC93}\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.cs b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.cs
new file mode 100755 (executable)
index 0000000..5eaf56d
--- /dev/null
@@ -0,0 +1,69 @@
+using System;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+\r
+namespace Launcher_TC_EXCEPTION_01\r
+{\r
+    internal class Program : NUIApplication\r
+    {\r
+        private void ExceptionTest()\r
+        {\r
+            string foo = null;\r
+            foo.ToUpper();\r
+        }\r
+\r
+        public void TC()\r
+        {\r
+            try\r
+            {\r
+                ExceptionTest();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Console.WriteLine(e.Message);\r
+                Console.WriteLine(e.ToString());\r
+            }\r
+        }\r
+\r
+        protected override void OnCreate()\r
+        {\r
+            base.OnCreate();\r
+            Initialize();\r
+            TC();\r
+        }\r
+\r
+        void Initialize()\r
+        {\r
+            Window.Instance.KeyEvent += OnKeyEvent;\r
+\r
+            TextLabel text = new TextLabel("Hello Tizen NUI World");\r
+            text.HorizontalAlignment = HorizontalAlignment.Center;\r
+            text.VerticalAlignment = VerticalAlignment.Center;\r
+            text.TextColor = Color.Blue;\r
+            text.PointSize = 30.0f;\r
+            text.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+            text.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+            Window.Instance.GetDefaultLayer().Add(text);\r
+\r
+            Animation animation = new Animation(2000);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);\r
+            animation.Looping = true;\r
+            animation.Play();\r
+        }\r
+\r
+        public void OnKeyEvent(object sender, Window.KeyEventArgs e)\r
+        {\r
+            if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))\r
+            {\r
+                Exit();\r
+            }\r
+        }\r
+\r
+        static void Main(string[] args)\r
+        {\r
+            var app = new Program();\r
+            app.Run(args);\r
+        }\r
+    }\r
+}\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.csproj b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01.csproj
new file mode 100755 (executable)
index 0000000..f53261d
--- /dev/null
@@ -0,0 +1,27 @@
+<Project Sdk="Tizen.NET.Sdk/1.0.9">\r
+\r
+       <PropertyGroup>\r
+               <OutputType>Exe</OutputType>\r
+               <TargetFramework>tizen60</TargetFramework>\r
+       </PropertyGroup>\r
+\r
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+               <DebugType>portable</DebugType>\r
+       </PropertyGroup>\r
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+               <DebugType>None</DebugType>\r
+       </PropertyGroup>\r
+\r
+       <ItemGroup>\r
+               <Folder Include="lib\" />\r
+               <Folder Include="res\" />\r
+       </ItemGroup>\r
+\r
+       <ItemGroup>\r
+               <PackageReference Include="Tizen.NET.TV" Version="5.5.0.4922">\r
+                       <ExcludeAssets>Runtime</ExcludeAssets>\r
+               </PackageReference>\r
+\r
+       </ItemGroup>\r
+\r
+</Project>\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/shared/res/Launcher_TC_EXCEPTION_01.png b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/shared/res/Launcher_TC_EXCEPTION_01.png
new file mode 100755 (executable)
index 0000000..9f3cb98
Binary files /dev/null and b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/shared/res/Launcher_TC_EXCEPTION_01.png differ
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/tizen-manifest.xml b/tests/Apps/Launcher_TC_EXCEPTION_01/Launcher_TC_EXCEPTION_01/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..55af907
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="6.5" package="org.tizen.example.Launcher_TC_EXCEPTION_01" version="1.0.0">\r
+       <feature name="http://tizen.org/feature/screen.size.normal.1080.1920">true</feature>\r
+  <profile name="common" />\r
+  <ui-application appid="org.tizen.example.Launcher_TC_EXCEPTION_01"\r
+                                       exec="Launcher_TC_EXCEPTION_01.dll"\r
+                                       type="dotnet"\r
+                                       multiple="false"\r
+                                       taskmanage="true"\r
+                                       nodisplay="false"\r
+                                       launch_mode="single">\r
+    <label>Launcher_TC_EXCEPTION_01</label>\r
+    <icon>Launcher_TC_EXCEPTION_01.png</icon>\r
+  </ui-application>\r
+  <tv-info api-version="9.9.0">\r
+    <infolink>T-INFOLINK2022-1000</infolink>\r
+  </tv-info>\r
+</manifest>\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.sln b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.sln
new file mode 100755 (executable)
index 0000000..dc3611b
--- /dev/null
@@ -0,0 +1,27 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Version 17\r
+VisualStudioVersion = 17.5.33627.172\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher_TC_EXCEPTION_02", "Launcher_TC_EXCEPTION_02\Launcher_TC_EXCEPTION_02.csproj", "{56FEFF50-B69E-4FA4-BC8C-3717101E3506}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Release|Any CPU = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Debug|Any CPU.Deploy.0 = Debug|Any CPU\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {56FEFF50-B69E-4FA4-BC8C-3717101E3506}.Release|Any CPU.Deploy.0 = Release|Any CPU\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+       GlobalSection(ExtensibilityGlobals) = postSolution\r
+               SolutionGuid = {54AA6825-7BE4-4AF0-A5AB-6FBCC23E26D3}\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.cs b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.cs
new file mode 100755 (executable)
index 0000000..a928380
--- /dev/null
@@ -0,0 +1,69 @@
+using System;\r
+using Tizen.NUI;\r
+using Tizen.NUI.BaseComponents;\r
+\r
+namespace Launcher_TC_EXCEPTION_02\r
+{\r
+    internal class Program : NUIApplication\r
+    {\r
+        private void ExceptionTest()\r
+        {\r
+            string foo = null;\r
+            foo.ToUpper();\r
+        }\r
+\r
+        public void TC()\r
+        {\r
+            try\r
+            {\r
+                ExceptionTest();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                Console.WriteLine(e.Message);\r
+                Console.WriteLine(e.ToString());\r
+            }\r
+        }\r
+\r
+        protected override void OnCreate()\r
+        {\r
+            base.OnCreate();\r
+            Initialize();\r
+            TC();\r
+        }\r
+\r
+        void Initialize()\r
+        {\r
+            Window.Instance.KeyEvent += OnKeyEvent;\r
+\r
+            TextLabel text = new TextLabel("Hello Tizen NUI World");\r
+            text.HorizontalAlignment = HorizontalAlignment.Center;\r
+            text.VerticalAlignment = VerticalAlignment.Center;\r
+            text.TextColor = Color.Blue;\r
+            text.PointSize = 30.0f;\r
+            text.HeightResizePolicy = ResizePolicyType.FillToParent;\r
+            text.WidthResizePolicy = ResizePolicyType.FillToParent;\r
+            Window.Instance.GetDefaultLayer().Add(text);\r
+\r
+            Animation animation = new Animation(2000);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);\r
+            animation.AnimateTo(text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);\r
+            animation.Looping = true;\r
+            animation.Play();\r
+        }\r
+\r
+        public void OnKeyEvent(object sender, Window.KeyEventArgs e)\r
+        {\r
+            if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))\r
+            {\r
+                Exit();\r
+            }\r
+        }\r
+\r
+        static void Main(string[] args)\r
+        {\r
+            var app = new Program();\r
+            app.Run(args);\r
+        }\r
+    }\r
+}\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.csproj b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02.csproj
new file mode 100755 (executable)
index 0000000..f53261d
--- /dev/null
@@ -0,0 +1,27 @@
+<Project Sdk="Tizen.NET.Sdk/1.0.9">\r
+\r
+       <PropertyGroup>\r
+               <OutputType>Exe</OutputType>\r
+               <TargetFramework>tizen60</TargetFramework>\r
+       </PropertyGroup>\r
+\r
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+               <DebugType>portable</DebugType>\r
+       </PropertyGroup>\r
+       <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+               <DebugType>None</DebugType>\r
+       </PropertyGroup>\r
+\r
+       <ItemGroup>\r
+               <Folder Include="lib\" />\r
+               <Folder Include="res\" />\r
+       </ItemGroup>\r
+\r
+       <ItemGroup>\r
+               <PackageReference Include="Tizen.NET.TV" Version="5.5.0.4922">\r
+                       <ExcludeAssets>Runtime</ExcludeAssets>\r
+               </PackageReference>\r
+\r
+       </ItemGroup>\r
+\r
+</Project>\r
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/shared/res/Launcher_TC_EXCEPTION_02.png b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/shared/res/Launcher_TC_EXCEPTION_02.png
new file mode 100755 (executable)
index 0000000..9f3cb98
Binary files /dev/null and b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/shared/res/Launcher_TC_EXCEPTION_02.png differ
diff --git a/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/tizen-manifest.xml b/tests/Apps/Launcher_TC_EXCEPTION_02/Launcher_TC_EXCEPTION_02/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..3b722d2
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<manifest xmlns="http://tizen.org/ns/packages" api-version="6.5" package="org.tizen.example.Launcher_TC_EXCEPTION_02" version="1.0.0">\r
+       <feature name="http://tizen.org/feature/screen.size.normal.1080.1920">true</feature>\r
+  <profile name="common" />\r
+  <ui-application appid="org.tizen.example.Launcher_TC_EXCEPTION_02"\r
+                                       exec="Launcher_TC_EXCEPTION_02.dll"\r
+                                       type="dotnet-nui"\r
+                                       multiple="false"\r
+                                       taskmanage="true"\r
+                                       nodisplay="false"\r
+                                       launch_mode="single">\r
+    <label>Launcher_TC_EXCEPTION_02</label>\r
+    <icon>Launcher_TC_EXCEPTION_02.png</icon>\r
+  </ui-application>\r
+  <tv-info api-version="9.9.0">\r
+    <infolink>T-INFOLINK2022-1000</infolink>\r
+  </tv-info>\r
+</manifest>\r
diff --git a/tests/TCs/8_EXCEPTION/EXCEPTION.py b/tests/TCs/8_EXCEPTION/EXCEPTION.py
new file mode 100755 (executable)
index 0000000..6f07b39
--- /dev/null
@@ -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)
index b492bc0669ed34e45abed93c921033bd58e8044e..b5e4af38806ce8676193f0d7d71c66a95adb6610 100755 (executable)
@@ -111,6 +111,11 @@ def get_device_type():
     raw = cmd(f"shell cat /etc/config/model-config.xml | grep tizen.org/feature/profile")
     return raw.split(">")[1].split("<")[0]
 
+# Get the device type
+def get_platform_version():
+    raw = cmd(f"shell cat /etc/config/model-config.xml | grep tizen.org/feature/platform.version")
+    return raw.split(">")[1].split("<")[0]
+
 # Create the System.Private.CoreLib native image
 def create_spc_ni():
     raw = cmd(f"shell find {RUNTIME_DIR} -name {SPC_DLL}.Backup")
@@ -134,7 +139,10 @@ def remove_system_ni():
 
 # Prepare the candidate process
 def prepare_candidate_process(loader, pkg_id):
-    cmd(f"shell killall dotnet-launcher {loader}")
+    cmd(f"shell killall dotnet-launcher")
+    raw = cmd(f"shell killall {loader}")
+    if "no process found" in raw:
+        return "NOT FOUND"
     sleep(30)
 
     raw = cmd(f"shell ps -ef | grep {loader}")