From: j-h.choi Date: Wed, 30 Dec 2020 05:07:54 +0000 (+0900) Subject: [TC Added] dotnettool option(--ni-regen-all-ro-app) test in TOOL X-Git-Tag: accepted/tizen/unified/20210125.073655~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7337678fedd25e2020add137fc3dab12f3b16721;p=platform%2Fcore%2Fdotnet%2Flauncher.git [TC Added] dotnettool option(--ni-regen-all-ro-app) test in TOOL Change-Id: Ibad71585e1fdabada656ccaac8630bd33d77af3e --- diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.sln b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.sln new file mode 100644 index 0000000..99a3ba6 --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher_TC_TOOL_08", "Launcher_TC_TOOL_08\Launcher_TC_TOOL_08\Launcher_TC_TOOL_08.csproj", "{14607BEA-C6C6-41B6-BB37-20072CBFD953}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher_TC_TOOL_08.Tizen", "Launcher_TC_TOOL_08\Launcher_TC_TOOL_08.Tizen\Launcher_TC_TOOL_08.Tizen.csproj", "{D47AC382-0C20-4AD2-9D52-5F1A26BF7C97}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {14607BEA-C6C6-41B6-BB37-20072CBFD953}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {14607BEA-C6C6-41B6-BB37-20072CBFD953}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14607BEA-C6C6-41B6-BB37-20072CBFD953}.Release|Any CPU.ActiveCfg = Release|Any CPU + {14607BEA-C6C6-41B6-BB37-20072CBFD953}.Release|Any CPU.Build.0 = Release|Any CPU + {D47AC382-0C20-4AD2-9D52-5F1A26BF7C97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D47AC382-0C20-4AD2-9D52-5F1A26BF7C97}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D47AC382-0C20-4AD2-9D52-5F1A26BF7C97}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D47AC382-0C20-4AD2-9D52-5F1A26BF7C97}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5DA771A9-1046-4DD4-89E4-5CF034C3BF06} + EndGlobalSection +EndGlobal diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.cs b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.cs new file mode 100644 index 0000000..3da222e --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.cs @@ -0,0 +1,22 @@ +using System; +using Xamarin.Forms; + +namespace Launcher_TC_TOOL_08 +{ + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + protected override void OnCreate() + { + base.OnCreate(); + + LoadApplication(new App()); + } + + static void Main(string[] args) + { + var app = new Program(); + Forms.Init(app); + app.Run(args); + } + } +} diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj new file mode 100644 index 0000000..6ec12f8 --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj @@ -0,0 +1,26 @@ + + + + Exe + tizen70 + + + + portable + + + None + + + + + + + + + + + + + + diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj.user b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj.user new file mode 100644 index 0000000..36eec2c --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/Launcher_TC_TOOL_08.Tizen.csproj.user @@ -0,0 +1,6 @@ + + + + Launcher_TC_TOOL_08.Tizen + + \ No newline at end of file diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/shared/res/Launcher_TC_TOOL_08.Tizen.png b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/shared/res/Launcher_TC_TOOL_08.Tizen.png new file mode 100644 index 0000000..9f3cb98 Binary files /dev/null and b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/shared/res/Launcher_TC_TOOL_08.Tizen.png differ diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/tizen-manifest.xml b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/tizen-manifest.xml new file mode 100644 index 0000000..756432b --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.Tizen/tizen-manifest.xml @@ -0,0 +1,16 @@ + + + + + + Launcher_TC_TOOL_08.Tizen.png + + + diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.cs b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.cs new file mode 100644 index 0000000..f6e0ee2 --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Xamarin.Forms; + +namespace Launcher_TC_TOOL_08 +{ + public class App : Application + { + public App() + { + // The root page of your application + MainPage = new ContentPage + { + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = { + new Label { + HorizontalTextAlignment = TextAlignment.Center, + Text = "Welcome to Xamarin Forms!" + } + } + } + }; + } + + protected override void OnStart() + { + // Handle when your app starts + } + + protected override void OnSleep() + { + // Handle when your app sleeps + } + + protected override void OnResume() + { + // Handle when your app resumes + } + } +} diff --git a/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.csproj b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.csproj new file mode 100644 index 0000000..be3d00f --- /dev/null +++ b/tests/Apps/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08/Launcher_TC_TOOL_08.csproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/tests/Apps/README.md b/tests/Apps/README.md index e01f9ca..0fa4ae0 100644 --- a/tests/Apps/README.md +++ b/tests/Apps/README.md @@ -116,6 +116,7 @@ Build complete : org.tizen.example.Launcher_TC_TAC_01.Tizen-1.0.0.tpk Launcher_TC_TOOL_05 | org.tizen.example.Launcher_TC_TOOL_05.Tizen | X | True | Xamarin.Forms(4.6.0.967) Launcher_TC_TOOL_06 | org.tizen.example.Launcher_TC_TOOL_06.Tizen | X | True | Xamarin.Forms(4.6.0.967) Launcher_TC_TOOL_07 | org.tizen.example.Launcher_TC_TOOL_07.Tizen | True | True | Xamarin.Forms(4.6.0.967), SkiaSharp(2.80.2) + Launcher_TC_TOOL_08 | org.tizen.example.Launcher_TC_TOOL_08.Tizen | True | X | Xamarin.Forms(4.6.0.967) ---- ### Note diff --git a/tests/TCs/6_TOOL/README.md b/tests/TCs/6_TOOL/README.md index ae1cf6a..5fb6790 100644 --- a/tests/TCs/6_TOOL/README.md +++ b/tests/TCs/6_TOOL/README.md @@ -110,6 +110,17 @@ launcher/tests/TCs/6_TOOL$ ./TOOL.py TC_01 PASS : The Database of the restored TAC and TLC must be a valid value. ``` 1. sh-3.2# dotnettool --tac-restore-db +* TC_17 +``` + PASS : The prefer_dotnet_aot metadata value of true will regenerates the native image in all .NET applications of read-only type. +``` + 1. sh-3.2# dotnettool --ni-regen-all-ro-app +* TC_18 +``` + PASS : The Launcher_TC_TOOL_08 application should load the newly generated native image. +``` + 1. Regenerated NI files of read-only application is stored at "/opt/usr/dotnet/apps/[PkgID]/bin/.native_image/". + 2. The assembly in the "/opt/usr/dotnet/apps/[PkgId]/bin/.native/image/" should be loaded when running the application. ---- ### Note diff --git a/tests/TCs/6_TOOL/TOOL.py b/tests/TCs/6_TOOL/TOOL.py index 83de4ae..e2ed2f8 100755 --- a/tests/TCs/6_TOOL/TOOL.py +++ b/tests/TCs/6_TOOL/TOOL.py @@ -245,30 +245,29 @@ def TC_12(): cmd(f"shell dotnettool --ni-regen-all-app") raw = subprocess.run((f"sdb -s {serial} shell pkginfo --metadata-flt").split(), stdout=subprocess.PIPE, input=f"http://tizen.org/metadata/prefer_dotnet_aot\ntrue\n", encoding="utf-8").stdout - lines1 = [l for l in raw.splitlines() if "appid" in l] - lines2 = [] - for app in lines1: + lines = [l for l in raw.splitlines() if "appid" in l] + for app in lines: pkg_id = app.split(": ")[1] raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout - lines2 = [l for l in raw.splitlines() if "root_path" in l] - - for path in lines2: - root_path = path.split(": ")[1] - raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll") - lines3 = [l for l in raw.splitlines()] - raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll") - lines4 = [l for l in raw.splitlines()] - if len(lines3) != len(lines4): - return "FAIL : The number of .dll and .ni.dll must match in the application" - - for ni in lines3: - is_same = False - for dll in lines4: - if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""): - is_same = True - break - if not is_same: - return "FAIL : The file name of .dll and .ni.dll must match in the application" + readonly = [l for l in raw.splitlines() if "Readonly" in l] + if "0" == readonly[0].split(": ")[1]: + path = [l for l in raw.splitlines() if "root_path" in l] + root_path = path[0].split(": ")[1] + raw = cmd(f"shell find {root_path}/bin/.native_image/ -name *.ni.dll") + lines1 = [l for l in raw.splitlines()] + raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll") + lines2 = [l for l in raw.splitlines()] + if len(lines1) != len(lines2): + return "FAIL : The number of .dll and .ni.dll must match in the application" + + for ni in lines1: + is_same = False + for dll in lines2: + if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""): + is_same = True + break + if not is_same: + return "FAIL : The file name of .dll and .ni.dll must match in the application" return "PASS" @@ -417,15 +416,79 @@ def TC_16(): return "PASS" +# The prefer_dotnet_aot metadata value of true will regenerates the native image in all .NET applications of read-only type. +def TC_17(): + sln_name = "Launcher_TC_TOOL_08.Tizen" -#def TC_17(): -#dotnettool --resolve-all-app + tpk_path = get_tpk_path(tpk_list, f"{sln_name}") + if tpk_path == None: + return f"FAIL : Get the tpk path for {sln_name}" + + raw = cmd(f"push {tpk_path} /usr/apps/.preload-tpk/") + if "1 file(s) pushed. 0 file(s) skipped." in raw: + cmd(f"shell install_preload_pkg") + + cmd(f"shell dotnettool --ni-regen-all-ro-app") + + raw = subprocess.run((f"sdb -s {serial} shell pkginfo --metadata-flt").split(), stdout=subprocess.PIPE, input=f"http://tizen.org/metadata/prefer_dotnet_aot\ntrue\n", encoding="utf-8").stdout + lines = [l for l in raw.splitlines() if "appid" in l] + for app in lines: + pkg_id = app.split(": ")[1] + raw = subprocess.run((f"sdb -s {serial} shell pkginfo --pkg {pkg_id}").split(), stdout=subprocess.PIPE, encoding="utf-8").stdout + readonly = [l for l in raw.splitlines() if "Readonly" in l] + if "1" == readonly[0].split(": ")[1]: + path = [l for l in raw.splitlines() if "root_path" in l] + root_path = path[0].split(": ")[1] + raw = cmd(f"shell find {DOTNET_DIR}apps/{pkg_id}/bin/.native_image/ -name *.ni.dll") + lines1 = [l for l in raw.splitlines()] + raw = cmd(f"shell find {root_path}/bin/ -maxdepth 1 -name *.dll -not -name *.ni.dll") + lines2 = [l for l in raw.splitlines()] + if len(lines1) != len(lines2): + return "FAIL : The number of .dll and .ni.dll must match in the application" + + for ni in lines1: + is_same = False + for dll in lines2: + if Path(ni).name.replace(".ni.dll", "") == Path(dll).name.replace(".dll", ""): + is_same = True + break + if not is_same: + return "FAIL : The file name of .dll and .ni.dll must match in the application" + + return "PASS" -#def TC_18(): -#dotnettool --instrument +# The `Launcher_TC_TOOL_08` application should load the newly generated native image. +def TC_18(): + pkg_id = f"org.tizen.example.Launcher_TC_TOOL_08.Tizen" + + 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 Xamarin.Forms.*.dll") + if (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Platform.Tizen.ni.dll" not in raw) or \ + (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Core.ni.dll" not in raw) or \ + (f"{DOTNET_DIR}apps/{pkg_id}/bin/.native_image/Xamarin.Forms.Platform.ni.dll" not in raw): + return "FAIL : The Xamarin.Forms in the application should be loaded when running the application" + + cmd(f"shell app_launcher -t {pkg_id}") + + return "PASS" + +# It should be done together for update test. +def TC_17_18(): + ret = TC_17() + if "PASS" != ret: + return f"{ret}" + + ret = TC_18() + if "PASS" != ret: + return f"{ret}" + + return "PASS" #def TC_19(): -#dotnettool --compatibility +#dotnettool --resolve-all-app # Run the test @@ -457,6 +520,8 @@ def clean(): cmd(f"shell rm -rf {IBCDATA_DIR}") + cmd(f"shell rm -rf {DOTNET_DIR}apps/org.tizen.example.Launcher_TC_TOOL_08.Tizen") + # Main entry point def main(): parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter) @@ -473,7 +538,7 @@ def main(): else: tc_array.append(funcMap[tc_num]) else: - tc_array = [TC_01, TC_02, TC_03, TC_04, TC_05, TC_06, TC_07, TC_08, TC_09, TC_10, TC_11, TC_12, TC_13, TC_14, TC_15, TC_16] + tc_array = [TC_01, TC_02, TC_03, TC_04, TC_05, TC_06, TC_07, TC_08, TC_09, TC_10, TC_11, TC_12, TC_13, TC_14, TC_15, TC_16, TC_17, TC_18] global serial if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]: @@ -493,12 +558,12 @@ def main(): funcMap = { -'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04, 'TC_05': TC_05, -'TC_06': TC_06, 'TC_07': TC_07, 'TC_08': TC_08, 'TC_09': TC_09, 'TC_10': TC_10, -'TC_11': TC_11, 'TC_12': TC_12, 'TC_13': TC_13, 'TC_14': TC_14, 'TC_15': TC_15, 'TC_16': TC_16, -'TOOL_TC_01': TC_01, 'TOOL_TC_02': TC_02, 'TOOL_TC_03': TC_03, 'TOOL_TC_04': TC_04, 'TOOL_TC_05': TC_05, -'TOOL_TC_06': TC_06, 'TOOL_TC_07': TC_07, 'TOOL_TC_08': TC_08, 'TOOL_TC_09': TC_09, 'TOOL_TC_10': TC_10, -'TOOL_TC_11': TC_11, 'TOOL_TC_12': TC_12, 'TOOL_TC_13': TC_13, 'TOOL_TC_14': TC_14, 'TOOL_TC_15': TC_15, 'TOOL_TC_16': TC_16 +'TC_01': TC_01, 'TC_02': TC_02, 'TC_03': TC_03, 'TC_04': TC_04, 'TC_05': TC_05, 'TC_06': TC_06, +'TC_07': TC_07, 'TC_08': TC_08, 'TC_09': TC_09, 'TC_10': TC_10, 'TC_11': TC_11, 'TC_12': TC_12, +'TC_13': TC_13, 'TC_14': TC_14, 'TC_15': TC_15, 'TC_16': TC_16, 'TC_17': TC_17, 'TC_18': TC_17_18, +'TOOL_TC_01': TC_01, 'TOOL_TC_02': TC_02, 'TOOL_TC_03': TC_03, 'TOOL_TC_04': TC_04, 'TOOL_TC_05': TC_05, 'TOOL_TC_06': TC_06, +'TOOL_TC_07': TC_07, 'TOOL_TC_08': TC_08, 'TOOL_TC_09': TC_09, 'TOOL_TC_10': TC_10, 'TOOL_TC_11': TC_11, 'TOOL_TC_12': TC_12, +'TOOL_TC_13': TC_13, 'TOOL_TC_14': TC_14, 'TOOL_TC_15': TC_15, 'TOOL_TC_16': TC_16, 'TOOL_TC_17': TC_17, 'TOOL_TC_18': TC_17_18 }