diff --git a/arkui/BUILD.gn b/arkui/BUILD.gn index 79a432d38bd165392b042ced1539ebc5d529761d..6f42eda94d339ccd12657bf6cd6dda705e0bd167 100644 --- a/arkui/BUILD.gn +++ b/arkui/BUILD.gn @@ -34,5 +34,6 @@ group("arkui") { "ace_napi_test:ActsAceNapiEtsTest", "ace_standard:ActsAceStandardTest", "ace_standard_video:ActsAceStandardVideoTest", + "libuv:libuvTest", ] } diff --git a/arkui/libuv/BUILD.gn b/arkui/libuv/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..05c237975bd3d76657a62a3be6742bf9a035f17d --- /dev/null +++ b/arkui/libuv/BUILD.gn @@ -0,0 +1,245 @@ +# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +import("//test/xts/acts/arkui/libuv/comm.gni") + +ohos_static_library("libuvTestStatic") { + include_dirs = [ + "//third_party/libuv/include", + "//third_party/libuv/src", + "//third_party/libuv/src/unix", + ] + sources = [ + "//third_party/libuv/test/blackhole-server.c", + "//third_party/libuv/test/echo-server.c", + "//third_party/libuv/test/runner-unix.c", + "//third_party/libuv/test/runner.c", + "//third_party/libuv/test/test-active.c", + "//third_party/libuv/test/test-async-null-cb.c", + "//third_party/libuv/test/test-async.c", + "//third_party/libuv/test/test-barrier.c", + "//third_party/libuv/test/test-callback-order.c", + "//third_party/libuv/test/test-callback-stack.c", + "//third_party/libuv/test/test-close-fd.c", + "//third_party/libuv/test/test-close-order.c", + "//third_party/libuv/test/test-condvar.c", + "//third_party/libuv/test/test-connect-unspecified.c", + "//third_party/libuv/test/test-connection-fail.c", + "//third_party/libuv/test/test-cwd-and-chdir.c", + "//third_party/libuv/test/test-default-loop-close.c", + "//third_party/libuv/test/test-delayed-accept.c", + "//third_party/libuv/test/test-dlerror.c", + "//third_party/libuv/test/test-eintr-handling.c", + "//third_party/libuv/test/test-embed.c", + "//third_party/libuv/test/test-emfile.c", + "//third_party/libuv/test/test-env-vars.c", + "//third_party/libuv/test/test-error.c", + "//third_party/libuv/test/test-fail-always.c", + "//third_party/libuv/test/test-fork.c", + "//third_party/libuv/test/test-fs-copyfile.c", + "//third_party/libuv/test/test-fs-event.c", + "//third_party/libuv/test/test-fs-fd-hash.c", + "//third_party/libuv/test/test-fs-open-flags.c", + "//third_party/libuv/test/test-fs-poll.c", + "//third_party/libuv/test/test-fs-readdir.c", + "//third_party/libuv/test/test-fs.c", + "//third_party/libuv/test/test-get-currentexe.c", + "//third_party/libuv/test/test-get-loadavg.c", + "//third_party/libuv/test/test-get-memory.c", + "//third_party/libuv/test/test-get-passwd.c", + "//third_party/libuv/test/test-getaddrinfo.c", + "//third_party/libuv/test/test-gethostname.c", + "//third_party/libuv/test/test-getnameinfo.c", + "//third_party/libuv/test/test-getsockname.c", + "//third_party/libuv/test/test-getters-setters.c", + "//third_party/libuv/test/test-gettimeofday.c", + "//third_party/libuv/test/test-handle-fileno.c", + "//third_party/libuv/test/test-homedir.c", + "//third_party/libuv/test/test-hrtime.c", + "//third_party/libuv/test/test-idle.c", + "//third_party/libuv/test/test-idna.c", + "//third_party/libuv/test/test-ip-name.c", + "//third_party/libuv/test/test-ip4-addr.c", + "//third_party/libuv/test/test-ip6-addr.c", + "//third_party/libuv/test/test-ipc-heavy-traffic-deadlock-bug.c", + "//third_party/libuv/test/test-ipc-send-recv.c", + "//third_party/libuv/test/test-ipc.c", + "//third_party/libuv/test/test-loop-alive.c", + "//third_party/libuv/test/test-loop-close.c", + "//third_party/libuv/test/test-loop-configure.c", + "//third_party/libuv/test/test-loop-handles.c", + "//third_party/libuv/test/test-loop-stop.c", + "//third_party/libuv/test/test-loop-time.c", + "//third_party/libuv/test/test-metrics.c", + "//third_party/libuv/test/test-multiple-listen.c", + "//third_party/libuv/test/test-mutexes.c", + "//third_party/libuv/test/test-not-readable-nor-writable-on-read-error.c", + "//third_party/libuv/test/test-not-writable-after-shutdown.c", + "//third_party/libuv/test/test-osx-select.c", + "//third_party/libuv/test/test-pass-always.c", + "//third_party/libuv/test/test-ping-pong.c", + "//third_party/libuv/test/test-pipe-bind-error.c", + "//third_party/libuv/test/test-pipe-close-stdout-read-stdin.c", + "//third_party/libuv/test/test-pipe-connect-error.c", + "//third_party/libuv/test/test-pipe-connect-multiple.c", + "//third_party/libuv/test/test-pipe-connect-prepare.c", + "//third_party/libuv/test/test-pipe-getsockname.c", + "//third_party/libuv/test/test-pipe-pending-instances.c", + "//third_party/libuv/test/test-pipe-sendmsg.c", + "//third_party/libuv/test/test-pipe-server-close.c", + "//third_party/libuv/test/test-pipe-set-fchmod.c", + "//third_party/libuv/test/test-pipe-set-non-blocking.c", + "//third_party/libuv/test/test-platform-output.c", + "//third_party/libuv/test/test-poll-close-doesnt-corrupt-stack.c", + "//third_party/libuv/test/test-poll-close.c", + "//third_party/libuv/test/test-poll-closesocket.c", + "//third_party/libuv/test/test-poll-multiple-handles.c", + "//third_party/libuv/test/test-poll-oob.c", + "//third_party/libuv/test/test-poll.c", + "//third_party/libuv/test/test-process-priority.c", + "//third_party/libuv/test/test-process-title-threadsafe.c", + "//third_party/libuv/test/test-process-title.c", + "//third_party/libuv/test/test-queue-foreach-delete.c", + "//third_party/libuv/test/test-random.c", + "//third_party/libuv/test/test-readable-on-eof.c", + "//third_party/libuv/test/test-ref.c", + "//third_party/libuv/test/test-run-nowait.c", + "//third_party/libuv/test/test-run-once.c", + "//third_party/libuv/test/test-semaphore.c", + "//third_party/libuv/test/test-shutdown-close.c", + "//third_party/libuv/test/test-shutdown-eof.c", + "//third_party/libuv/test/test-shutdown-simultaneous.c", + "//third_party/libuv/test/test-shutdown-twice.c", + "//third_party/libuv/test/test-signal-multiple-loops.c", + "//third_party/libuv/test/test-signal-pending-on-close.c", + "//third_party/libuv/test/test-signal.c", + "//third_party/libuv/test/test-socket-buffer-size.c", + "//third_party/libuv/test/test-spawn.c", + "//third_party/libuv/test/test-stdio-over-pipes.c", + "//third_party/libuv/test/test-strscpy.c", + "//third_party/libuv/test/test-tcp-alloc-cb-fail.c", + "//third_party/libuv/test/test-tcp-bind-error.c", + "//third_party/libuv/test/test-tcp-bind6-error.c", + "//third_party/libuv/test/test-tcp-close-accept.c", + "//third_party/libuv/test/test-tcp-close-reset.c", + "//third_party/libuv/test/test-tcp-close-while-connecting.c", + "//third_party/libuv/test/test-tcp-close.c", + "//third_party/libuv/test/test-tcp-connect-error-after-write.c", + "//third_party/libuv/test/test-tcp-connect-error.c", + "//third_party/libuv/test/test-tcp-connect-timeout.c", + "//third_party/libuv/test/test-tcp-connect6-error.c", + "//third_party/libuv/test/test-tcp-create-socket-early.c", + "//third_party/libuv/test/test-tcp-flags.c", + "//third_party/libuv/test/test-tcp-oob.c", + "//third_party/libuv/test/test-tcp-open.c", + + # "//third_party/libuv/test/test-metrics-idle-time.c", + # "//third_party/libuv/test/test-metrics-idle-time-thread.c", + # "//third_party/libuv/test/test-metrics-idle-time-zero.c", + "//third_party/libuv/test/test-tcp-read-stop-start.c", + "//third_party/libuv/test/test-tcp-read-stop.c", + "//third_party/libuv/test/test-tcp-shutdown-after-write.c", + "//third_party/libuv/test/test-tcp-try-write-error.c", + "//third_party/libuv/test/test-tcp-try-write.c", + "//third_party/libuv/test/test-tcp-unexpected-read.c", + "//third_party/libuv/test/test-tcp-write-after-connect.c", + "//third_party/libuv/test/test-tcp-write-fail.c", + "//third_party/libuv/test/test-tcp-write-queue-order.c", + "//third_party/libuv/test/test-tcp-write-to-half-open-connection.c", + "//third_party/libuv/test/test-tcp-writealot.c", + "//third_party/libuv/test/test-test-macros.c", + "//third_party/libuv/test/test-thread-equal.c", + "//third_party/libuv/test/test-thread.c", + "//third_party/libuv/test/test-threadpool-cancel.c", + "//third_party/libuv/test/test-threadpool.c", + "//third_party/libuv/test/test-timer-again.c", + "//third_party/libuv/test/test-timer-from-check.c", + "//third_party/libuv/test/test-timer.c", + "//third_party/libuv/test/test-tmpdir.c", + "//third_party/libuv/test/test-tty-duplicate-key.c", + "//third_party/libuv/test/test-tty-escape-sequence-processing.c", + "//third_party/libuv/test/test-tty.c", + "//third_party/libuv/test/test-udp-alloc-cb-fail.c", + "//third_party/libuv/test/test-udp-bind.c", + "//third_party/libuv/test/test-udp-connect.c", + "//third_party/libuv/test/test-udp-connect6.c", + "//third_party/libuv/test/test-udp-create-socket-early.c", + "//third_party/libuv/test/test-udp-dgram-too-big.c", + "//third_party/libuv/test/test-udp-ipv6.c", + "//third_party/libuv/test/test-udp-mmsg.c", + "//third_party/libuv/test/test-udp-multicast-interface.c", + "//third_party/libuv/test/test-udp-multicast-interface6.c", + "//third_party/libuv/test/test-udp-multicast-join.c", + "//third_party/libuv/test/test-udp-multicast-join6.c", + "//third_party/libuv/test/test-udp-multicast-ttl.c", + "//third_party/libuv/test/test-udp-open.c", + "//third_party/libuv/test/test-udp-options.c", + "//third_party/libuv/test/test-udp-send-and-recv.c", + "//third_party/libuv/test/test-udp-send-hang-loop.c", + "//third_party/libuv/test/test-udp-send-immediate.c", + "//third_party/libuv/test/test-udp-send-unreachable.c", + "//third_party/libuv/test/test-udp-sendmmsg-error.c", + "//third_party/libuv/test/test-udp-try-send.c", + "//third_party/libuv/test/test-uname.c", + "//third_party/libuv/test/test-walk-handles.c", + "//third_party/libuv/test/test-watcher-cross-stop.c", + ] + deps = [ "//third_party/libuv:uv_static" ] +} + +ohos_executable("libuvruntest") { + include_dirs = [ + "//third_party/libuv/include", + "//third_party/libuv/src", + "//third_party/libuv/src/unix", + ] + sources = [ "//third_party/libuv/test/run-tests.c" ] + deps = [ ":libuvTestStatic" ] +} + +ohos_moduletest_suite("ActsLibuvTestSuite") { + sources = [ "src/ActsLibuvTestSuite.cpp" ] + + include_dirs = [ + "//test/xts/acts/arkui/libuv/src", + "//third_party/libuv/test", + "//third_party/libuv/include", + "//third_party/libuv/src", + "//third_party/libuv/src/unix", + ] + deps = [ ":libuvTestStatic" ] + cflags = [ "-Wno-error" ] +} + +action("cpLibuv") { + testonly = true + script = "cplibuv.sh" + outputs = [ "${target_out_dir}/cplibuv.log" ] + deps = [ + ":ActsLibuvTestSuite", + ":libuvruntest", + ] +} + +group("libuvTest") { + testonly = true + if (is_standard_system) { + deps = [ + ":ActsLibuvTestSuite", + ":cpLibuv", + ":libuvruntest", + ] + } +} diff --git a/arkui/libuv/Test.json b/arkui/libuv/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..4f23ce05d02cfc8353584170cf2bb55680e1ed2f --- /dev/null +++ b/arkui/libuv/Test.json @@ -0,0 +1,35 @@ +{ + "description": "Config for ActsLibuvTestSuite test cases", + "driver": { + "module-name": "ActsLibuvTestSuite", + "native-test-timeout": "120000", + "native-test-device-path": "/data/local/tmp", + "runtime-hint": "100s", + "type": "CppTest" + }, + "kits": [ + { + "pre-push" : [ + ], + "post-push" : [ + "chmod -R 777 /data/local/tmp/*" + ], + "push": [ + "ActsLibuvTestSuite->/data/local/tmp/ActsLibuvTestSuite", + "libuvdata/libuvruntest->/data/local/tmp/libuvruntest " + ], + "type": "PushKit" + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test", + "cd /data/local/tmp" + ], + "teardown-localcommand": [ + "python testcases/libuvdata/genlocal.py" + ] + } + ] +} \ No newline at end of file diff --git a/arkui/libuv/comm.gni b/arkui/libuv/comm.gni new file mode 100644 index 0000000000000000000000000000000000000000..6d8d783a4cbc35e2f50f8cd40c8cedd122235a04 --- /dev/null +++ b/arkui/libuv/comm.gni @@ -0,0 +1,21 @@ +# Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +common_include = [ "//test/xts/acts/graphic/libuv/src" ] + +common_depends = [ "//third_party/libuv:uv_static" ] + +common_src = [ "../../ActsApp.cpp" ] +#import("//third_party/VK-GL-CTS/vk_gl_cts.gni") diff --git a/arkui/libuv/cplibuv.sh b/arkui/libuv/cplibuv.sh new file mode 100755 index 0000000000000000000000000000000000000000..a549b12edfe2ec7f75d80c4f1c0c64f0639074ea --- /dev/null +++ b/arkui/libuv/cplibuv.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright (C) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +mkdir -p "suites/acts/testcases/libuvdata" +cp -rf "../../test/xts/acts/arkui/libuv/genlocal.py" "suites/acts/testcases/libuvdata" +cp -rf "common/common/libuvruntest" "suites/acts/testcases/libuvdata" diff --git a/arkui/libuv/genlocal.py b/arkui/libuv/genlocal.py new file mode 100755 index 0000000000000000000000000000000000000000..b31525f10e4d457e91fd4c34e8edbc537d0d1396 --- /dev/null +++ b/arkui/libuv/genlocal.py @@ -0,0 +1,258 @@ +from ast import Return +import os +import sys +from unittest import suite + +G_SUITE = "" +G_MAXCASECNT = 5 +G_MUSTPASSPATH = "mustpass/" +G_MUSTPASSFILE = ".txt" +G_TMPPATH = "template/" +G_TMPDIRPATH = G_TMPPATH + "ace_ets_template" +G_HAPDIRPATH = "../act_etc_component_" +G_IMPORTTEST = "import {}Jsunit from \'./{}.test.ets\';" +G_IMPORTTESTCASE = "{}Jsunit()" +G_PATHDIRPATH = "/entry/src/main/ets/MainAbility/pages/" +G_PAGETEMPPATH = "/pagetemplate.ets" +G_PAGEATTRTEMPPATH = "/pageattrtemplate.ets" +G_TESTDIRPATH = "/entry/src/main/ets/test/" +G_TESTCASETEMPPATH = "/testcasetemplate.ets" +G_TESTTEMPPATH = "/List.test.ets" +G_LISTTESTETSPATH = "/entry/src/main/ets/test/List.test.ets" +G_PAGENAMEPATTERN = "##PAGENAME" +G_ATTRNAMEPATTERN = "##ATTRNAME" +G_LOWATTRNAMEPATTERN = "##LOWATTRNAME" +G_PAGENAMETESETPATTERN = "##PAGENAMETEST" +G_PAGEFILENAMEPATTERN = "##PAGEFILENAME" +G_SUITENAMEPATTERN = "##SUITENAME" +G_PAGENAMETESTPATTERN = "##PAGENAMETEXT" +G_CONFIGJSONPATH = "/entry/src/main/config.json" +G_BUILDGNPATH = "/BUILD.gn" +G_TESTJSONPATH = "/Test.json" +G_INDEXETSPATH = "/entry/src/main/ets/MainAbility/pages/index.ets" + +def writemultestcase(): + print("writemultestcase") + writemultestcasecpp() + print("writemulbuildgn") + writemulbuildgn() + +def writemulbuildgn(): + #生成buildgn + for suiteitem in G_SUITE: + subcasecnt = 0 + subattcnt = 0 + subgncnt = 0 + suiteitemcap = "".join(suiteitem[:1].upper() + suiteitem[1:]) + print("suite:", suiteitem, "----------------------") + #创建一个hap目录 + hapdirpath = G_HAPDIRPATH + suiteitem.lower() + if os.path.exists(hapdirpath): + os.system(r"rm -rf {}".format(hapdirpath)) + os.system(r"cp {} {} -r".format(G_TMPDIRPATH, hapdirpath)) + else: + os.system(r"cp {} {} -r".format(G_TMPDIRPATH, hapdirpath)) + + mustpass = G_MUSTPASSPATH + suiteitem + G_MUSTPASSFILE + with open(mustpass) as mastpassfile: + compdict = {"":1} + + importtestheads = [] + importtests = [] + for line in mastpassfile: + if line[0] == "#": + continue + line = line.replace("\n", "") + linelist = line.split(",") + suitename = linelist[0] + casename = linelist[1] + + if suitename in compdict: + #同文件里加属性 + ind = compdict[suitename] + subattcnt += 1 + #在page文件里追加attr内容 + suitenamecap = "".join(suitename[:1].upper() + suitename[1:]) + casenamecap = "".join(casename[:1].upper() + casename[1:]) + pagename = suitenamecap + casenamecap + pagenametext = suitename + "-" + casenamecap + pagefilename = hapdirpath + G_PATHDIRPATH + suitename + ".ets" + attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH + #print("addattr:", subattcnt, pagename, attrtmp) + with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile: + for attrtempline in attrtmpfile: + attrtempline = attrtempline.replace(" ", "\ ") + attrtempline = attrtempline.replace(G_PAGENAMETESTPATTERN, pagenametext) + attrtempline = attrtempline.replace(G_ATTRNAMEPATTERN, casename) + os.system(r"sed -i '{}a {}' {}".format(ind, attrtempline, pagefilename)) + ind += 1 + compdict[suitename] = ind + + else: + #创建不同页面 + subgncnt += 1 + subattcnt = 1 + ind = 29 + compdict[suitename] = ind + postfix = '%04d' % subgncnt + dirpath = suitename + postfix + temppagefilename = G_TMPPATH + G_PAGETEMPPATH + suitenamecap = "".join(suitename[:1].upper() + suitename[1:]) + casenamecap = "".join(casename[:1].upper() + casename[1:]) + pagename = suitename + casenamecap + capagename = suitenamecap + casenamecap + testname = pagename + pagefilename = hapdirpath + G_PATHDIRPATH + suitename + ".ets" + os.system(r"cp {} {}".format(temppagefilename, pagefilename)) + #替换page里的名称 + os.system(r"sed -i 's/{}/{}/g' {}".format(G_PAGENAMEPATTERN, capagename, pagefilename)) + #追加page里的attr + pagenametext = suitename + "-" + casenamecap + attrtmp = G_TMPPATH + G_PAGEATTRTEMPPATH + #print("addattr:", subattcnt, pagename, attrtmp) + with open(attrtmp, encoding="utf-8", mode="r") as attrtmpfile: + for attrtempline in attrtmpfile: + attrtempline = attrtempline.replace(" ", "\ ") + attrtempline = attrtempline.replace(G_PAGENAMETESTPATTERN, pagenametext) + attrtempline = attrtempline.replace(G_ATTRNAMEPATTERN, casename) + os.system(r"sed -i '{}a {}' {}".format(ind, attrtempline, pagefilename)) + ind += 1 + compdict[suitename] = ind + + temptestfilename = G_TMPPATH + G_TESTCASETEMPPATH + testfilename = hapdirpath + G_TESTDIRPATH + suitename + ".test.ets" + #print("createpage:", subgncnt, dirpath, pagefilename, testfilename) + os.system(r"cp {} {}".format(temptestfilename, testfilename)) + #替换test里的名称 + os.system(r"sed -i 's/{}/{}/g' {}".format(G_ATTRNAMEPATTERN, testname, testfilename)) + os.system(r"sed -i 's/{}/{}/g' {}".format(G_PAGENAMETESETPATTERN, testname+"Test", testfilename)) + os.system(r"sed -i 's/{}/{}/g' {}".format(G_PAGEFILENAMEPATTERN, pagename, testfilename)) + os.system(r"sed -i 's/{}/{}/g' {}".format(G_LOWATTRNAMEPATTERN, casename, testfilename)) + #替换config.json里的名称 + configjsonname = hapdirpath + G_CONFIGJSONPATH + os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, configjsonname)) + os.system(r"sed -i 's/{}/{}/g' {}".format(G_PAGEFILENAMEPATTERN, casenamecap, configjsonname)) + #替换BUILD.gn里的名称 + buildgnname = hapdirpath + G_BUILDGNPATH + os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, buildgnname)) + # formate gn + #print("Formate: dirpath:",buildgnname) + formatcmd = "cat "+buildgnname+" | ~/workspace/oh31/prebuilts/build-tools/linux-x86/bin/gn format --stdin > FORMAT_RESULT.gn;cp -f FORMAT_RESULT.gn "+buildgnname+";rm FORMAT_RESULT.gn" + os.system(formatcmd) + #替换index.ets里的名称 + indexetsname = hapdirpath + G_INDEXETSPATH + os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, indexetsname)) + + #替换Test.json里的名称 + testjsonname = hapdirpath + G_TESTJSONPATH + os.system(r"sed -i 's/{}/{}/g' {}".format(G_SUITENAMEPATTERN, suiteitemcap, testjsonname)) + + #G_IMPORTTEST = "import {} from './{}Jsunit.test';\n" + importtestheads.append(G_IMPORTTEST.format(testname, suitename)) + importtests.append(G_IMPORTTESTCASE.format(testname)) + subcasecnt += 1 + #print("importtestheads:", importtestheads) + #print("importtests:", importtests) + #插入List.test.ets,装载多个testcase + ind = 16 + for importtestsline in importtests: + os.system(r"sed -i '{}a \ \ {}' {}".format(ind, importtestsline, hapdirpath + G_LISTTESTETSPATH)) + ind += 1 + ind = 14 + for importtestheadsline in importtestheads: + os.system(r"sed -i '{}a {}' {}".format(ind, importtestheadsline, hapdirpath + G_LISTTESTETSPATH)) + ind += 1 + +def writemultestcasecpp(): + #生成testcase + for suiteitem in G_SUITE: + print("suite:", suiteitem) + +def removedir(rootdir): + for root,dirs,files in os.walk(rootdir, topdown=False): + for name in files: + os.remove(os.path.join(rootdir,name)) + for name in dirs: + os.rmdir(os.path.join(rootdir,name)) + os.rmdir(rootdir) + + +def printhelp(): + print("Need testsuite and codepattern:\n") + print("For example\n") + print("python3 .\GenerateTestCase.py apilack\n") + print("codepattern contains: apilack, attrlack\n") + +def new_report(bakdir, str): + files = os.listdir(bakdir) + lists = [] #列出目录的下所有文件和文件夹保存到lists + for f in files: + # if f.startswith(str): + if "latest" in f: + continue + lists.append(f) + + lists.sort(key=lambda fn:os.path.getmtime(bakdir + "/" + fn)) # 按时间排序 + file_new = os.path.join(bakdir,lists[-1]) # 获取最新的文件保存到file_new + print("latest file:", file_new) + return file_new + + +if __name__ == '__main__': + latestpath = new_report("reports", "") + tmpfile = "tmptestsuite.xml" + putfile = "/result/ActsLibuvTestSuite.xml" + tasklogfile = "/log/task_log.log" + putdir = latestpath+putfile + tasklogpath = latestpath+tasklogfile + + timelist = latestpath.split("/") + curtime = timelist[1].replace("\n", "") + testcaselist = [] + total = 0 + passcnt = 0 + failcnt = 0 + suitename = "" + #读取最近的tasklog文件 + with open(tasklogpath) as tasklogbuf: + #从tasklog文件中获取运行的testcase的信息 + for tasklogline in tasklogbuf: + if "[Start test suite [" in tasklogline: + suitelist = tasklogline.split("[Start test suite [") + suiteitem = suitelist[1].split("]") + suitename = suiteitem[0] + if "[ok " in tasklogline: + freslist = tasklogline.split("ok") + numcase = freslist[1] + numcase = numcase.replace(" ","") + numcase = numcase.replace("]","") + caseline = numcase.split("-") + total +=1 + passcnt += 1 + testcaselist.append(caseline[1]+"-true") + if "[not ok " in tasklogline: + freslist = tasklogline.split("not ok") + numcase = freslist[1] + numcase = numcase.replace(" ","") + numcase = numcase.replace("]","") + caseline = numcase.split("-") + total +=1 + failcnt += 1 + testcaselist.append(caseline[1]+"-false") + #print("tasklogfile line:", caseline[0], caseline[1]) + #将testcase信息生成文件 + xmlfile = open(tmpfile, mode='w+') + xmlfile.write("\n") + xmlfile.write("\n".format(suitename, curtime, failcnt, total, "{}")) + xmlfile.write(" \n".format(suitename, failcnt, total)) + for casename in testcaselist: + casename = casename.replace("\n","") + loccasename = casename.split("-") + recasename = loccasename[0] + casestate = loccasename[1] + xmlfile.write(" \n".format(recasename, suitename, casestate)) + xmlfile.write(" \n") + xmlfile.write("\n") + xmlfile.close() + #将tmp文件替换xts框架的result + os.system(r"cp {} {}".format(tmpfile, putdir)) \ No newline at end of file diff --git a/arkui/libuv/src/ActsLibuvTestSuite.cpp b/arkui/libuv/src/ActsLibuvTestSuite.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ad5f32493e5878d2e73cff5c8e155f2a9b794291 --- /dev/null +++ b/arkui/libuv/src/ActsLibuvTestSuite.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "ActsLibuvTestSuite.h" +extern "C"{ +#include "runner.h" +} + +namespace OHOS { + using namespace std; + using namespace testing::ext; + + // Preset action of the test suite, which is executed before the first test case + void ActsLibuvTestSuite::SetUpTestCase(void) + { + } + // Test suite cleanup action, which is executed after the last test case + void ActsLibuvTestSuite::TearDownTestCase(void) + { + } + // Preset action of the test case + void ActsLibuvTestSuite::SetUp() + { + } + // Cleanup action of the test case + void ActsLibuvTestSuite::TearDown() + { + } + + HWTEST_F(ActsLibuvTestSuite, testLibuvTestCase001, Function | MediumTest | Level2) + { + printf("------start ActsLibuvTestSuite------\n"); + // int m =run_tests(0); + // printf("%d\n",m); + int ret = system("/data/local/tmp/libuvruntest"); + printf("system ret=%d\n", ret); + + EXPECT_TRUE(true); + printf("------end ActsLibuvTestSuite------\n"); + } +} diff --git a/arkui/libuv/src/ActsLibuvTestSuite.h b/arkui/libuv/src/ActsLibuvTestSuite.h new file mode 100644 index 0000000000000000000000000000000000000000..036c9aa5a428d27e1929f8fcc5fe3a8e1c68e0a8 --- /dev/null +++ b/arkui/libuv/src/ActsLibuvTestSuite.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LIBUV_TESTCASE_H +#define LIBUV_TESTCASE_H + +#include +namespace OHOS { + class ActsLibuvTestSuite : public testing::Test { + public: + protected: + // Preset action of the test suite, which is executed before the first test case + static void SetUpTestCase(void); + // Test suite cleanup action, which is executed after the last test case + static void TearDownTestCase(void); + // Preset action of the test case + virtual void SetUp(); + // Cleanup action of the test case + virtual void TearDown(); + }; +} // namespace OHOS + +#endif // LIBUV_TESTCASE_H \ No newline at end of file