49669870d4c4cb0509339a16e0bb7a1381f0d742
[platform/core/dotnet/launcher.git] / tests / TCs / 4_TAC / TAC.py
1 #!/usr/bin/env python3
2 import os, subprocess, sys, argparse
3 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
4
5 from time import sleep
6 from Utils import *
7
8
9 module_name = "TAC"
10
11 # The `Launcher_TC_TAC_01` application must have TAC applied.
12 def TC_01():
13     sln_name = "Launcher_TC_TAC_01.Tizen"
14
15     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
16     if tpk_path == None:
17         return f"FAIL : Get the tpk path for {sln_name}"
18
19     if "OK" not in app_install(f"{tpk_path}"):
20         return f"FAIL : Install the application for {tpk_path}"
21
22     pkg_id = f"org.tizen.example.Launcher_TC_TAC_01.Tizen"
23
24     root_path = get_root_path(f"{pkg_id}")
25     if root_path == "None":
26         return f"FAIL : Get the root path for {pkg_id}"
27
28     if not exist(f"{root_path}/bin/.tac_symlink"):
29         return "FAIL : The .tac_symlink folder should exist"
30
31     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
32     lines1 = [l for l in raw.splitlines()]
33     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.6.0.967/ -name *.dll -not -name *.ni.dll")
34     lines2 = [l for l in raw.splitlines()]
35     if len(lines1) != len(lines2):
36         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
37
38     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
39     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
40     for dll in lines:
41         origin_path = dll.split("->")[1].strip()
42         if not exist(f"{origin_path}"):
43             return "FAIL : The original file of the symbolic link must exist"
44
45     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
46     if 0 == pid:
47         return f"FAIL : Get the pid for {pkg_id}"
48
49     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
50     if (f"{DOTNET_DIR}Xamarin.Forms/4.6.0.967/Xamarin.Forms.Platform.Tizen.dll" not in raw) and \
51        (f"{DOTNET_DIR}Xamarin.Forms/4.6.0.967/Xamarin.Forms.Core.dll" not in raw) and \
52        (f"{DOTNET_DIR}Xamarin.Forms/4.6.0.967/Xamarin.Forms.Platform.dll" not in raw):
53         return "FAIL : The Xamarin.Forms in the TAC should be loaded when running the application"
54
55     cmd(f"shell app_launcher -t {pkg_id}")
56
57     return "PASS"
58
59 # The `Launcher_TC_TAC_02` application must have TAC applied.
60 def TC_02():
61     sln_name = "Launcher_TC_TAC_02.Tizen"
62
63     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
64     if tpk_path == None:
65         return f"FAIL : Get the tpk path for {sln_name}"
66
67     if "OK" not in app_install(f"{tpk_path}"):
68         return f"FAIL : Install the application for {tpk_path}"
69
70     pkg_id = f"org.tizen.example.Launcher_TC_TAC_00.Tizen"
71
72     root_path = get_root_path(f"{pkg_id}")
73     if root_path == "None":
74         return f"FAIL : Get the root path for {pkg_id}"
75
76     if not exist(f"{root_path}/bin/.tac_symlink"):
77         return "FAIL : The .tac_symlink folder should exist"
78
79     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
80     lines1 = [l for l in raw.splitlines()]
81     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.8.0.1364/ -name *.dll -not -name *.ni.dll")
82     lines2 = [l for l in raw.splitlines()]
83     raw = cmd(f"shell find {DOTNET_DIR}Newtonsoft.Json/12.0.1/ -name *.dll -not -name *.ni.dll")
84     lines3 = [l for l in raw.splitlines()]
85     if len(lines1) != len(lines2)+len(lines3):
86         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
87
88     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
89     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
90     for dll in lines:
91         origin_path = dll.split("->")[1].strip()
92         if not exist(f"{origin_path}"):
93             return "FAIL : The original file of the symbolic link must exist"
94
95     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
96     if 0 == pid:
97         return f"FAIL : Get the pid for {pkg_id}"
98
99     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
100     if (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1364/Xamarin.Forms.Platform.Tizen.dll" not in raw) and \
101        (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1364/Xamarin.Forms.Core.dll" not in raw) and \
102        (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1364/Xamarin.Forms.Platform.dll" not in raw):
103         return "FAIL : The Xamarin.Forms in the TAC should be loaded when running the application"
104
105     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Newtonsoft.Json.dll")
106     if f"{DOTNET_DIR}Newtonsoft.Json/12.0.1/Newtonsoft.Json.dll" not in raw:
107         return "FAIL : The Newtonsoft.Json in the TAC should be loaded when running the application"
108
109     cmd(f"shell app_launcher -t {pkg_id}")
110
111     return "PASS"
112
113 # The `Launcher_TC_TAC_03` application is normally TAC applied when updating.
114 def TC_03():
115     sln_name = "Launcher_TC_TAC_03.Tizen"
116
117     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
118     if tpk_path == None:
119         return f"FAIL : Get the tpk path for {sln_name}"
120
121     if "OK" not in app_install(f"{tpk_path}"):
122         return f"FAIL : Install the application for {tpk_path}"
123
124     pkg_id = f"org.tizen.example.Launcher_TC_TAC_00.Tizen"
125
126     root_path = get_root_path(f"{pkg_id}")
127     if root_path == "None":
128         return f"FAIL : Get the root path for {pkg_id}"
129
130     if not exist(f"{root_path}/bin/.tac_symlink"):
131         return "FAIL : The .tac_symlink folder should exist"
132
133     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
134     lines1 = [l for l in raw.splitlines()]
135     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.8.0.1687/ -name *.dll -not -name *.ni.dll")
136     lines2 = [l for l in raw.splitlines()]
137     raw = cmd(f"shell find {DOTNET_DIR}sqlite-net-base/1.7.335/ -name *.dll -not -name *.ni.dll")
138     lines3 = [l for l in raw.splitlines()]
139     raw = cmd(f"shell find {DOTNET_DIR}SQLitePCLRaw.core/2.0.3/ -name *.dll -not -name *.ni.dll")
140     lines4 = [l for l in raw.splitlines()]
141     if len(lines1) != len(lines2)+len(lines3)+len(lines4):
142         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
143
144     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
145     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
146     for dll in lines:
147         origin_path = dll.split("->")[1].strip()
148         if not exist(f"{origin_path}"):
149             return "FAIL : The original file of the symbolic link must exist"
150
151     if exist(f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1364/ -name *.dll"):
152         return f"FAIL : The Xamarin.Forms/4.8.0.1364 nuget should not exist in {DOTNET_DIR}"
153
154     if exist(f"{DOTNET_DIR}Newtonsoft.Json/12.0.1/ -name *.dll"):
155         return f"FAIL : The Newtonsoft.Json/12.0.1 nuget should not exist in {DOTNET_DIR}"
156
157     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
158     if 0 == pid:
159         return f"FAIL : Get the pid for {pkg_id}"
160
161     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
162     if (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1687/Xamarin.Forms.Platform.Tizen.dll" not in raw) and \
163        (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1687/Xamarin.Forms.Core.dll" not in raw) and \
164        (f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1687/Xamarin.Forms.Platform.dll" not in raw):
165         return "FAIL : The Xamarin.Forms in the TAC should be loaded when running the application"
166
167     raw = cmd(f"shell cat /proc/{pid}/smaps | grep SQLite-net.dll")
168     if f"{DOTNET_DIR}sqlite-net-base/1.7.335/SQLite-net.dll" not in raw:
169         return "FAIL : The sqlite-net-base in the TAC should be loaded when running the application"
170
171     raw = cmd(f"shell cat /proc/{pid}/smaps | grep SQLitePCLRaw.core.dll")
172     if f"{DOTNET_DIR}SQLitePCLRaw.core/2.0.3/SQLitePCLRaw.core.dll" not in raw:
173         return "FAIL : The SQLitePCLRaw.core in the TAC should be loaded when running the application"
174
175     cmd(f"shell app_launcher -t {pkg_id}")
176
177     return "PASS"
178
179 # The `Launcher_TC_TAC_04` application should not apply TAC when updating.
180 def TC_04():
181     sln_name = "Launcher_TC_TAC_04.Tizen"
182
183     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
184     if tpk_path == None:
185         return f"FAIL : Get the tpk path for {sln_name}"
186
187     if "OK" not in app_install(f"{tpk_path}"):
188         return f"FAIL : Install the application for {tpk_path}"
189
190     pkg_id = f"org.tizen.example.Launcher_TC_TAC_00.Tizen"
191
192     root_path = get_root_path(f"{pkg_id}")
193     if root_path == "None":
194         return f"FAIL : Get the root path for {pkg_id}"
195
196     if exist(f"{root_path}/bin/.tac_symlink"):
197         return "FAIL : The .tac_symlink folder should not exist"
198
199     if exist(f"{DOTNET_DIR}Xamarin.Forms/4.8.0.1364/ -name *.dll"):
200         return f"FAIL : The Xamarin.Forms/4.8.0.1364 nuget should not exist in {DOTNET_DIR}"
201
202     if exist(f"{DOTNET_DIR}Newtonsoft.Json/12.0.1/ -name *.dll"):
203         return f"FAIL : The Newtonsoft.Json/12.0.1 nuget should not exist in {DOTNET_DIR}"
204
205     if exist(f"{DOTNET_DIR}sqlite-net-base/1.7.335/ -name *.dll"):
206         return f"FAIL : The sqlite-net-base/1.7.335 nuget should not exist in {DOTNET_DIR}"
207
208     if exist(f"{DOTNET_DIR}SQLitePCLRaw.core/2.0.3/ -name *.dll"):
209         return f"FAIL : The SQLitePCLRaw.core/2.0.3 nuget should not exist in {DOTNET_DIR}"
210
211     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
212     if 0 == pid:
213         return f"FAIL : Get the pid for {pkg_id}"
214
215     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
216     if (f"{root_path}/bin/Xamarin.Forms.Platform.Tizen.dll" not in raw) and \
217        (f"{root_path}/bin/Xamarin.Forms.Core.dll" not in raw) and \
218        (f"{root_path}/bin/Xamarin.Forms.Platform.dll" not in raw):
219         return "FAIL : The Xamarin.Forms in the application should be loaded when running the application"
220
221     cmd(f"shell app_launcher -t {pkg_id}")
222
223     return "PASS"
224
225 # The `Launcher_TC_TAC_05`, `Launcher_TC_TAC_06` applications using the same nuget are normally TAC applied.
226 def TC_05():
227     sln_name = "Launcher_TC_TAC_05.Tizen"
228
229     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
230     if tpk_path == None:
231         return f"FAIL : Get the tpk path for {sln_name}"
232
233     if "OK" not in app_install(f"{tpk_path}"):
234         return f"FAIL : Install the application for {tpk_path}"
235
236     pkg_id1 = f"org.tizen.example.Launcher_TC_TAC_05.Tizen"
237
238     root_path = get_root_path(f"{pkg_id1}")
239     if root_path == "None":
240         return f"FAIL : Get the root path for {pkg_id1}"
241
242     if not exist(f"{root_path}/bin/.tac_symlink"):
243         return "FAIL : The .tac_symlink folder should exist"
244
245     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
246     lines1 = [l for l in raw.splitlines()]
247     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/ -name *.dll -not -name *.ni.dll")
248     lines2 = [l for l in raw.splitlines()]
249     if len(lines1) != len(lines2):
250         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
251
252     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
253     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
254     for dll in lines:
255         origin_path = dll.split("->")[1].strip()
256         if not exist(f"{origin_path}"):
257             return "FAIL : The original file of the symbolic link must exist"
258
259     sln_name = "Launcher_TC_TAC_06.Tizen"
260
261     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
262     if tpk_path == None:
263         return f"FAIL : Get the tpk path for {sln_name}"
264
265     if "OK" not in app_install(f"{tpk_path}"):
266         return f"FAIL : Install the application for {tpk_path}"
267
268     pkg_id2 = f"org.tizen.example.Launcher_TC_TAC_06.Tizen"
269
270     root_path = get_root_path(f"{pkg_id2}")
271     if root_path == "None":
272         return f"FAIL : Get the root path for {pkg_id2}"
273
274     if not exist(f"{root_path}/bin/.tac_symlink"):
275         return "FAIL : The .tac_symlink folder should exist"
276
277     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
278     lines1 = [l for l in raw.splitlines()]
279     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/ -name *.dll -not -name *.ni.dll")
280     lines2 = [l for l in raw.splitlines()]
281     if len(lines1) != len(lines2):
282         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
283
284     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
285     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
286     for dll in lines:
287         origin_path = dll.split("->")[1].strip()
288         if not exist(f"{origin_path}"):
289             return "FAIL : The original file of the symbolic link must exist"
290
291     raw = cmd(f"uninstall {pkg_id1}")
292     if "key[end] val[ok]" not in raw:
293         return f"FAIL : Uninstall the application for {pkg_id1}"
294
295     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
296     lines1 = [l for l in raw.splitlines()]
297     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/ -name *.dll -not -name *.ni.dll")
298     lines2 = [l for l in raw.splitlines()]
299     if len(lines1) != len(lines2):
300         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
301
302     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
303     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
304     for dll in lines:
305         origin_path = dll.split("->")[1].strip()
306         if not exist(f"{origin_path}"):
307             return "FAIL : The original file of the symbolic link must exist"
308
309     pid = launch_and_get_pid(f"-e", f"{pkg_id2}")
310     if 0 == pid:
311         return f"FAIL : Get the pid for {pkg_id2}"
312
313     raw = cmd(f"shell cat /proc/{pid}/smaps | grep Xamarin.Forms.*.dll")
314     if (f"{DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/Xamarin.Forms.Platform.Tizen.dll" not in raw) and \
315        (f"{DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/Xamarin.Forms.Core.dll" not in raw) and \
316        (f"{DOTNET_DIR}Xamarin.Forms/5.0.0.1558-pre3/Xamarin.Forms.Platform.dll" not in raw):
317         return "FAIL : The Xamarin.Forms in the TAC should be loaded when running the application"
318
319     cmd(f"shell app_launcher -t {pkg_id2}")
320
321     return "PASS"
322
323 # The `Launcher_TC_TAC_07` application is normally TAC applied when uninstall.
324 def TC_06():
325     sln_name = "Launcher_TC_TAC_07.Tizen"
326
327     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
328     if tpk_path == None:
329         return f"FAIL : Get the tpk path for {sln_name}"
330
331     if "OK" not in app_install(f"{tpk_path}"):
332         return f"FAIL : Install the application for {tpk_path}"
333
334     pkg_id = f"org.tizen.example.Launcher_TC_TAC_07.Tizen"
335
336     root_path = get_root_path(f"{pkg_id}")
337     if root_path == "None":
338         return f"FAIL : Get the root path for {pkg_id}"
339
340     if not exist(f"{root_path}/bin/.tac_symlink"):
341         return "FAIL : The .tac_symlink folder should exist"
342
343     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
344     lines1 = [l for l in raw.splitlines()]
345     raw = cmd(f"shell find {DOTNET_DIR}Xamarin.Forms/4.4.0.991864/ -name *.dll -not -name *.ni.dll")
346     lines2 = [l for l in raw.splitlines()]
347     if len(lines1) != len(lines2):
348         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
349
350     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
351     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
352     for dll in lines:
353         origin_path = dll.split("->")[1].strip()
354         if not exist(f"{origin_path}"):
355             return "FAIL : The original file of the symbolic link must exist"
356
357     raw = cmd(f"uninstall {pkg_id}")
358     if "key[end] val[ok]" not in raw:
359         return f"FAIL : Uninstall the application for {pkg_id}"
360
361     if exist(f"{DOTNET_DIR}Xamarin.Forms/4.4.0.991864/ -name *.dll"):
362         return f"FAIL : The Xamarin.Forms/4.4.0.991864 nuget should not exist in {DOTNET_DIR}"
363
364     return "PASS"
365
366 # The `Launcher_TC_TAC_08` application should be applied to TAC, but The `Launcher_TC_TAC_09` application should not be applied to TAC.
367 def TC_07():
368     raw = cmd(f"shell find {FRAMEWORK_DIR}/XSF.*")
369     if "XSF.dll" in raw:
370         cmd(f"shell mv {FRAMEWORK_DIR}/XSF.dll {FRAMEWORK_DIR}/XSF.dll2")
371     elif "XSF.ni.dll" in raw:
372         cmd(f"shell mv {FRAMEWORK_DIR}/XSF.ni.dll {FRAMEWORK_DIR}/XSF.ni.dll2")
373
374     sln_name = "Launcher_TC_TAC_08.Tizen"
375
376     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
377     if tpk_path == None:
378         return f"FAIL : Get the tpk path for {sln_name}"
379
380     if "OK" not in app_install(f"{tpk_path}"):
381         return f"FAIL : Install the application for {tpk_path}"
382
383     pkg_id = f"org.tizen.example.Launcher_TC_TAC_08.Tizen"
384
385     root_path = get_root_path(f"{pkg_id}")
386     if root_path == "None":
387         return f"FAIL : Get the root path for {pkg_id}"
388
389     if not exist(f"{root_path}/bin/.tac_symlink"):
390         return "FAIL : The .tac_symlink folder should exist"
391
392     raw = cmd(f"shell find {root_path}/bin/.tac_symlink/ -name *.dll -not -name *.ni.dll")
393     lines1 = [l for l in raw.splitlines()]
394     raw = cmd(f"shell find {DOTNET_DIR}XSF/1.0.0.0/ -name *.dll -not -name *.ni.dll")
395     lines2 = [l for l in raw.splitlines()]
396     if len(lines1) != len(lines2):
397         return "FAIL : The number of .dll in the .tac_symlink and .dll in the TAC must match"
398
399     raw = cmd(f"shell ls -alZ {root_path}/bin/.tac_symlink/*.dll")
400     lines = [l for l in raw.splitlines() if ".ni.dll" not in l]
401     for dll in lines:
402         origin_path = dll.split("->")[1].strip()
403         if not exist(f"{origin_path}"):
404             return "FAIL : The original file of the symbolic link must exist"
405
406     sln_name = "Launcher_TC_TAC_09.Tizen"
407
408     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
409     if tpk_path == None:
410         return f"FAIL : Get the tpk path for {sln_name}"
411
412     if "OK" not in app_install(f"{tpk_path}"):
413         return f"FAIL : Install the application for {tpk_path}"
414
415     pkg_id = f"org.tizen.example.Launcher_TC_TAC_09.Tizen"
416
417     root_path = get_root_path(f"{pkg_id}")
418     if root_path == "None":
419         return f"FAIL : Get the root path for {pkg_id}"
420
421     raw = cmd(f"shell find {root_path}/bin/.tac_symlink -name XSF.dll -not -name XSF.ni.dll")
422     lines = [l for l in raw.splitlines()]
423     if len(lines) != 0:
424         return "FAIL : The version is the same Nuget, but the SHA value is different"
425
426     pid = launch_and_get_pid(f"-e", f"{pkg_id}")
427     if 0 == pid:
428         return f"FAIL : Get the pid for {pkg_id}"
429
430     raw = cmd(f"shell cat /proc/{pid}/smaps | grep XSF.dll")
431     if f"{root_path}/bin/XSF.dll" not in raw:
432         return "FAIL : The XSF in the application should be loaded when running the application"
433
434     cmd(f"shell app_launcher -t {pkg_id}")
435
436     return "PASS"
437
438 # The Launcher_TC_TAC_10 application should match the information of nuget with the value of TAC DB.
439 def TC_08():
440     sln_name = "Launcher_TC_TAC_10.Tizen"
441
442     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
443     if tpk_path == None:
444         return f"FAIL : Get the tpk path for {sln_name}"
445
446     if "OK" not in app_install(f"{tpk_path}"):
447         return f"FAIL : Install the application for {tpk_path}"
448
449     pkg_id = f"org.tizen.example.Launcher_TC_TAC_10.Tizen"
450
451     root_path = get_root_path(f"{pkg_id}")
452     if root_path == "None":
453         return f"FAIL : Get the root path for {pkg_id}"
454
455     if not exist(f"{root_path}/bin/.tac_symlink"):
456         return "FAIL : The .tac_symlink folder should exist"
457
458     raw = subprocess.run((f"sdb -s {serial} shell sqlite3 {DOTNET_DIR}.TAC.App.list.db").split(), stdout=subprocess.PIPE, input=f"select * from TAC;\n.q\n", encoding="utf-8").stdout
459     lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
460     for rcd in lines:
461         if ("Xamarin.Forms/4.8.0.1560" not in rcd) and \
462            ("Google.Apis.Core/1.49.0" not in rcd) and \
463            ("Google.Apis/1.49.0" not in rcd) and \
464            ("Newtonsoft.Json/12.0.3" not in rcd):
465             return "FAIL : TAC database must have a valid value"
466
467     return "PASS"
468
469 # The Launcher_TC_TAC_11 application must match the version of the nuget in .deps.json and the version of the nuget in TAC DB.
470 def TC_09():
471     sln_name = "Launcher_TC_TAC_11.Tizen"
472
473     tpk_path = get_tpk_path(tpk_list, f"{sln_name}")
474     if tpk_path == None:
475         return f"FAIL : Get the tpk path for {sln_name}"
476
477     if "OK" not in app_install(f"{tpk_path}"):
478         return f"FAIL : Install the application for {tpk_path}"
479
480     pkg_id = f"org.tizen.example.Launcher_TC_TAC_11.Tizen"
481
482     root_path = get_root_path(f"{pkg_id}")
483     if root_path == "None":
484         return f"FAIL : Get the root path for {pkg_id}"
485
486     raw = subprocess.run((f"sdb -s {serial} shell sqlite3 {DOTNET_DIR}.TAC.App.list.db").split(), stdout=subprocess.PIPE, input=f"select * from TAC;\n.q\n", encoding="utf-8").stdout
487     lines = [l for l in raw.splitlines() if f"{pkg_id}" in l]
488     for nuget in lines:
489         name = nuget.split("|")[3]
490         version = nuget.split("|")[4]
491         raw = cmd(f"shell cat {root_path}/{sln_name}.deps.json | grep {name}/")
492         if f"{version}" not in f"{raw}":
493             return "FAIL : "
494
495     return "PASS"
496
497 # Run the test
498 def run():
499     cmd(f"root on")
500     cmd(f"shell mount -o remount,rw /")
501
502     global tpk_list
503     tpk_list = search_tpk(f"{module_name}")
504
505     p = run_tc_array(module_name, tc_array)
506     f = len(tc_array) - p
507     r = round(((p / len(tc_array)) * 100), 2)
508     print(f"--- {module_name} TCT Result ---\nFAIL : [{f}] / PASS : [{p}] - [{r}%]\n")
509
510 # Uninstall the application and restore to original state
511 def clean():
512     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_01.Tizen")
513     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_00.Tizen")
514     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_06.Tizen")
515     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_07.Tizen")
516     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_08.Tizen")
517     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_09.Tizen")
518     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_10.Tizen")
519     cmd(f"uninstall org.tizen.example.Launcher_TC_TAC_11.Tizen")
520
521     cmd(f"shell mv {FRAMEWORK_DIR}/XSF.dll2 {FRAMEWORK_DIR}/XSF.dll")
522     cmd(f"shell mv {FRAMEWORK_DIR}/XSF.ni.dll2 {FRAMEWORK_DIR}/XSF.ni.dll")
523
524 # Main entry point
525 def main():
526     parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter)
527     parser.add_argument("TC_NUMBER", type=str, nargs="*", help="Individual excution")
528     args = parser.parse_args()
529
530     global tc_array
531     if args.TC_NUMBER and "TC_" in args.TC_NUMBER[0]:
532         tc_array = []
533         for tc_num in args.TC_NUMBER:
534             if tc_num not in funcMap:
535                 print(f"There is no {tc_num} test.")
536                 exit(1)
537             else:
538                 tc_array.append(funcMap[tc_num])
539     else:
540         tc_array = [TC_01, TC_02, TC_03, TC_04, TC_05, TC_06, TC_07, TC_08, TC_09]
541
542     global serial
543     if len(sys.argv) >= 2 and "TC_" not in sys.argv[1]:
544         serial = read_serial(sys.argv[1])
545     else:
546         serial = read_serial(None)
547
548     if serial is None:
549         print("No connected device(s).")
550         exit(1)
551
552     device = get_device_type()
553     print(f"=== Dotnet-Launcher [{device}] Test Case - ({module_name}) ===")
554
555     run()
556     clean()
557
558
559 funcMap = {
560 '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,
561 'TAC_TC_01': TC_01, 'TAC_TC_02': TC_02, 'TAC_TC_03': TC_03, 'TAC_TC_04': TC_04, 'TAC_TC_05': TC_05,
562 'TAC_TC_06': TC_06, 'TAC_TC_07': TC_07, 'TAC_TC_08': TC_08, 'TAC_TC_09': TC_09
563 }
564
565
566 if __name__ == "__main__":
567     try:
568         main()
569     except KeyboardInterrupt:
570         print("\nExit (Pressed Ctrl+C)")
571         exit(1)