From 1995f9df1d7b084117ce3ec414830f5e15918083 Mon Sep 17 00:00:00 2001 From: Emily Date: Mon, 8 Feb 2021 16:35:46 +0800 Subject: [PATCH] add command cover testcases --- suite2cases/CreateImage | 1 + suite2cases/bcrypt | 1 + suite2cases/cmake | 8 + suite2cases/cppcheck | 2 + suite2cases/javapackages-tools | 6 + suite2cases/jq | 1 + suite2cases/kmod | 7 + suite2cases/libmemcached | 12 ++ suite2cases/libosinfo | 3 + suite2cases/mutt | 1 + suite2cases/openvpn | 1 + suite2cases/php | 7 + .../oe_test_CreateImage.sh | 56 +++++ .../oe_test_CreateImage/readme.txt | 6 + .../bcrypt/oe_test_bcrypt/oe_test_bcrypt.sh | 125 +++++++++++ .../cli-test/cmake/common/CMakeLists.txt | 3 + .../cli-test/cmake/common/common_cmake.sh | 39 ++++ testcases/cli-test/cmake/common/main.c | 6 + .../cli-test/cmake/common/mysettings.cmake | 9 + .../cmake/oe_test_ccmake/oe_test_ccmake.sh | 123 +++++++++++ .../cmake/oe_test_ccmake3/oe_test_ccmake3.sh | 123 +++++++++++ .../cmake/oe_test_cmake/oe_test_cmake.sh | 119 +++++++++++ .../cmake/oe_test_cmake3/oe_test_cmake3.sh | 119 +++++++++++ .../cmake/oe_test_cpack/CMakeLists.txt | 11 + testcases/cli-test/cmake/oe_test_cpack/main.c | 6 + .../cmake/oe_test_cpack/oe_test_cpack.sh | 111 ++++++++++ .../cmake/oe_test_cpack3/CMakeLists.txt | 11 + .../cli-test/cmake/oe_test_cpack3/main.c | 6 + .../cmake/oe_test_cpack3/oe_test_cpack3.sh | 111 ++++++++++ .../cmake/oe_test_ctest/CMakeLists.txt | 8 + .../cmake/oe_test_ctest/oe_test_ctest.sh | 109 ++++++++++ .../cli-test/cmake/oe_test_ctest/test.cpp | 10 + .../cmake/oe_test_ctest3/CMakeLists.txt | 8 + .../cmake/oe_test_ctest3/oe_test_ctest3.sh | 109 ++++++++++ .../cli-test/cmake/oe_test_ctest3/test.cpp | 10 + .../oe_test_cppcheck-htmlreport/file.c | 7 + .../oe_test_cppcheck-htmlreport.sh | 63 ++++++ .../cli-test/cppcheck/oe_test_cppcheck/file.c | 7 + .../cli-test/cppcheck/oe_test_cppcheck/main.c | 6 + .../oe_test_cppcheck/oe_test_cppcheck.sh | 111 ++++++++++ .../cppcheck/oe_test_cppcheck/test.cpp | 10 + .../common/common_javapackages-tools.sh | 33 +++ .../oe_test_binary-files_operation.sh | 99 +++++++++ .../oe_test_build-classpath.sh | 54 +++++ .../oe_test_build-jar-repository.sh | 54 +++++ .../oe_test_find-shade-jar.sh | 52 +++++ .../oe_test_gradle-local/build.gradle | 29 +++ .../oe_test_gradle-local.sh | 77 +++++++ .../oe_test_javapackages-local/build.gradle | 29 +++ .../oe_test_javapackages-local.sh | 50 +++++ .../cli-test/jq/oe_test_jq/oe_test_jq.sh | 63 ++++++ testcases/cli-test/jq/oe_test_jq/test.json | 1 + .../kmod/oe_test_depmod/oe_test_depmod.sh | 49 +++++ .../oe_test_insmod-lsmod.sh | 49 +++++ .../kmod/oe_test_kmod/oe_test_kmod.sh | 37 ++++ .../kmod/oe_test_modinfo/oe_test_modinfo.sh | 45 ++++ .../kmod/oe_test_modprobe/oe_test_modprobe.sh | 66 ++++++ .../kmod/oe_test_rmmod/oe_test_rmmod.sh | 47 +++++ .../oe_test_weak-modules.sh | 42 ++++ .../common/common_libmemcached.sh | 36 ++++ .../libmemcached/oe_test_memaslap/config | 7 + .../oe_test_memaslap/oe_test_memaslap.sh | 73 +++++++ .../oe_test_memcapable/oe_test_memcapable.sh | 65 ++++++ .../oe_test_memcat/oe_test_memcat.sh | 68 ++++++ .../oe_test_memcp/oe_test_memcp.sh | 101 +++++++++ .../oe_test_memdump-memerror.sh | 69 ++++++ .../oe_test_memexist/oe_test_memexist.sh | 60 ++++++ .../oe_test_memflush/oe_test_memflush.sh | 64 ++++++ .../oe_test_memping/oe_test_memping.sh | 57 +++++ .../oe_test_memrm/oe_test_memrm.sh | 62 ++++++ .../oe_test_memslap/oe_test_memslap.sh | 61 ++++++ .../oe_test_memstat/oe_test_memstat.sh | 57 +++++ .../oe_test_memtouch/oe_test_memtouch.sh | 63 ++++++ .../oe_test_osinfo-detect.sh | 52 +++++ .../oe_test_osinfo-install-script.sh | 57 +++++ .../oe_test_osinfo-query.sh | 51 +++++ .../mutt/oe_test_mutt/oe_test_mutt.sh | 68 ++++++ .../oe_test_openvpn/oe_test_openvpn.sh | 199 ++++++++++++++++++ testcases/cli-test/php/common/my_script.php | 8 + testcases/cli-test/php/common/myphp.ini | 37 ++++ testcases/cli-test/php/common/project/Lib.php | 5 + .../cli-test/php/common/project/file/test.css | 0 .../cli-test/php/common/project/file/test.js | 0 .../cli-test/php/common/project/index.php | 5 + .../cli-test/php/common/project/lib/lib_a.php | 4 + .../php/common/project/template/msg.html | 10 + testcases/cli-test/php/common/test.php | 95 +++++++++ testcases/cli-test/php/common/testBuild.php | 4 + .../cli-test/php/oe_test_phar/oe_test_phar.sh | 168 +++++++++++++++ .../oe_test_phar_phar/oe_test_phar_phar.sh | 168 +++++++++++++++ .../oe_test_php-cgi_phpize.sh | 79 +++++++ .../oe_test_php-config/oe_test_php-config.sh | 65 ++++++ .../php/oe_test_php-fpm/oe_test_php-fpm.sh | 49 +++++ .../cli-test/php/oe_test_php/oe_test_php.sh | 92 ++++++++ .../php/oe_test_phpdbg/oe_test_phpdbg.sh | 77 +++++++ 95 files changed, 4504 insertions(+) create mode 100644 suite2cases/CreateImage create mode 100644 suite2cases/bcrypt create mode 100644 suite2cases/cmake create mode 100644 suite2cases/cppcheck create mode 100644 suite2cases/javapackages-tools create mode 100644 suite2cases/jq create mode 100644 suite2cases/kmod create mode 100644 suite2cases/libmemcached create mode 100644 suite2cases/libosinfo create mode 100644 suite2cases/mutt create mode 100644 suite2cases/openvpn create mode 100644 suite2cases/php create mode 100644 testcases/cli-test/CreateImage/oe_test_CreateImage/oe_test_CreateImage.sh create mode 100644 testcases/cli-test/CreateImage/oe_test_CreateImage/readme.txt create mode 100644 testcases/cli-test/bcrypt/oe_test_bcrypt/oe_test_bcrypt.sh create mode 100644 testcases/cli-test/cmake/common/CMakeLists.txt create mode 100644 testcases/cli-test/cmake/common/common_cmake.sh create mode 100644 testcases/cli-test/cmake/common/main.c create mode 100644 testcases/cli-test/cmake/common/mysettings.cmake create mode 100644 testcases/cli-test/cmake/oe_test_ccmake/oe_test_ccmake.sh create mode 100644 testcases/cli-test/cmake/oe_test_ccmake3/oe_test_ccmake3.sh create mode 100644 testcases/cli-test/cmake/oe_test_cmake/oe_test_cmake.sh create mode 100644 testcases/cli-test/cmake/oe_test_cmake3/oe_test_cmake3.sh create mode 100644 testcases/cli-test/cmake/oe_test_cpack/CMakeLists.txt create mode 100644 testcases/cli-test/cmake/oe_test_cpack/main.c create mode 100644 testcases/cli-test/cmake/oe_test_cpack/oe_test_cpack.sh create mode 100644 testcases/cli-test/cmake/oe_test_cpack3/CMakeLists.txt create mode 100644 testcases/cli-test/cmake/oe_test_cpack3/main.c create mode 100644 testcases/cli-test/cmake/oe_test_cpack3/oe_test_cpack3.sh create mode 100644 testcases/cli-test/cmake/oe_test_ctest/CMakeLists.txt create mode 100644 testcases/cli-test/cmake/oe_test_ctest/oe_test_ctest.sh create mode 100644 testcases/cli-test/cmake/oe_test_ctest/test.cpp create mode 100644 testcases/cli-test/cmake/oe_test_ctest3/CMakeLists.txt create mode 100644 testcases/cli-test/cmake/oe_test_ctest3/oe_test_ctest3.sh create mode 100644 testcases/cli-test/cmake/oe_test_ctest3/test.cpp create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/file.c create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/oe_test_cppcheck-htmlreport.sh create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck/file.c create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck/main.c create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck/oe_test_cppcheck.sh create mode 100644 testcases/cli-test/cppcheck/oe_test_cppcheck/test.cpp create mode 100644 testcases/cli-test/javapackages-tools/common/common_javapackages-tools.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_binary-files_operation/oe_test_binary-files_operation.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_build-classpath/oe_test_build-classpath.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_build-jar-repository/oe_test_build-jar-repository.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_find-shade-jar/oe_test_find-shade-jar.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_gradle-local/build.gradle create mode 100644 testcases/cli-test/javapackages-tools/oe_test_gradle-local/oe_test_gradle-local.sh create mode 100644 testcases/cli-test/javapackages-tools/oe_test_javapackages-local/build.gradle create mode 100644 testcases/cli-test/javapackages-tools/oe_test_javapackages-local/oe_test_javapackages-local.sh create mode 100644 testcases/cli-test/jq/oe_test_jq/oe_test_jq.sh create mode 100644 testcases/cli-test/jq/oe_test_jq/test.json create mode 100644 testcases/cli-test/kmod/oe_test_depmod/oe_test_depmod.sh create mode 100644 testcases/cli-test/kmod/oe_test_insmod-lsmod/oe_test_insmod-lsmod.sh create mode 100644 testcases/cli-test/kmod/oe_test_kmod/oe_test_kmod.sh create mode 100644 testcases/cli-test/kmod/oe_test_modinfo/oe_test_modinfo.sh create mode 100644 testcases/cli-test/kmod/oe_test_modprobe/oe_test_modprobe.sh create mode 100644 testcases/cli-test/kmod/oe_test_rmmod/oe_test_rmmod.sh create mode 100644 testcases/cli-test/kmod/oe_test_weak-modules/oe_test_weak-modules.sh create mode 100644 testcases/cli-test/libmemcached/common/common_libmemcached.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memaslap/config create mode 100644 testcases/cli-test/libmemcached/oe_test_memaslap/oe_test_memaslap.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memcapable/oe_test_memcapable.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memcat/oe_test_memcat.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memcp/oe_test_memcp.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memdump-memerror/oe_test_memdump-memerror.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memexist/oe_test_memexist.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memflush/oe_test_memflush.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memping/oe_test_memping.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memrm/oe_test_memrm.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memslap/oe_test_memslap.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memstat/oe_test_memstat.sh create mode 100644 testcases/cli-test/libmemcached/oe_test_memtouch/oe_test_memtouch.sh create mode 100644 testcases/cli-test/libosinfo/oe_test_osinfo-detect/oe_test_osinfo-detect.sh create mode 100644 testcases/cli-test/libosinfo/oe_test_osinfo-install-script/oe_test_osinfo-install-script.sh create mode 100644 testcases/cli-test/libosinfo/oe_test_osinfo-query/oe_test_osinfo-query.sh create mode 100644 testcases/cli-test/mutt/oe_test_mutt/oe_test_mutt.sh create mode 100644 testcases/cli-test/openvpn/oe_test_openvpn/oe_test_openvpn.sh create mode 100644 testcases/cli-test/php/common/my_script.php create mode 100644 testcases/cli-test/php/common/myphp.ini create mode 100644 testcases/cli-test/php/common/project/Lib.php create mode 100644 testcases/cli-test/php/common/project/file/test.css create mode 100644 testcases/cli-test/php/common/project/file/test.js create mode 100644 testcases/cli-test/php/common/project/index.php create mode 100644 testcases/cli-test/php/common/project/lib/lib_a.php create mode 100644 testcases/cli-test/php/common/project/template/msg.html create mode 100644 testcases/cli-test/php/common/test.php create mode 100644 testcases/cli-test/php/common/testBuild.php create mode 100644 testcases/cli-test/php/oe_test_phar/oe_test_phar.sh create mode 100644 testcases/cli-test/php/oe_test_phar_phar/oe_test_phar_phar.sh create mode 100644 testcases/cli-test/php/oe_test_php-cgi_phpize/oe_test_php-cgi_phpize.sh create mode 100644 testcases/cli-test/php/oe_test_php-config/oe_test_php-config.sh create mode 100644 testcases/cli-test/php/oe_test_php-fpm/oe_test_php-fpm.sh create mode 100644 testcases/cli-test/php/oe_test_php/oe_test_php.sh create mode 100644 testcases/cli-test/php/oe_test_phpdbg/oe_test_phpdbg.sh diff --git a/suite2cases/CreateImage b/suite2cases/CreateImage new file mode 100644 index 0000000..f1fbb2b --- /dev/null +++ b/suite2cases/CreateImage @@ -0,0 +1 @@ +oe_test_CreateImage diff --git a/suite2cases/bcrypt b/suite2cases/bcrypt new file mode 100644 index 0000000..66db633 --- /dev/null +++ b/suite2cases/bcrypt @@ -0,0 +1 @@ +oe_test_bcrypt diff --git a/suite2cases/cmake b/suite2cases/cmake new file mode 100644 index 0000000..337ac47 --- /dev/null +++ b/suite2cases/cmake @@ -0,0 +1,8 @@ +oe_test_ccmake +oe_test_ccmake3 +oe_test_cmake +oe_test_cmake3 +oe_test_cpack +oe_test_cpack3 +oe_test_ctest +oe_test_ctest3 diff --git a/suite2cases/cppcheck b/suite2cases/cppcheck new file mode 100644 index 0000000..704a074 --- /dev/null +++ b/suite2cases/cppcheck @@ -0,0 +1,2 @@ +oe_test_cppcheck +oe_test_cppcheck-htmlreport diff --git a/suite2cases/javapackages-tools b/suite2cases/javapackages-tools new file mode 100644 index 0000000..de4f51e --- /dev/null +++ b/suite2cases/javapackages-tools @@ -0,0 +1,6 @@ +oe_test_binary-files_operation +oe_test_build-classpath +oe_test_build-jar-repository +oe_test_find-shade-jar +oe_test_gradle-local +oe_test_javapackages-local diff --git a/suite2cases/jq b/suite2cases/jq new file mode 100644 index 0000000..2688bab --- /dev/null +++ b/suite2cases/jq @@ -0,0 +1 @@ +oe_test_jq diff --git a/suite2cases/kmod b/suite2cases/kmod new file mode 100644 index 0000000..631905f --- /dev/null +++ b/suite2cases/kmod @@ -0,0 +1,7 @@ +oe_test_depmod +oe_test_insmod-lsmod +oe_test_kmod +oe_test_modinfo +oe_test_modprobe +oe_test_rmmod +oe_test_weak-modules diff --git a/suite2cases/libmemcached b/suite2cases/libmemcached new file mode 100644 index 0000000..a7ef44a --- /dev/null +++ b/suite2cases/libmemcached @@ -0,0 +1,12 @@ +oe_test_memaslap +oe_test_memcapable +oe_test_memcat +oe_test_memcp +oe_test_memdump-memerror +oe_test_memexist +oe_test_memflush +oe_test_memping +oe_test_memrm +oe_test_memslap +oe_test_memstat +oe_test_memtouch diff --git a/suite2cases/libosinfo b/suite2cases/libosinfo new file mode 100644 index 0000000..573fc20 --- /dev/null +++ b/suite2cases/libosinfo @@ -0,0 +1,3 @@ +oe_test_osinfo-detect +oe_test_osinfo-install-script +oe_test_osinfo-query diff --git a/suite2cases/mutt b/suite2cases/mutt new file mode 100644 index 0000000..d3a8d01 --- /dev/null +++ b/suite2cases/mutt @@ -0,0 +1 @@ +oe_test_mutt diff --git a/suite2cases/openvpn b/suite2cases/openvpn new file mode 100644 index 0000000..1839372 --- /dev/null +++ b/suite2cases/openvpn @@ -0,0 +1 @@ +oe_test_openvpn diff --git a/suite2cases/php b/suite2cases/php new file mode 100644 index 0000000..8b92025 --- /dev/null +++ b/suite2cases/php @@ -0,0 +1,7 @@ +oe_test_phar +oe_test_phar_phar +oe_test_php +oe_test_php-cgi_phpize +oe_test_php-config +oe_test_phpdbg +oe_test_php-fpm diff --git a/testcases/cli-test/CreateImage/oe_test_CreateImage/oe_test_CreateImage.sh b/testcases/cli-test/CreateImage/oe_test_CreateImage/oe_test_CreateImage.sh new file mode 100644 index 0000000..6a49233 --- /dev/null +++ b/testcases/cli-test/CreateImage/oe_test_CreateImage/oe_test_CreateImage.sh @@ -0,0 +1,56 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/30 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of create-image and dib-run-parts command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL CreateImage + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + create-image --help | grep "Usage: create-image" + CHECK_RESULT $? + create-image --version | grep "[0-9]" + CHECK_RESULT $? + create-image -r https://repo.openeuler.org/openEuler-20.09/OS/aarch64/ >runlog + CHECK_RESULT $? + grep -E "Complete|system.img" runlog + CHECK_RESULT $? + test -f system.img + CHECK_RESULT $? + + dib-run-parts --list /etc/ld.so.conf.d/ + CHECK_RESULT $? + dib-run-parts /etc/ld.so.conf.d/ >runlog 2>&1 + CHECK_RESULT $? + grep "PROFILING" runlog + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + rm -rf system.img runlog + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/CreateImage/oe_test_CreateImage/readme.txt b/testcases/cli-test/CreateImage/oe_test_CreateImage/readme.txt new file mode 100644 index 0000000..63c6682 --- /dev/null +++ b/testcases/cli-test/CreateImage/oe_test_CreateImage/readme.txt @@ -0,0 +1,6 @@ +1.执行此用例时需要在安装环境时给/tmp分区分大一点,否则会提示空间不够用,因为运行create-image -r http://121.36.84.172/repo.openeuler.org/openEuler-20.09/OS/aarch64/ 命令时,实则执行的是以下这脚本: +Command:yum install -y -d 10 --disableexcludes=all --setopt=reposdir=/tmp/hmi_build.9L4deZ9o/hooks/yum.repos.d --installroot=/tmp/hmi_build.9L4deZ9o/mnt openEuler-release basesystem filesystem setup yum +Installroot: /tmp/hmi_build.9L4deZ9o/mnt +2.create-image -r 参数后边应该跟官方的地址,但是执行到最后时会报错: +Curl error (6):Could't resolve host name for https:/repo.openeuler.org/openEuler-20.09/OS/aarch64/repodata/repomd.xml[Could not resolve host:repo.openeuler.org] +3、create-image -r http://121.36.84.172/repo.openeuler.org/openEuler-20.09/OS/aarch64/时就能够正常执行,最终生成一个system.imgs \ No newline at end of file diff --git a/testcases/cli-test/bcrypt/oe_test_bcrypt/oe_test_bcrypt.sh b/testcases/cli-test/bcrypt/oe_test_bcrypt/oe_test_bcrypt.sh new file mode 100644 index 0000000..f3b620c --- /dev/null +++ b/testcases/cli-test/bcrypt/oe_test_bcrypt/oe_test_bcrypt.sh @@ -0,0 +1,125 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/11/16 +# @License : Mulan PSL v2 +# @Desc : verify the bcrypt command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL bcrypt + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + touch test{1..8} + expect < +int main(void) +{ + printf("Hello World\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cmake/common/mysettings.cmake b/testcases/cli-test/cmake/common/mysettings.cmake new file mode 100644 index 0000000..c535b22 --- /dev/null +++ b/testcases/cli-test/cmake/common/mysettings.cmake @@ -0,0 +1,9 @@ +if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) + if(BUILD_TYPE) + string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" + CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") + else() + set(CMAKE_INSTALL_CONFIG_NAME "Debug") + endif() + message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") +endif() \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_ccmake/oe_test_ccmake.sh b/testcases/cli-test/cmake/oe_test_ccmake/oe_test_ccmake.sh new file mode 100644 index 0000000..40d879f --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ccmake/oe_test_ccmake.sh @@ -0,0 +1,123 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/12 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of ccmake command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + ccmake -help | grep -E "Usage|ccmake " + CHECK_RESULT $? + ccmake -version | grep "ccmake version" + CHECK_RESULT $? + ccmake --help-full | grep "variable" + CHECK_RESULT $? + ccmake --help-command add_executable | grep "add_executable" + CHECK_RESULT $? + ccmake --help-manual-list | grep "cmake" + CHECK_RESULT $? + expect <" + CHECK_RESULT $? + ccmake3 -version | grep "ccmake version" + CHECK_RESULT $? + ccmake3 --help-full | grep "variable" + CHECK_RESULT $? + ccmake3 --help-command add_executable | grep "add_executable" + CHECK_RESULT $? + ccmake3 --help-manual-list | grep "cmake" + CHECK_RESULT $? + expect <" + CHECK_RESULT $? + cmake -version | grep "cmake version" + CHECK_RESULT $? + cmake --help-full | grep "variable" + CHECK_RESULT $? + cmake --help-command aux_source_directory | grep "aux_source_directory" + CHECK_RESULT $? + cmake --help-manual-list | grep "cmake" + CHECK_RESULT $? + cmake --help-command-list | grep -E "add_executable|include_directories|aux_source_directory" + CHECK_RESULT $? + cmake -S ../../common/ -B ../builddir + CHECK_RESULT $? + test -d ../builddir/CMakeFiles + CHECK_RESULT $? + test -f ../builddir/CMakeCache.txt -a -f ../builddir/cmake_install.cmake -a -f ../builddir/Makefile + CHECK_RESULT $? + cmake -C ../../common/mysettings.cmake ../../common/ | grep -E 'Install configuration: "Debug"|Build files have been written to:' + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake -DCMAKE_BUILD_TYPE:STRING=Debug ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake -UCMAKE_BUILD_TYPE ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake -G "Unix Makefiles" ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake -G "Ninja" ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f build.ninja + rm -rf ./* + cmake -E environment | grep -E "SHELL=/bin/bash|_=/usr/bin/cmake" + CHECK_RESULT $? + cmake -E touch testCommand + CHECK_RESULT $? + test -f testCommand && rm -rf testCommand + cmake -L A ../../common/ | grep -E "CMAKE_BUILD_TYPE:STRING=|CMAKE_INSTALL_PREFIX:PATH=/usr/local" + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + cmake --build ./ | grep "\[100%\] Built target main" + CHECK_RESULT $? + test -f main + CHECK_RESULT $? + ./main | grep "Hello World" + CHECK_RESULT $? + cmake -N ../../common/ + CHECK_RESULT $? + cmake -P ../../common/mysettings.cmake ../../common/ | grep 'Install configuration: "Debug"' + CHECK_RESULT $? + rm -rf ./* + cmake --debug-output ../../common/ | grep "Called from:" + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_cmake3/oe_test_cmake3.sh b/testcases/cli-test/cmake/oe_test_cmake3/oe_test_cmake3.sh new file mode 100644 index 0000000..7365c91 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cmake3/oe_test_cmake3.sh @@ -0,0 +1,119 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/12 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of cmake3 command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + cmake3 -help | grep -E "Usage|cmake \[options]\ " + CHECK_RESULT $? + cmake3 -version | grep "cmake version" + CHECK_RESULT $? + cmake3 --help-full | grep "variable" + CHECK_RESULT $? + cmake3 --help-command aux_source_directory | grep "aux_source_directory" + CHECK_RESULT $? + cmake3 --help-manual-list | grep "cmake" + CHECK_RESULT $? + cmake3 --help-command-list | grep -E "add_executable|include_directories|aux_source_directory" + CHECK_RESULT $? + cmake3 -S ../../common/ -B ../builddir3 + CHECK_RESULT $? + test -d ../builddir3/CMakeFiles + CHECK_RESULT $? + test -f ../builddir3/CMakeCache.txt -a -f ../builddir3/cmake_install.cmake -a -f ../builddir3/Makefile + CHECK_RESULT $? + cmake3 -C ../../common/mysettings.cmake ../../common/ | grep -E 'Install configuration: "Debug"|Build files have been written to:' + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake3 -DCMAKE_BUILD_TYPE:STRING=Debug ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake3 -UCMAKE_BUILD_TYPE ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake3 -G "Unix Makefiles" ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + rm -rf ./* + cmake3 -G "Ninja" ../../common/ + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f build.ninja + rm -rf ./* + cmake3 -E environment | grep -E "SHELL=/bin/bash|_=/usr/bin/cmake3" + CHECK_RESULT $? + cmake3 -E touch testCommand + CHECK_RESULT $? + test -f testCommand && rm -rf testCommand + cmake3 -L A ../../common/ | grep -E "CMAKE_BUILD_TYPE:STRING=|CMAKE_INSTALL_PREFIX:PATH=/usr/local" + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + cmake3 --build ./ | grep "\[100%\] Built target main" + CHECK_RESULT $? + test -f main + CHECK_RESULT $? + ./main | grep "Hello World" + CHECK_RESULT $? + cmake3 -N ../../common/ + CHECK_RESULT $? + cmake3 -P ../../common/mysettings.cmake ../../common/ | grep 'Install configuration: "Debug"' + CHECK_RESULT $? + rm -rf ./* + cmake3 --debug-output ../../common/ | grep "Called from:" + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_cpack/CMakeLists.txt b/testcases/cli-test/cmake/oe_test_cpack/CMakeLists.txt new file mode 100644 index 0000000..5ec9987 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8) +project (demo) +add_executable(main main.c) +set(CPACK_PACKAGE_NAME "demo1") +set(CPACK_SET_DESTDIR ON) +set(CPACK_INSTALL_PREFIX "install") +set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_RPM_PACKAGE_GROUP "demo1") +set(CPACK_PACKAGE_VENDOR "demo1") +set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0 + Common Clause 1.0") +include(CPack) \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_cpack/main.c b/testcases/cli-test/cmake/oe_test_cpack/main.c new file mode 100644 index 0000000..c9e2e50 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack/main.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + printf("Hello World\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_cpack/oe_test_cpack.sh b/testcases/cli-test/cmake/oe_test_cpack/oe_test_cpack.sh new file mode 100644 index 0000000..7f72bdb --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack/oe_test_cpack.sh @@ -0,0 +1,111 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/13 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of cpack command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + cpack --help | grep -E "Usage|cpack \[options\]" + CHECK_RESULT $? + cpack --version | grep "cpack version" + CHECK_RESULT $? + cpack --help-full | grep "variable" + CHECK_RESULT $? + cpack --help-manual-list | grep "cmake" + CHECK_RESULT $? + cpack --help-command include_directories | grep "include_directories" + CHECK_RESULT $? + cpack --help-command-list | grep -E "add_executable|include_directories|aux_source_directory" + CHECK_RESULT $? + cmake .. + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile -a -f CPackConfig.cmake -a -f CPackSourceConfig.cmake + CHECK_RESULT $? + cpack -G "7Z" | grep "CPack: Create package using 7Z" + CHECK_RESULT $? + test -d _CPack_Packages + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.7z -a -f install_manifest.txt -a -f main + CHECK_RESULT $? + cpack -C "Debug" -G "STGZ" | grep -E "CPack: Create package using STGZ|demo \[Debug\]" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.sh + CHECK_RESULT $? + cpack -D CPACK_GENERATOR=ZIP | grep "CPack: Create package using ZIP" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.zip + CHECK_RESULT $? + cpack --config CPackConfig.cmake -G "TGZ" | grep "CPack: Create package using TGZ" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.gz + CHECK_RESULT $? + cpack --verbose -G "TZ" | grep "CPack: Enable Verbose" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.Z + CHECK_RESULT $? + cpack --debug -G "TXZ" | grep "Enable Debug" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.xz + CHECK_RESULT $? + cpack -P "testpack" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "testpack Installer Version: 1.0.0, Copyright (c) demo1" + CHECK_RESULT $? + cpack -R "2.2.3" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "demo1 Installer Version: 2.2.3, Copyright (c) demo1" + CHECK_RESULT $? + OPENEULER_VERSION=$(awk '{print$3}' /etc/openEuler-release) + if [ ${OPENEULER_VERSION} == 20.09 ]; then + cpack -B cpackdir -G "STGZ" | grep "cpackdir/demo1-1.0.0-Linux.sh generated." + elif [ ${OPENEULER_VERSION} == 20.03 ]; then + currentDir=$( + cd "$(dirname $0)" || exit 1 + pwd + ) + cpack -B $currentDir/cpackdir -G "STGZ" | grep "cpackdir/demo1-1.0.0-Linux.sh generated." + else + exit 1 + fi + test -d cpackdir -a -d cpackdir/_CPack_Packages + CHECK_RESULT $? + test -f cpackdir/demo1-1.0.0-Linux.sh + CHECK_RESULT $? + cpack --vendor "Huawei" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "demo1 Installer Version: 1.0.0, Copyright (c) Huawei" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_cpack3/CMakeLists.txt b/testcases/cli-test/cmake/oe_test_cpack3/CMakeLists.txt new file mode 100644 index 0000000..5ec9987 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack3/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8) +project (demo) +add_executable(main main.c) +set(CPACK_PACKAGE_NAME "demo1") +set(CPACK_SET_DESTDIR ON) +set(CPACK_INSTALL_PREFIX "install") +set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_RPM_PACKAGE_GROUP "demo1") +set(CPACK_PACKAGE_VENDOR "demo1") +set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0 + Common Clause 1.0") +include(CPack) \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_cpack3/main.c b/testcases/cli-test/cmake/oe_test_cpack3/main.c new file mode 100644 index 0000000..c9e2e50 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack3/main.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + printf("Hello World\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_cpack3/oe_test_cpack3.sh b/testcases/cli-test/cmake/oe_test_cpack3/oe_test_cpack3.sh new file mode 100644 index 0000000..4fa33e0 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_cpack3/oe_test_cpack3.sh @@ -0,0 +1,111 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/13 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of cpack3 command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + cpack3 --help | grep -E "Usage|cpack \[options\]" + CHECK_RESULT $? + cpack3 --version | grep "cpack version" + CHECK_RESULT $? + cpack3 --help-full | grep "variable" + CHECK_RESULT $? + cpack3 --help-manual-list | grep "cmake" + CHECK_RESULT $? + cpack3 --help-command include_directories | grep "include_directories" + CHECK_RESULT $? + cpack3 --help-command-list | grep -E "add_executable|include_directories|aux_source_directory" + CHECK_RESULT $? + cmake .. + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile -a -f CPackConfig.cmake -a -f CPackSourceConfig.cmake + CHECK_RESULT $? + cpack3 -G "7Z" | grep "CPack: Create package using 7Z" + CHECK_RESULT $? + test -d _CPack_Packages + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.7z -a -f install_manifest.txt -a -f main + CHECK_RESULT $? + cpack3 -C "Debug" -G "STGZ" | grep -E "CPack: Create package using STGZ|demo \[Debug\]" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.sh + CHECK_RESULT $? + cpack3 -D CPACK_GENERATOR=ZIP | grep "CPack: Create package using ZIP" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.zip + CHECK_RESULT $? + cpack3 --config CPackConfig.cmake -G "TGZ" | grep "CPack: Create package using TGZ" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.gz + CHECK_RESULT $? + cpack3 --verbose -G "TZ" | grep "CPack: Enable Verbose" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.Z + CHECK_RESULT $? + cpack3 --debug -G "TXZ" | grep "Enable Debug" + CHECK_RESULT $? + test -f demo1-1.0.0-Linux.tar.xz + CHECK_RESULT $? + cpack3 -P "testpack" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "testpack Installer Version: 1.0.0, Copyright (c) demo1" + CHECK_RESULT $? + cpack3 -R "2.2.3" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "demo1 Installer Version: 2.2.3, Copyright (c) demo1" + CHECK_RESULT $? + OPENEULER_VERSION=$(awk '{print$3}' /etc/openEuler-release) + if [ ${OPENEULER_VERSION} == 20.09 ]; then + cpack -B cpackdir3 -G "STGZ" | grep "cpackdir3/demo1-1.0.0-Linux.sh generated." + elif [ ${OPENEULER_VERSION} == 20.03 ]; then + currentDir=$( + cd "$(dirname $0)" || exit 1 + pwd + ) + cpack -B $currentDir/cpackdir3 -G "STGZ" | grep "cpackdir3/demo1-1.0.0-Linux.sh generated." + else + exit 1 + fi + test -d cpackdir3 -a -d cpackdir3/_CPack_Packages + CHECK_RESULT $? + test -f cpackdir3/demo1-1.0.0-Linux.sh + CHECK_RESULT $? + cpack3 --vendor "Huawei" -G "STGZ" + CHECK_RESULT $? + cat demo1-1.0.0-Linux.sh | grep -a "demo1 Installer Version: 1.0.0, Copyright (c) Huawei" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_ctest/CMakeLists.txt b/testcases/cli-test/cmake/oe_test_ctest/CMakeLists.txt new file mode 100644 index 0000000..1a21ab3 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest/CMakeLists.txt @@ -0,0 +1,8 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TEST_APP) +AUX_SOURCE_DIRECTORY(. DIR_SRCS) +ADD_EXECUTABLE(my_test ${DIR_SRCS}) +enable_testing() +add_test (test_run2 my_test 1 2) +add_test (test_1_plus_3 my_test 1 3) +set_tests_properties (test_1_plus_3 PROPERTIES PASS_REGULAR_EXPRESSION "is 4") \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_ctest/oe_test_ctest.sh b/testcases/cli-test/cmake/oe_test_ctest/oe_test_ctest.sh new file mode 100644 index 0000000..b41666c --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest/oe_test_ctest.sh @@ -0,0 +1,109 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/14 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of ctest command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + ctest --help | grep -E "Usage|ctest \[options\]" + CHECK_RESULT $? + ctest --version | grep "ctest version" + CHECK_RESULT $? + cmake .. + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile -a -f CTestTestfile.cmake + CHECK_RESULT $? + make | grep "Scanning dependencies of target my_test" + CHECK_RESULT $? + test -f my_test + CHECK_RESULT $? + ctest -C "Debug" | grep "100% tests passed" + CHECK_RESULT $? + test -d Testing + CHECK_RESULT $? + ctest --verbose | grep -E "UpdateCTestConfiguration|Test command:|100% tests passed" + CHECK_RESULT $? + ctest --extra-verbose | grep -E "UpdateCTestConfiguration|Test command:|100% tests passed" + CHECK_RESULT $? + ctest --debug | grep -E "Constructing a list of tests|Done constructing a list of tests|Updating test list for fixtures|Added 0 tests to meet fixture requirements|100% tests passed|Total Test time (real)" + CHECK_RESULT $? + ctest --output-on-failure | grep "100% tests passed" + CHECK_RESULT $? + ctest -F | grep "100% tests passed" + CHECK_RESULT $? + ctest -j 1 | grep "100% tests passed" + CHECK_RESULT $? + ctest -Q | grep "100% tests passed" + CHECK_RESULT $? 1 + ctest -O result + CHECK_RESULT $? + grep -E "\[HANDLER_OUTPUT\]|100% tests passed" result + CHECK_RESULT $? + ctest -N | grep "Total Tests: 2" + CHECK_RESULT $? + ctest -N -E test_1_plus_3 | grep -E "Test #1: test_run2|Total Tests: 1" + CHECK_RESULT $? + ctest -R test_run2 | grep "1/1 Test #1: test_run2" + CHECK_RESULT $? + ctest --build-and-test | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-target . | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-nocmake | grep "100% tests passed" + CHECK_RESULT $? + ctest -build-run-dir . | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-two-config | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-exe-dir . | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-generator "Unix Makefiles" | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-generator-toolset "Visual Studio" | grep "100% tests passed" + CHECK_RESULT $? + ctest --build-project my_test | grep "100% tests passed" + CHECK_RESULT $? + ctest --print-labels | grep "Labels" + CHECK_RESULT $? + ctest --timeout 0.0001 | grep -E "0% tests passed, 2 tests failed out of 2|1 - test_run2 \(Timeout\)|2 - test_1_plus_3 \(Timeout\)" + CHECK_RESULT $? + ctest --stop-time 0.001 | grep "100% tests passed" + CHECK_RESULT $? + ctest --http1.0 | grep "100% tests passed" + CHECK_RESULT $? + ctest --no-compress-output | grep "100% tests passed" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_ctest/test.cpp b/testcases/cli-test/cmake/oe_test_ctest/test.cpp new file mode 100644 index 0000000..c8945a5 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest/test.cpp @@ -0,0 +1,10 @@ +#include +#include +int main(int argc, const char *argv[]) +{ + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("is %d\n", a+b); + printf("exit 0!\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_ctest3/CMakeLists.txt b/testcases/cli-test/cmake/oe_test_ctest3/CMakeLists.txt new file mode 100644 index 0000000..1a21ab3 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest3/CMakeLists.txt @@ -0,0 +1,8 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(TEST_APP) +AUX_SOURCE_DIRECTORY(. DIR_SRCS) +ADD_EXECUTABLE(my_test ${DIR_SRCS}) +enable_testing() +add_test (test_run2 my_test 1 2) +add_test (test_1_plus_3 my_test 1 3) +set_tests_properties (test_1_plus_3 PROPERTIES PASS_REGULAR_EXPRESSION "is 4") \ No newline at end of file diff --git a/testcases/cli-test/cmake/oe_test_ctest3/oe_test_ctest3.sh b/testcases/cli-test/cmake/oe_test_ctest3/oe_test_ctest3.sh new file mode 100644 index 0000000..3c1d622 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest3/oe_test_ctest3.sh @@ -0,0 +1,109 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/14 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of ctest3 command +# ############################################ + +source "../common/common_cmake.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + ctest3 --help | grep -E "Usage|ctest \[options\]" + CHECK_RESULT $? + ctest3 --version | grep "ctest version" + CHECK_RESULT $? + cmake .. + CHECK_RESULT $? + test -d CMakeFiles + CHECK_RESULT $? + test -f cmake_install.cmake -a -f CMakeCache.txt -a -f Makefile -a -f CTestTestfile.cmake + CHECK_RESULT $? + make | grep "Scanning dependencies of target my_test" + CHECK_RESULT $? + test -f my_test + CHECK_RESULT $? + ctest3 -C "Debug" | grep "100% tests passed" + CHECK_RESULT $? + test -d Testing + CHECK_RESULT $? + ctest3 --verbose | grep -E "UpdateCTestConfiguration|Test command:|100% tests passed" + CHECK_RESULT $? + ctest3 --extra-verbose | grep -E "UpdateCTestConfiguration|Test command:|100% tests passed" + CHECK_RESULT $? + ctest3 --debug | grep -E "Constructing a list of tests|Done constructing a list of tests|Updating test list for fixtures|Added 0 tests to meet fixture requirements|100% tests passed|Total Test time (real)" + CHECK_RESULT $? + ctest3 --output-on-failure | grep "100% tests passed" + CHECK_RESULT $? + ctest3 -F | grep "100% tests passed" + CHECK_RESULT $? + ctest3 -j 1 | grep "100% tests passed" + CHECK_RESULT $? + ctest3 -Q | grep "100% tests passed" + CHECK_RESULT $? 1 + ctest3 -O result + CHECK_RESULT $? + grep -E "\[HANDLER_OUTPUT\]|100% tests passed" result + CHECK_RESULT $? + ctest3 -N | grep "Total Tests: 2" + CHECK_RESULT $? + ctest3 -N -E test_1_plus_3 | grep -E "Test #1: test_run2|Total Tests: 1" + CHECK_RESULT $? + ctest3 -R test_run2 | grep "1/1 Test #1: test_run2" + CHECK_RESULT $? + ctest3 --build-and-test | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-target . | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-nocmake | grep "100% tests passed" + CHECK_RESULT $? + ctest3 -build-run-dir . | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-two-config | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-exe-dir . | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-generator "Unix Makefiles" | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-generator-toolset "Visual Studio" | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --build-project my_test | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --print-labels | grep "Labels" + CHECK_RESULT $? + ctest3 --timeout 0.0001 | grep -E "0% tests passed, 2 tests failed out of 2|1 - test_run2 \(Timeout\)|2 - test_1_plus_3 \(Timeout\)" + CHECK_RESULT $? + ctest3 --stop-time 0.001 | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --http1.0 | grep "100% tests passed" + CHECK_RESULT $? + ctest3 --no-compress-output | grep "100% tests passed" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cmake/oe_test_ctest3/test.cpp b/testcases/cli-test/cmake/oe_test_ctest3/test.cpp new file mode 100644 index 0000000..c8945a5 --- /dev/null +++ b/testcases/cli-test/cmake/oe_test_ctest3/test.cpp @@ -0,0 +1,10 @@ +#include +#include +int main(int argc, const char *argv[]) +{ + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("is %d\n", a+b); + printf("exit 0!\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/file.c b/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/file.c new file mode 100644 index 0000000..652107a --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/file.c @@ -0,0 +1,7 @@ +#include +int main() +{ + char a[10]; + a[10] = 0; + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/oe_test_cppcheck-htmlreport.sh b/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/oe_test_cppcheck-htmlreport.sh new file mode 100644 index 0000000..2c1f8e2 --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck-htmlreport/oe_test_cppcheck-htmlreport.sh @@ -0,0 +1,63 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/11/09 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of cppcheck-htmlreport command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL cppcheck + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + cppcheck --xml file.c 2>err1.xml + CHECK_RESULT $? + grep -E "|arrayIndexOutOfBounds" err1.xml + CHECK_RESULT $? + cppcheck --enable=all --xml-version=2 file.c 2>err2.xml + CHECK_RESULT $? + grep -E "|arrayIndexOutOfBounds|unreadVariable|missingIncludeSystem" err2.xml + CHECK_RESULT $? + cppcheck-htmlreport --help | grep "Usage: cppcheck-htmlreport \[options\]" + CHECK_RESULT $? + cppcheck-htmlreport --title=fileReport --file=err1.xml --report-dir=testErr1 | grep -E "Parsing|Creating|Processing|file.c" + CHECK_RESULT $? + grep "fileReport" testErr1/index.html + CHECK_RESULT $? + cppcheck-htmlreport --title=fileReport2 --file=err2.xml --report-dir=testErr2 --source-dir=. | grep -E "Parsing|Creating|Processing|file.c" + CHECK_RESULT $? + grep "fileReport2" testErr2/index.html + CHECK_RESULT $? + cppcheck-htmlreport --title=fileReport3 --file=err2.xml --report-dir=testErr3 --source-encoding=UTF-8 | grep -E "Parsing|Creating|Processing|file.c" + CHECK_RESULT $? + grep "fileReport3" testErr3/index.html + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + roc=$(ls | grep -vE "\.sh|\.c") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck/file.c b/testcases/cli-test/cppcheck/oe_test_cppcheck/file.c new file mode 100644 index 0000000..652107a --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck/file.c @@ -0,0 +1,7 @@ +#include +int main() +{ + char a[10]; + a[10] = 0; + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck/main.c b/testcases/cli-test/cppcheck/oe_test_cppcheck/main.c new file mode 100644 index 0000000..c9e2e50 --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck/main.c @@ -0,0 +1,6 @@ +#include +int main(void) +{ + printf("Hello World\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck/oe_test_cppcheck.sh b/testcases/cli-test/cppcheck/oe_test_cppcheck/oe_test_cppcheck.sh new file mode 100644 index 0000000..eed3e0b --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck/oe_test_cppcheck.sh @@ -0,0 +1,111 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/11/09 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of cppcheck command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL cppcheck + mkdir cppcheck1 cppcheck2 result + cp test.cpp cppcheck1/test1.cpp + cp file.c cppcheck1/file1.c + cp main.c cppcheck1/main1.c + cp test.cpp cppcheck2/test2.cpp + cp main.c cppcheck2/main2.c + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + cppcheck --help | grep -E "Syntax|cppcheck \[OPTIONS\] \[files or paths\]" + CHECK_RESULT $? + cppcheck --version | grep -i "Cppcheck" + CHECK_RESULT $? + cppcheck cppcheck1 | grep -E "file1.c|main1.c|test1.cpp" + CHECK_RESULT $? + cppcheck cppcheck1/file1.c cppcheck1/main1.c | grep -E "file1.c|main1.c" + CHECK_RESULT $? + cppcheck -i cppcheck2/test2.cpp cppcheck2 | grep "test2.cpp" + CHECK_RESULT $? 1 + cppcheck file.c 2>error1 | grep "Checking file.c ..." + CHECK_RESULT $? + grep "error" error1 + CHECK_RESULT $? + cppcheck --enable=all file.c 2>error2 | grep "Checking file.c ..." + CHECK_RESULT $? + grep -E "error|style|information" error2 + CHECK_RESULT $? + cppcheck --enable=warning,performance cppcheck1/test1.cpp | grep "Checking cppcheck1/test1.cpp ..." + CHECK_RESULT $? + cppcheck --quiet cppcheck2/ + CHECK_RESULT $? + cppcheck cppcheck2 --cppcheck-build-dir=result + CHECK_RESULT $? + test -f result/files.txt -a -f result/main2.a1 -a -f result/test2.a1 + CHECK_RESULT $? + cppcheck --inconclusive cppcheck1 + CHECK_RESULT $? + cppcheck -j 4 cppcheck1 | grep -E "Checking|checked" + CHECK_RESULT $? + cppcheck -I cppcheck2 cppcheck2/test2.cpp | grep "Checking cppcheck2/test2.cpp ..." + CHECK_RESULT $? + cppcheck --std=c99 --std=posix test.cpp + CHECK_RESULT $? + cppcheck --xml-version=2 file.c + CHECK_RESULT $? + cppcheck --xml file.c 2>err1.xml + CHECK_RESULT $? + grep -E "|arrayIndexOutOfBounds" err1.xml + CHECK_RESULT $? + cppcheck --enable=all --xml-version=2 file.c 2>err2.xml + CHECK_RESULT $? + grep -E "|arrayIndexOutOfBounds|unreadVariable|missingIncludeSystem" err2.xml + CHECK_RESULT $? + cppcheck --verbose main.c | grep -E "main.c|Defines|Includes|Platform" + CHECK_RESULT $? + cppcheck --template="{file}:{line},{severity},{id},{message}" file.c 2>error3 | grep "Checking file.c ..." + CHECK_RESULT $? + grep "error,arrayIndexOutOfBounds" error3 + CHECK_RESULT $? + cppcheck --enable=all --template="{file}:{line},{severity},{id},{message}" file.c 2>error4 | grep "Checking file.c ..." + CHECK_RESULT $? + grep -E "error,arrayIndexOutOfBounds|style,unreadVariable|information,missingIncludeSystem" error4 + CHECK_RESULT $? + cppcheck -DA file.c | grep "A=1" + CHECK_RESULT $? + cppcheck -DA --force file.c | grep "A=1" + CHECK_RESULT $? 1 + cppcheck -DDEBUG=1-D_ucplusplus test.cpp | grep "DEBUG=1-D_ucplusplus" + CHECK_RESULT $? + cppcheck -UX file.c + CHECK_RESULT $? + cppcheck -UDEBUG test.cpp + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + roc=$(ls | grep -vE "\.sh|\.c|\.cpp") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/cppcheck/oe_test_cppcheck/test.cpp b/testcases/cli-test/cppcheck/oe_test_cppcheck/test.cpp new file mode 100644 index 0000000..c8945a5 --- /dev/null +++ b/testcases/cli-test/cppcheck/oe_test_cppcheck/test.cpp @@ -0,0 +1,10 @@ +#include +#include +int main(int argc, const char *argv[]) +{ + int a = atoi(argv[1]); + int b = atoi(argv[2]); + printf("is %d\n", a+b); + printf("exit 0!\n"); + return 0; +} \ No newline at end of file diff --git a/testcases/cli-test/javapackages-tools/common/common_javapackages-tools.sh b/testcases/cli-test/javapackages-tools/common/common_javapackages-tools.sh new file mode 100644 index 0000000..1cb98b1 --- /dev/null +++ b/testcases/cli-test/javapackages-tools/common/common_javapackages-tools.sh @@ -0,0 +1,33 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################ +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Version : 1.0 +# @Desc : public class integration +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function deploy_env() { + DNF_INSTALL junit + java_version=$(rpm -qa java* | grep java-.*-openjdk | awk -F '-' '{print $2}') + DNF_INSTALL "javapackages-tools java-${java_version}-devel xmvn-resolve objectweb-asm3 beust-jcommander log4j" +} + +function clear_env() { + roc=$(ls | grep -v ".sh") + rm -rf $roc + DNF_REMOVE +} diff --git a/testcases/cli-test/javapackages-tools/oe_test_binary-files_operation/oe_test_binary-files_operation.sh b/testcases/cli-test/javapackages-tools/oe_test_binary-files_operation/oe_test_binary-files_operation.sh new file mode 100644 index 0000000..5d2127b --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_binary-files_operation/oe_test_binary-files_operation.sh @@ -0,0 +1,99 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of check-binary-files,clean-binary-files,create-jar-links and diff-jars command +# ############################################ + +source "../common/common_javapackages-tools.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL tar + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + mkdir hello + CHECK_RESULT $? + cp /usr/share/java/*.jar hello/ + echo 'public class Hello{ + public static void main(String[] args){ + System.out.println("Hello java!"); + } +}' >>hello/Hello.java + tar cvzf hello.tar.gz hello + test -f hello.tar.gz + CHECK_RESULT $? + touch exclusion + CHECK_RESULT $? + clean-binary-files -e exclusion -l -a hello.tar.gz >instructions + CHECK_RESULT $? + grep "remove hello/" instructions + CHECK_RESULT $? + test -f hello-clean.tar.gz + CHECK_RESULT $? + check-binary-files -f instructions -a hello-clean.tar.gz | grep "ERROR" + CHECK_RESULT $? + rm -rf hello-clean.tar.gz + clean-binary-files -f instructions -n -a hello.tar.gz | grep 'rm -f "hello/' + CHECK_RESULT $? + test -f hello-clean.tar.gz + CHECK_RESULT $? + check-binary-files -f instructions -a hello-clean.tar.gz | grep "ERROR" + CHECK_RESULT $? 1 + test -f hello-clean-clean.tar.gz + CHECK_RESULT $? + + mv hello hello_old + tar zxvf hello-clean-clean.tar.gz + test -d hello + CHECK_RESULT $? + create-jar-links -f instructions | grep "build-jar-repository -s" + CHECK_RESULT $? + ls -l hello | grep "].jar -> /usr/share/java/" + CHECK_RESULT $? + create-jar-links -f instructions -a hello-clean-clean.tar.gz | grep "build-jar-repository -s" + CHECK_RESULT $? + test -f hello-clean-clean-clean.tar.gz + CHECK_RESULT $? + mv hello hello_old2 + tar zxvf hello-clean-clean-clean.tar.gz + ls -l hello | grep "].jar -> /usr/share/java/" + CHECK_RESULT $? + create-jar-links -f instructions -p + CHECK_RESULT $? + ls -l hello | grep -E "].jar -> /usr/share/java/|.jar -> /usr/share/java/" + CHECK_RESULT $? + rm -rf hello-clean-clean-clean.tar.gz + create-jar-links -f instructions -p -a hello-clean-clean.tar.gz + CHECK_RESULT $? + test -f hello-clean-clean-clean.tar.gz + CHECK_RESULT $? + + diff-jars hello/easymock.jar hello/junit.jar | grep "+org/" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/javapackages-tools/oe_test_build-classpath/oe_test_build-classpath.sh b/testcases/cli-test/javapackages-tools/oe_test_build-classpath/oe_test_build-classpath.sh new file mode 100644 index 0000000..3238654 --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_build-classpath/oe_test_build-classpath.sh @@ -0,0 +1,54 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of build-classpath and build-classpath-directory command +# ############################################ + +source "../common/common_javapackages-tools.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + build-classpath db | grep -E "/usr/share/java/db.jar" + CHECK_RESULT $? + build-classpath junit | grep -E "/usr/share/java/junit.jar" + CHECK_RESULT $? + build-classpath easymock beust-jcommander | grep -E "/usr/share/java/easymock.jar|/usr/share/java/beust-jcommander.jar" + CHECK_RESULT $? + + build-classpath-directory --help | grep "Usage:" + CHECK_RESULT $? + build-classpath-directory --version | grep "[0-9]" + CHECK_RESULT $? + build-classpath-directory /usr/share/java | tr ':' '\n' | grep "/usr/share/java" + CHECK_RESULT $? + build-classpath-directory /usr/lib | tr ':' '\n' | grep "/usr/lib" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/javapackages-tools/oe_test_build-jar-repository/oe_test_build-jar-repository.sh b/testcases/cli-test/javapackages-tools/oe_test_build-jar-repository/oe_test_build-jar-repository.sh new file mode 100644 index 0000000..b1bfbff --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_build-jar-repository/oe_test_build-jar-repository.sh @@ -0,0 +1,54 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of build-jar-repository and rebuild-jar-repository command +# ############################################ + +source "../common/common_javapackages-tools.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + build-jar-repository -s ./ db.jar && test -L '[db].jar' + CHECK_RESULT $? + build-jar-repository -h ./ junit.jar && test -f '[junit].jar' + CHECK_RESULT $? + build-jar-repository -c ./ easymock.jar && test -f '[easymock].jar' + CHECK_RESULT $? + build-jar-repository -p ./ qdox.jar && test -f qdox.jar + CHECK_RESULT $? + + rebuild-jar-repository -c ./ easymock.jar && test -f '[easymock].jar' + CHECK_RESULT $? + rebuild-jar-repository -h ./ junit.jar && test -f '[junit].jar' + CHECK_RESULT $? + rebuild-jar-repository -s ./ db.jar && test -L '[db].jar' + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/javapackages-tools/oe_test_find-shade-jar/oe_test_find-shade-jar.sh b/testcases/cli-test/javapackages-tools/oe_test_find-shade-jar/oe_test_find-shade-jar.sh new file mode 100644 index 0000000..286b5e9 --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_find-shade-jar/oe_test_find-shade-jar.sh @@ -0,0 +1,52 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of find-jar and shade-jar command +# ############################################ + +source "../common/common_javapackages-tools.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + find-jar junit | grep "/usr/share/java/junit.jar" + CHECK_RESULT $? + find-jar easymock | grep "/usr/share/java/easymock.jar" + CHECK_RESULT $? + + mkdir -p com/example/shade/log4j + CHECK_RESULT $? + mkdir lib + CHECK_RESULT $? + shade-jar org.apache.log4j com.example.shaded.log4j /usr/share/java/log4j.jar lib/shaded-log4j.jar + CHECK_RESULT $? + test -f lib/shaded-log4j.jar + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/javapackages-tools/oe_test_gradle-local/build.gradle b/testcases/cli-test/javapackages-tools/oe_test_gradle-local/build.gradle new file mode 100644 index 0000000..cba8410 --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_gradle-local/build.gradle @@ -0,0 +1,29 @@ +apply plugin: "java-library" +repositories { + jcenter() +} +dependencies { + api "org.apache.commons:commons-math3:3.6.1" + implementation "com.google.guava:guava:23.0" + testImplementation "junit:junit:4.12" +} +task base { + doLast { + println "I am base!" + } +} +task extend(dependsOn: base) { + doLast { + println "I am extend!" + } +} +task dolast <<{ + println "show me! dolast" + println ("show me! dolast") + println ("show me! dolast"); + } +task extendExpExp() { + doLast { + println "I am extendExpExp" + } +} \ No newline at end of file diff --git a/testcases/cli-test/javapackages-tools/oe_test_gradle-local/oe_test_gradle-local.sh b/testcases/cli-test/javapackages-tools/oe_test_gradle-local/oe_test_gradle-local.sh new file mode 100644 index 0000000..b2d91e7 --- /dev/null +++ b/testcases/cli-test/javapackages-tools/oe_test_gradle-local/oe_test_gradle-local.sh @@ -0,0 +1,77 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/26 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of gradle-local command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL gradle-local + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + gradle-local --help | grep "-" + CHECK_RESULT $? + gradle-local -v | grep -i "Gradle" + CHECK_RESULT $? + gradle-local + CHECK_RESULT $? + gradle-local extend | grep -E "BUILD SUCCESSFUL|extend" + CHECK_RESULT $? + gradle-local base | grep -E "BUILD SUCCESSFUL|base" + CHECK_RESULT $? + gradle-local base dolast | grep -E "base|dolast|BUILD SUCCESSFUL" + CHECK_RESULT $? + radle-local base dolast -x dolast | grep "dolast" + CHECK_RESULT $? 1 + gradle-local base --rerun-tasks + CHECK_RESULT $? + gradle-local base --continue + CHECK_RESULT $? + gradle-local -q base | grep "I am base!" + CHECK_RESULT $? + gradle-local -w base + CHECK_RESULT $? + gradle-local -i base | grep -E "Starting Build|All projects evaluated|Tasks to be executed: \[task ':base'\]" + CHECK_RESULT $? + gradle-local base --console plain + CHECK_RESULT $? + gradle-local base --console rich + CHECK_RESULT $? + gradle-local base --status | grep -E "PID|STATUS|INFO|$(gradle-local -v | grep "Gradle" | awk '{print $2}')" + CHECK_RESULT $? + expect <build.log + xmvn-builddep --help | grep "Usage: /usr/bin/xmvn-builddep" + CHECK_RESULT $? + xmvn-builddep build.log + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + rm -rf build.log .gradle + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/jq/oe_test_jq/oe_test_jq.sh b/testcases/cli-test/jq/oe_test_jq/oe_test_jq.sh new file mode 100644 index 0000000..b77b76e --- /dev/null +++ b/testcases/cli-test/jq/oe_test_jq/oe_test_jq.sh @@ -0,0 +1,63 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/21 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of jq command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL jq + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + jq --help | grep "Usage:" + CHECK_RESULT $? + jq --version | grep "jq-" + CHECK_RESULT $? + jq -c "." test.json | grep "url" + CHECK_RESULT $? + jq -n "." test.json | grep "null" + CHECK_RESULT $? + jq -e "." test.json | grep " " + CHECK_RESULT $? + jq -s "." test.json + CHECK_RESULT $? + jq -r "." test.json + CHECK_RESULT $? + jq -R "." test.json | grep '\\' + CHECK_RESULT $? + jq -C "." test.json + CHECK_RESULT $? + jq -M "." test.json + CHECK_RESULT $? + jq -S "." test.json + CHECK_RESULT $? + jq --tab "." test.json + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/jq/oe_test_jq/test.json b/testcases/cli-test/jq/oe_test_jq/test.json new file mode 100644 index 0000000..9d23697 --- /dev/null +++ b/testcases/cli-test/jq/oe_test_jq/test.json @@ -0,0 +1 @@ +[{"name":"站长工具","url":"http://tool.chinaz.com","address":{"city":"厦门","country":"中国"},"arrayBrowser":[{"name":"Google","url":"http://www.google.com"},{"name":"Baidu","url":"http://www.baidu.com"}]},{"name":"站长之家","url":"http://tool.zzhome.com","address":{"city":"大连","country":"中国"},"arrayBrowser":[{"name":"360","url":"http://www.so.com"},{"name":"bing","url":"http://www.bing.com"}]}] \ No newline at end of file diff --git a/testcases/cli-test/kmod/oe_test_depmod/oe_test_depmod.sh b/testcases/cli-test/kmod/oe_test_depmod/oe_test_depmod.sh new file mode 100644 index 0000000..0cc2597 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_depmod/oe_test_depmod.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of depmod command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + depmod --help | grep "-" + CHECK_RESULT $? + depmod -V | grep "kmod version" + CHECK_RESULT $? + depmod -a + CHECK_RESULT $? + depmod -A + CHECK_RESULT $? + depmod --config=./ + CHECK_RESULT $? + symversPath=$(find / -name Module.symvers) + depmod -e -E $symversPath + CHECK_RESULT $? + mapPath=$(find / -name System.map) + depmod -e -F $mapPath + CHECK_RESULT $? + depmod -e -E $symversPath -n + CHECK_RESULT $? + depmod -e -E $symversPath -v + CHECK_RESULT $? + depmod -e -E $symversPath -w + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_insmod-lsmod/oe_test_insmod-lsmod.sh b/testcases/cli-test/kmod/oe_test_insmod-lsmod/oe_test_insmod-lsmod.sh new file mode 100644 index 0000000..55a544c --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_insmod-lsmod/oe_test_insmod-lsmod.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of insmod and lsmod command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + insmod -h | grep -E "Usage:|insmod \[options\]" + CHECK_RESULT $? + insmod -V | grep "kmod version" + CHECK_RESULT $? + raid0Path=$(find /usr/lib/modules/ -name raid0.ko) + faultyPath=$(find /usr/lib/modules/ -name faulty.ko) + lsmod | grep raid0 && modprobe -r raid0 + CHECK_RESULT $? + lsmod | grep faulty && modprobe -r faulty + CHECK_RESULT $? + insmod -p $raid0Path + CHECK_RESULT $? + lsmod | grep raid0 + CHECK_RESULT $? + insmod -p $faultyPath + CHECK_RESULT $? + lsmod | grep faulty + CHECK_RESULT $? + insmod $raid0Path + CHECK_RESULT $? 1 + insmod $faultyPath + CHECK_RESULT $? 1 + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_kmod/oe_test_kmod.sh b/testcases/cli-test/kmod/oe_test_kmod/oe_test_kmod.sh new file mode 100644 index 0000000..d3169b7 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_kmod/oe_test_kmod.sh @@ -0,0 +1,37 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of kmod command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + kmod -h | grep -E "Usage:|kmod \[options\]" + CHECK_RESULT $? + kmod -V | grep -i "kmod version" + CHECK_RESULT $? + kmod help | grep -E "Usage:|help \[options\]" + CHECK_RESULT $? + kmod list | grep "[a-zA-Z0-9]" + CHECK_RESULT $? + kmod static-nodes | grep -E "Module|Device node" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_modinfo/oe_test_modinfo.sh b/testcases/cli-test/kmod/oe_test_modinfo/oe_test_modinfo.sh new file mode 100644 index 0000000..c9dae26 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_modinfo/oe_test_modinfo.sh @@ -0,0 +1,45 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of modinfo command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + modinfo --help | grep -E "modinfo|-" + CHECK_RESULT $? + modinfo -V | grep "kmod version" + CHECK_RESULT $? + lsmod | grep "[a-zA-Z0-9]" + CHECK_RESULT $? + modinfo -a dm_log | grep "dm-devel@redhat.com" + CHECK_RESULT $? + modinfo -d dm_log | grep "device-mapper" + CHECK_RESULT $? + modinfo -l dm_log | grep "GPL" + CHECK_RESULT $? + modinfo -p raid1 | grep -E "max_queued_requests|int" + CHECK_RESULT $? + modinfo -n dm_log | grep "dm-log" + CHECK_RESULT $? + modinfo -0 dm_log | grep -aE "filename|dm-log|dm-devel@redhat.com|:" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_modprobe/oe_test_modprobe.sh b/testcases/cli-test/kmod/oe_test_modprobe/oe_test_modprobe.sh new file mode 100644 index 0000000..41d38f4 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_modprobe/oe_test_modprobe.sh @@ -0,0 +1,66 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of modprobe command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + modprobe --help | grep -E "Usage:|modprobe" + CHECK_RESULT $? + modprobe --version | grep "kmod version" + CHECK_RESULT $? + lsmod | grep dm_log && modprobe dm_log + CHECK_RESULT $? + lsmod | grep -E "dm_log|dm_mirror" && modprobe -a dm_log dm_mirror + CHECK_RESULT $? + lsmod | grep dm_mirror && modprobe -r dm_mirror + CHECK_RESULT $? + lsmod | grep dm_mirror + CHECK_RESULT $? 1 + modprobe --remove-dependencies dm_log + CHECK_RESULT $? + modprobe -R dm_log | grep "dm_log" + CHECK_RESULT $? + modprobe --first-time dm_cache + CHECK_RESULT $? + lsmod | grep dm_cache + CHECK_RESULT $? + modprobe -r dm_cache + CHECK_RESULT $? + modprobe -f dm_cache + CHECK_RESULT $? + modprobe -r -f dm_cache + CHECK_RESULT $? + lsmod | grep dm_cache + CHECK_RESULT $? 1 + modprobe -D dm_log | grep "insmod" + CHECK_RESULT $? + modprobe -c | grep "alias symbol" + CHECK_RESULT $? + modprobe --show-config | grep "alias symbol:" + CHECK_RESULT $? + dmPath=$(find /usr/lib/modules/ -name dm-log.ko) + modprobe --show-modversions $dmPath | grep "[0-9]" + CHECK_RESULT $? + modprobe --dump-modversions $dmPath | grep "[0-9]" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_rmmod/oe_test_rmmod.sh b/testcases/cli-test/kmod/oe_test_rmmod/oe_test_rmmod.sh new file mode 100644 index 0000000..8add4a3 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_rmmod/oe_test_rmmod.sh @@ -0,0 +1,47 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of rmmod command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + rmmod --help | grep -E "Usage:|rmmod \[options\]" + CHECK_RESULT $? + rmmod --version | grep "kmod version" + CHECK_RESULT $? + modprobe -a dm_log dm_mirror + CHECK_RESULT $? + rmmod -f -v dm_mirror + CHECK_RESULT $? + lsmod | grep dm_mirror + CHECK_RESULT $? 1 + lsmod | grep dm_log + CHECK_RESULT $? + rmmod -v dm_log + CHECK_RESULT $? 1 + rmmod -s dm_log + CHECK_RESULT $? 1 + rmmod -v dm_region_hash + CHECK_RESULT $? + rmmod -v -s dm_log + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/kmod/oe_test_weak-modules/oe_test_weak-modules.sh b/testcases/cli-test/kmod/oe_test_weak-modules/oe_test_weak-modules.sh new file mode 100644 index 0000000..40c1831 --- /dev/null +++ b/testcases/cli-test/kmod/oe_test_weak-modules/oe_test_weak-modules.sh @@ -0,0 +1,42 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of weak-modules command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function run_test() { + LOG_INFO "Start to run test." + weak-modules --help + CHECK_RESULT $? + extraPath=$(find / -name extra | awk 'NR==2') + echo $extraPath/catch.ko | weak-modules --add-module --no-initramfs + CHECK_RESULT $? + echo $extraPath/catch.ko | weak-modules --add-module --verbose + CHECK_RESULT $? + echo $extraPath/catch.ko | weak-modules --remove-modules + CHECK_RESULT $? + echo $extraPath/catch.ko | weak-modules --add-kernel + CHECK_RESULT $? + echo $extraPath/catch.ko | weak-modules --remove-kernel + CHECK_RESULT $? + weak-modules --dry-run --add-kernel + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +main $@ diff --git a/testcases/cli-test/libmemcached/common/common_libmemcached.sh b/testcases/cli-test/libmemcached/common/common_libmemcached.sh new file mode 100644 index 0000000..bd9879a --- /dev/null +++ b/testcases/cli-test/libmemcached/common/common_libmemcached.sh @@ -0,0 +1,36 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################ +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/27 +# @License : Mulan PSL v2 +# @Version : 1.0 +# @Desc : public class integration +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function deploy_env() { + DNF_INSTALL "libmemcached memcached telnet net-tools" + memcached -d -u root -m 512 -p 11211 + sleep 5 + netstat -an | grep 11211 + pgrep -f 'memcached -d -u' +} + +function clear_env() { + kill -9 $(pgrep -f 'memcached -d -u') + roc=$(ls | grep -vE ".sh|config") + rm -rf $roc + DNF_REMOVE +} diff --git a/testcases/cli-test/libmemcached/oe_test_memaslap/config b/testcases/cli-test/libmemcached/oe_test_memaslap/config new file mode 100644 index 0000000..32bcfbd --- /dev/null +++ b/testcases/cli-test/libmemcached/oe_test_memaslap/config @@ -0,0 +1,7 @@ +key +128 128 1 +value +2048 2048 1 +cmd +0 0.1 +1.0 0.9 \ No newline at end of file diff --git a/testcases/cli-test/libmemcached/oe_test_memaslap/oe_test_memaslap.sh b/testcases/cli-test/libmemcached/oe_test_memaslap/oe_test_memaslap.sh new file mode 100644 index 0000000..9fba035 --- /dev/null +++ b/testcases/cli-test/libmemcached/oe_test_memaslap/oe_test_memaslap.sh @@ -0,0 +1,73 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/27 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of memaslap command +# ############################################ + +source "../common/common_libmemcached.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + memaslap --help | grep "-" + CHECK_RESULT $? + memaslap -V | grep "memslap.*.[0-9]" + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -S 5s -t 15s | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 15s|Period.*5" log + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -t 10s -v 0.2 -e 0.05 -b | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 10s" log + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -F config -t 12s -w 40k -S 3s -o 0.2 | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 12s|windows size: 40k|Period.*3" log + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -F config -t 5s | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 5s" log + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -F config -t 2s -T 4 -c 128 -d 20 -P 40k | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 2s|threads count: 4|concurrency: 128" log + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211 -F config -t 4s -d 50 -a -n 40 | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211|run time: 4s" log + CHECK_RESULT $? + memcached -d -u root -m 512 -l 127.0.0.1 -p 11212 + CHECK_RESULT $? + memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 5s -p 2 | tee log + CHECK_RESULT $? + grep -E "servers : 127.0.0.1:11211,127.0.0.1:11212|run time: 5s" log + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + clear_env + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/libmemcached/oe_test_memcapable/oe_test_memcapable.sh b/testcases/cli-test/libmemcached/oe_test_memcapable/oe_test_memcapable.sh new file mode 100644 index 0000000..0343dae --- /dev/null +++ b/testcases/cli-test/libmemcached/oe_test_memcapable/oe_test_memcapable.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/27 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of memcapable command +# ############################################ + +source "../common/common_libmemcached.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + deploy_env + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + memcapable -p 11211 -c | grep -E "ascii verbosity" + CHECK_RESULT $? + memcapable -p 11211 -v | grep -E "ascii|binary|pass" + CHECK_RESULT $? + memcapable -p 11211 -t 5 | grep "pass" + CHECK_RESULT $? + expect </dev/null 2>&1 & + SLEEP_WAIT 20 + osinfo-detect --format=env openEuler-20.03-LTS-aarch64-dvd.iso + CHECK_RESULT $? + osinfo-detect --format=plain openEuler-20.03-LTS-aarch64-dvd.iso + CHECK_RESULT $? + osinfo-detect --type=media openEuler-20.03-LTS-aarch64-dvd.iso + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + kill -9 $(pgrep -f 'wget') + roc=$(ls | grep -v ".sh") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/libosinfo/oe_test_osinfo-install-script/oe_test_osinfo-install-script.sh b/testcases/cli-test/libosinfo/oe_test_osinfo-install-script/oe_test_osinfo-install-script.sh new file mode 100644 index 0000000..c4b3452 --- /dev/null +++ b/testcases/cli-test/libosinfo/oe_test_osinfo-install-script/oe_test_osinfo-install-script.sh @@ -0,0 +1,57 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of osinfo-install-script command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL libosinfo + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + osinfo-install-script --help | grep -E "Usage:|osinfo-install-script \[OPTION…\]" + CHECK_RESULT $? + osinfo-install-script --profile jeos --config l10n-timezone=GMT --config l10n-keyboard=uk --config l10n-language=en_GB --config admin-password=123456 --config user-login=berrange --config user-password=123456 --config user-realname="Daniel P Berrange" fedora16 + CHECK_RESULT $? + test -f fedora.ks && rm -rf fedora.ks + CHECK_RESULT $? + mkdir testdir + CHECK_RESULT $? + osinfo-install-script --profile jeos --config l10n-timezone=GMT --config l10n-keyboard=uk --config l10n-language=en_GB --config admin-password=123456 --config user-login=berrange --config user-password=123456 --config user-realname="Daniel P Berrange" fedora16 --output-dir testdir/ + CHECK_RESULT $? + test -f testdir/fedora.ks + CHECK_RESULT $? + osinfo-install-script --profile jeos --config l10n-timezone=GMT --config l10n-keyboard=uk --config l10n-language=en_GB --config admin-password=123456 --config user-login=berrange --config user-password=123456 --config user-realname="Daniel P Berrange" fedora16 -q + CHECK_RESULT $? + test -f fedora.ks + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + roc=$(ls | grep -v ".sh") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/libosinfo/oe_test_osinfo-query/oe_test_osinfo-query.sh b/testcases/cli-test/libosinfo/oe_test_osinfo-query/oe_test_osinfo-query.sh new file mode 100644 index 0000000..49cff5b --- /dev/null +++ b/testcases/cli-test/libosinfo/oe_test_osinfo-query/oe_test_osinfo-query.sh @@ -0,0 +1,51 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/29 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of osinfo-query command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL libosinfo + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + osinfo-query --help | grep -E "Usage:|osinfo-query \[OPTION…\]" + CHECK_RESULT $? + osinfo-query os | grep "http:" + CHECK_RESULT $? + osinfo-query os vendor="Fedora Project" | grep "Fedora" + CHECK_RESULT $? + osinfo-query --sort=version os vendor="Fedora Project" | grep "[0-9]" + CHECK_RESULT $? + osinfo-query --sort=version os | grep "[0-9a-Z]" + CHECK_RESULT $? + osinfo-query --fields=short-id,version os vendor="openSUSE" | grep "opensuse" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/mutt/oe_test_mutt/oe_test_mutt.sh b/testcases/cli-test/mutt/oe_test_mutt/oe_test_mutt.sh new file mode 100644 index 0000000..8a6b2a8 --- /dev/null +++ b/testcases/cli-test/mutt/oe_test_mutt/oe_test_mutt.sh @@ -0,0 +1,68 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/10 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of mutt command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL "mutt sendmail" + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + muttFile=$(find / -name Muttrc) + cp $muttFile /root/.muttrc + echo 'set charset="utf-8" + set rfc2047_parameters=yes + set envelope_from=yes + set use_from=yes + set from=root@itdhz.com + set realname="itdhz"' >>/root/.muttrc + touch test.jar + CHECK_RESULT $? + echo "test mutt from lisa" >sendmail + mutt -help | grep "usage: mutt" + CHECK_RESULT $? + mutt -version | grep "Copyright (C) 1996-2016 Michael R. Elkins and others" + CHECK_RESULT $? + mutt Lisa@163.com -s "test mutt01" |Subject: test mutt01|test mutt from lisa" + CHECK_RESULT $? + mutt Lisa@163.com -s "test mutt02" -a test.jar sendmail + mutt -s "test mutt04" -c lisa@gmail.com -b jack@server1.tecmint.com john@server1.tecmint.com /dev/null 2>&1 & + pgrep -f 'openvpn --local' + CHECK_RESULT $? + ping -c 3 10.4.0.1 >/dev/null + CHECK_RESULT $? + + kill -9 $(pgrep -f 'openvpn --local') + SLEEP_WAIT 15 + pgrep -f 'openvpn --local' + CHECK_RESULT $? 1 + + nohup openvpn --remote ${NODE2_IPV4} --dev tun1 --ifconfig 10.4.0.1 10.4.0.2 --verb 9 >/dev/null 2>&1 & + CHECK_RESULT $? + pgrep -f 'openvpn --remote' + CHECK_RESULT $? + + SSH_CMD "nohup openvpn --remote ${NODE1_IPV4} --dev tun1 --ifconfig 10.4.0.2 10.4.0.1 --verb 9 >/dev/null 2>&1 &" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + remote_pid=$(SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} | tail -n 1 | awk -F '\r' '{print $1}') + CHECK_RESULT $? + + ping -c 3 10.4.0.2 >/dev/null + CHECK_RESULT $? + SSH_CMD "ping -c 3 10.4.0.1 >/dev/null" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + kill -9 $(pgrep -f 'openvpn --remote') + SLEEP_WAIT 15 + pgrep -f 'openvpn --remote' + CHECK_RESULT $? 1 + SSH_CMD "kill -9 $remote_pid" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + SLEEP_WAIT 15 + SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? 1 + + openvpn --genkey --secret key + CHECK_RESULT $? + grep -iE "[a-z0-9]|openvpn" key + CHECK_RESULT $? + + SSH_SCP key ${NODE2_USER}@${NODE2_IPV4}:~ "${NODE2_PASSWORD}" + CHECK_RESULT $? + SSH_CMD "test -f key" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + + nohup openvpn --remote ${NODE2_IPV4} --dev tun1 --ifconfig 10.4.0.1 10.4.0.2 --verb 5 --secret key >/dev/null 2>&1 & + pgrep -f 'openvpn --remote' + CHECK_RESULT $? + SSH_CMD "nohup openvpn --remote ${NODE1_IPV4} --dev tun1 --ifconfig 10.4.0.2 10.4.0.1 --verb 5 --secret key >/dev/null 2>&1 &" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + remote_pid=$(SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} | tail -n 1 | awk -F '\r' '{print $1}') + CHECK_RESULT $? + + ping -c 3 10.4.0.2 >/dev/null + CHECK_RESULT $? + SSH_CMD "ping -c 3 10.4.0.1 >/dev/null" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + kill -9 $(pgrep -f 'openvpn --remote') + SLEEP_WAIT 15 + pgrep -f 'openvpn --remote' + CHECK_RESULT $? 1 + SSH_CMD "kill -9 $remote_pid" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + SLEEP_WAIT 15 + SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? 1 + + expect </dev/null 2>&1 & + pgrep -f 'openvpn --remote' + CHECK_RESULT $? + ping -c 3 10.4.0.1 >/dev/null + CHECK_RESULT $? + kill -9 $(pgrep -f 'openvpn --remote') + SLEEP_WAIT 15 + pgrep -f 'openvpn --remote' + CHECK_RESULT $? 1 + + expect </dev/null 2>&1 &" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + remote_pid=$(SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} | tail -n 1 | awk -F '\r' '{print $1}') + CHECK_RESULT $? + SSH_CMD "ping -c 3 10.4.0.2 >/dev/null" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + SSH_CMD "kill -9 $remote_pid" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + SLEEP_WAIT 15 + SSH_CMD "pgrep -f 'openvpn --remote'" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? 1 + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + roc=$(ls | grep -v ".sh") + rm -rf $roc + CHECK_RESULT $? + SSH_CMD "rm -rf ca.crt dh1024.pem key server.crt server.key" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + CHECK_RESULT $? + SSH_CMD "dnf remove openvpn -y" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER} + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/php/common/my_script.php b/testcases/cli-test/php/common/my_script.php new file mode 100644 index 0000000..d06a537 --- /dev/null +++ b/testcases/cli-test/php/common/my_script.php @@ -0,0 +1,8 @@ + + + PHP test + + + Hello World

'; ?> + + diff --git a/testcases/cli-test/php/common/myphp.ini b/testcases/cli-test/php/common/myphp.ini new file mode 100644 index 0000000..f42d967 --- /dev/null +++ b/testcases/cli-test/php/common/myphp.ini @@ -0,0 +1,37 @@ +[sysvshm] +; A default size of the shared memory segment +;sysvshm.init_mem = 10000 + +[ldap] +; Sets the maximum number of open links or -1 for unlimited. +ldap.max_links = -1 + +[dba] +;dba.default_handler= + +[curl] +; A default value for the CURLOPT_CAINFO option. This is required to be an +; absolute path. +;curl.cainfo = + +[openssl] +; The location of a Certificate Authority (CA) file on the local filesystem +; to use when verifying the identity of SSL/TLS peers. Most users should +; not specify a value for this directive as PHP will attempt to use the +; OS-managed cert stores in its absence. If specified, this value may still +; be overridden on a per-stream basis via the cafile SSL stream context +; option. +;openssl.cafile= + +; If openssl.cafile is not specified or if the CA file is not found, the +; directory pointed to by openssl.capath is searched for a suitable +; certificate. This value must be a correctly hashed certificate directory. +; Most users should not specify a value for this directive as PHP will +; attempt to use the OS-managed cert stores in its absence. If specified, +; this value may still be overridden on a per-stream basis via the capath +; SSL stream context option. +;openssl.capath= + +; Local Variables: +; tab-width: 4 +; End: diff --git a/testcases/cli-test/php/common/project/Lib.php b/testcases/cli-test/php/common/project/Lib.php new file mode 100644 index 0000000..4c9f0cb --- /dev/null +++ b/testcases/cli-test/php/common/project/Lib.php @@ -0,0 +1,5 @@ + + + + + phar + + + + + diff --git a/testcases/cli-test/php/common/test.php b/testcases/cli-test/php/common/test.php new file mode 100644 index 0000000..c512f67 --- /dev/null +++ b/testcases/cli-test/php/common/test.php @@ -0,0 +1,95 @@ + + + + + + + +

PHP Verification examples

+

* Required fields

+
"> + Name: + * +

+ Email: + * +

+ Address: + +

+ Comment: +

+ Gender: + female + male + * +

+ +
+ Your input:"; + echo $name; + echo "
"; + echo $email; + echo "
"; + echo $website; + echo "
"; + echo $comment; + echo "
"; + echo $gender; + ?> + + diff --git a/testcases/cli-test/php/common/testBuild.php b/testcases/cli-test/php/common/testBuild.php new file mode 100644 index 0000000..bb09faf --- /dev/null +++ b/testcases/cli-test/php/common/testBuild.php @@ -0,0 +1,4 @@ +buildFromDirectory(dirname(__FILE__) . '/project'); + $phar->setDefaultStub('index.php', 'index.php'); diff --git a/testcases/cli-test/php/oe_test_phar/oe_test_phar.sh b/testcases/cli-test/php/oe_test_phar/oe_test_phar.sh new file mode 100644 index 0000000..4cc401a --- /dev/null +++ b/testcases/cli-test/php/oe_test_phar/oe_test_phar.sh @@ -0,0 +1,168 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/19 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of phar and phar.phar command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL php-cli + sed -i 's/;phar.readonly = On/phar.readonly = Off/g' /etc/php.ini || exit 1 + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php ../common/testBuild.php + CHECK_RESULT $? + test -f test.phar + CHECK_RESULT $? + phar help | grep "/usr/bin/phar \[options\]" + CHECK_RESULT $? + phar help-list | grep "add compress delete extract help help-list info list meta-del meta-get meta-set pack sign stub-get stub-set tree version" + CHECK_RESULT $? + phar version | grep -i "version" + CHECK_RESULT $? + + phar add -f test.phar ../common/project/ | grep -E "lib/lib_a.php|template/msg.html|Lib.php|file/test.css|file/test.js|index.php" + CHECK_RESULT $? + phar add -f test.phar -a tt.phar ../common/project/ + CHECK_RESULT $? + phar info -f test.phar | grep "Uncompressed-files: 6" + CHECK_RESULT $? + phar add -f test.phar -c gz ../common/project/ + CHECK_RESULT $? + phar info -f test.phar | grep 'Compressed-gz.*6' + CHECK_RESULT $? + phar add -f test.phar -i .php ../common/project/ | grep ".php" + CHECK_RESULT $? + phar add -f test.phar -l 1 ../common/project/ | grep -E "lib_a.php|msg.html|Lib.php|test.css|test.js|index.php" + CHECK_RESULT $? + phar add -f test.phar -x .php ../common/project/ | grep ".php" + CHECK_RESULT $? 1 + + phar info -f test.phar | grep "Uncompressed-files: 10" + CHECK_RESULT $? + phar compress -f test.phar -c bz2 + CHECK_RESULT $? + phar info -f test.phar | grep "Compressed-bz2.*10" + CHECK_RESULT $? + phar compress -f test.phar -c bz2 -e lib/lib_a.php + CHECK_RESULT $? + + b_count=$(phar list -f test.phar | wc -l) + phar delete -f test.phar -e lib_a.php + CHECK_RESULT $? + a_count=$(phar list -f test.phar | wc -l) + test $b_count -eq $a_count + CHECK_RESULT $? 1 + phar list -f test.phar | grep "test.phar/lib_a.php" + CHECK_RESULT $? 1 + + phar extract -f test.phar test1/ | grep "ok" + CHECK_RESULT $? + test -d test1 + CHECK_RESULT $? + phar extract -f test.phar -i .css test2/ | grep "ok" + CHECK_RESULT $? + test -d test2 + CHECK_RESULT $? + phar extract -f test.phar -x .css test3/ | grep "ok" + CHECK_RESULT $? + test -d test3 + CHECK_RESULT $? + + phar info -f test.phar | grep -E "Alias|Hash-type|Hash|Entries|Uncompressed-files|Compressed-files|Compressed-gz|Compressed-bz2|Uncompressed-size|Compressed-size|Compression-ratio|Metadata-global|Metadata-files|Stub-size" + CHECK_RESULT $? + phar info -f test.phar -k 3 + CHECK_RESULT $? 1 + + phar list -f test.phar | grep "phar:" + CHECK_RESULT $? + phar list -f test.phar -i lib | grep "lib" + CHECK_RESULT $? + phar list -f test.phar -x .css | grep ".css" + CHECK_RESULT $? 1 + + phar meta-del -f test.phar + CHECK_RESULT $? + phar meta-del -f test.phar -k 3 + CHECK_RESULT $? 1 + phar meta-del -f test.phar -e /lib/lib_a.php + CHECK_RESULT $? + + phar meta-get -f test.phar | grep "No Metadata" + CHECK_RESULT $? + phar meta-get -f test.phar -k 2 | grep "No Metadata" + CHECK_RESULT $? + phar meta-get -f test.phar -e /lib/lib_a.php | grep "No Metadata" + CHECK_RESULT $? + + phar pack -f test.phar test1/ + CHECK_RESULT $? + phar pack -f test.phar -b dd test1/ + CHECK_RESULT $? + phar info -f test.phar | grep "Uncompressed-files: 9" + CHECK_RESULT $? + phar pack -f test.phar -c gz test1/ + CHECK_RESULT $? + phar info -f test.phar | grep "Compressed-gz.*9" + CHECK_RESULT $? + phar pack -f test.phar -h md5 test1/ + CHECK_RESULT $? + phar info -f test.phar | grep "MD5" + CHECK_RESULT $? + phar pack -f test.phar -i .php test1/ | grep ".php" + CHECK_RESULT $? + phar pack -f test.phar -l 1 test1/ + CHECK_RESULT $? + phar pack -f test.phar -p 0 test1/ + CHECK_RESULT $? + phar pack -f test.phar -x .css test1/ | grep ".css" + CHECK_RESULT $? 1 + + phar tree -f test.phar | grep -E "file|lib|template" + CHECK_RESULT $? + phar tree -f test.phar -i lib | grep "lib" + CHECK_RESULT $? + phar tree -f test.phar -x file | grep "file" + CHECK_RESULT $? 1 + + phar sign -f test.phar -h sha512 + CHECK_RESULT $? + phar info -f test.phar | grep "SHA-512" + CHECK_RESULT $? + openssl genrsa -out ca.key 1024 + CHECK_RESULT $? + test -f ca.key + CHECK_RESULT $? + phar sign -f test.phar -h openssl -y ca.key + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + sed -i 's/phar.readonly = Off/;phar.readonly = On/g' /etc/php.ini + roc=$(ls | grep -v ".sh") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ \ No newline at end of file diff --git a/testcases/cli-test/php/oe_test_phar_phar/oe_test_phar_phar.sh b/testcases/cli-test/php/oe_test_phar_phar/oe_test_phar_phar.sh new file mode 100644 index 0000000..a69ac14 --- /dev/null +++ b/testcases/cli-test/php/oe_test_phar_phar/oe_test_phar_phar.sh @@ -0,0 +1,168 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/19 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of phar.phar command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL php-cli + sed -i 's/;phar.readonly = On/phar.readonly = Off/g' /etc/php.ini || exit 1 + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php ../common/testBuild.php + CHECK_RESULT $? + test -f test.phar + CHECK_RESULT $? + phar.phar help | grep "/usr/bin/phar.phar \[options\]" + CHECK_RESULT $? + phar.phar help-list | grep "add compress delete extract help help-list info list meta-del meta-get meta-set pack sign stub-get stub-set tree version" + CHECK_RESULT $? + phar.phar version | grep -i "version" + CHECK_RESULT $? + + phar.phar add -f test.phar ../common/project/ | grep -E "lib/lib_a.php|template/msg.html|Lib.php|file/test.css|file/test.js|index.php" + CHECK_RESULT $? + phar.phar add -f test.phar -a tt.phar ../common/project/ + CHECK_RESULT $? + phar.phar info -f test.phar | grep "Uncompressed-files: 6" + CHECK_RESULT $? + phar.phar add -f test.phar -c gz ../common/project/ + CHECK_RESULT $? + phar.phar info -f test.phar | grep 'Compressed-gz.*6' + CHECK_RESULT $? + phar.phar add -f test.phar -i .php ../common/project/ | grep ".php" + CHECK_RESULT $? + phar.phar add -f test.phar -l 1 ../common/project/ | grep -E "lib_a.php|msg.html|Lib.php|test.css|test.js|index.php" + CHECK_RESULT $? + phar.phar add -f test.phar -x .php ../common/project/ | grep ".php" + CHECK_RESULT $? 1 + + phar.phar info -f test.phar | grep "Uncompressed-files: 10" + CHECK_RESULT $? + phar.phar compress -f test.phar -c bz2 + CHECK_RESULT $? + phar.phar info -f test.phar | grep "Compressed-bz2.*10" + CHECK_RESULT $? + phar.phar compress -f test.phar -c bz2 -e lib/lib_a.php + CHECK_RESULT $? + + b_count=$(phar.phar list -f test.phar | wc -l) + phar.phar delete -f test.phar -e lib_a.php + CHECK_RESULT $? + a_count=$(phar.phar list -f test.phar | wc -l) + test $b_count -eq $a_count + CHECK_RESULT $? 1 + phar.phar list -f test.phar | grep "test.phar/lib_a.php" + CHECK_RESULT $? 1 + + phar.phar extract -f test.phar test1/ | grep "ok" + CHECK_RESULT $? + test -d test1 + CHECK_RESULT $? + phar.phar extract -f test.phar -i .css test2/ | grep "ok" + CHECK_RESULT $? + test -d test2 + CHECK_RESULT $? + phar.phar extract -f test.phar -x .css test3/ | grep "ok" + CHECK_RESULT $? + test -d test3 + CHECK_RESULT $? + + phar.phar info -f test.phar | grep -E "Alias|Hash-type|Hash|Entries|Uncompressed-files|Compressed-files|Compressed-gz|Compressed-bz2|Uncompressed-size|Compressed-size|Compression-ratio|Metadata-global|Metadata-files|Stub-size" + CHECK_RESULT $? + phar.phar info -f test.phar -k 3 + CHECK_RESULT $? 1 + + phar.phar list -f test.phar | grep "phar:" + CHECK_RESULT $? + phar.phar list -f test.phar -i lib | grep "lib" + CHECK_RESULT $? + phar.phar list -f test.phar -x .css | grep ".css" + CHECK_RESULT $? 1 + + phar.phar meta-del -f test.phar + CHECK_RESULT $? + phar.phar meta-del -f test.phar -k 3 + CHECK_RESULT $? 1 + phar.phar meta-del -f test.phar -e /lib/lib_a.php + CHECK_RESULT $? + + phar.phar meta-get -f test.phar | grep "No Metadata" + CHECK_RESULT $? + phar.phar meta-get -f test.phar -k 2 | grep "No Metadata" + CHECK_RESULT $? + phar.phar meta-get -f test.phar -e /lib/lib_a.php | grep "No Metadata" + CHECK_RESULT $? + + phar.phar pack -f test.phar test1/ + CHECK_RESULT $? + phar.phar pack -f test.phar -b dd test1/ + CHECK_RESULT $? + phar.phar info -f test.phar | grep "Uncompressed-files: 9" + CHECK_RESULT $? + phar.phar pack -f test.phar -c gz test1/ + CHECK_RESULT $? + phar.phar info -f test.phar | grep "Compressed-gz.*9" + CHECK_RESULT $? + phar.phar pack -f test.phar -h md5 test1/ + CHECK_RESULT $? + phar.phar info -f test.phar | grep "MD5" + CHECK_RESULT $? + phar.phar pack -f test.phar -i .php test1/ | grep ".php" + CHECK_RESULT $? + phar.phar pack -f test.phar -l 1 test1/ + CHECK_RESULT $? + phar.phar pack -f test.phar -p 0 test1/ + CHECK_RESULT $? + phar.phar pack -f test.phar -x .css test1/ | grep ".css" + CHECK_RESULT $? 1 + + phar.phar tree -f test.phar | grep -E "file|lib|template" + CHECK_RESULT $? + phar.phar tree -f test.phar -i lib | grep "lib" + CHECK_RESULT $? + phar.phar tree -f test.phar -x file | grep "file" + CHECK_RESULT $? 1 + + phar.phar sign -f test.phar -h sha512 + CHECK_RESULT $? + phar.phar info -f test.phar | grep "SHA-512" + CHECK_RESULT $? + openssl genrsa -out ca.key 1024 + CHECK_RESULT $? + test -f ca.key + CHECK_RESULT $? + phar.phar sign -f test.phar -h openssl -y ca.key + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + sed -i 's/phar.readonly = Off/;phar.readonly = On/g' /etc/php.ini + roc=$(ls | grep -v ".sh") + rm -rf $roc + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ \ No newline at end of file diff --git a/testcases/cli-test/php/oe_test_php-cgi_phpize/oe_test_php-cgi_phpize.sh b/testcases/cli-test/php/oe_test_php-cgi_phpize/oe_test_php-cgi_phpize.sh new file mode 100644 index 0000000..ecf33ea --- /dev/null +++ b/testcases/cli-test/php/oe_test_php-cgi_phpize/oe_test_php-cgi_phpize.sh @@ -0,0 +1,79 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/16 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of php-cgi and phpize command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL "php-cli php-devel" + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php-cgi --help | grep "\-" + CHECK_RESULT $? + php-cgi -v | grep "PHP" + CHECK_RESULT $? + expect <|class|" + CHECK_RESULT $? + php-cgi -l ../common/my_script.php | grep "No syntax errors detected in.*" + CHECK_RESULT $? + php-cgi -l ../common/test.php | grep "No syntax errors detected in.*" + CHECK_RESULT $? + php-cgi -m | grep -E "\[PHP Modules\]|\[Zend Modules\]" + CHECK_RESULT $? + php-cgi -m | grep -E "\[PHP Modules\]|\[Zend Modules\]" + CHECK_RESULT $? + php-cgi -q ../common/my_script.php + CHECK_RESULT $? + php-cgi -s ../common/my_script.php + CHECK_RESULT $? + php-cgi -w ../common/my_script.php + CHECK_RESULT $? + php-cgi -T 3 ../common/my_script.php | grep -E "PHP test|Elapsed time:" + CHECK_RESULT $? + + phpize --help | grep "Usage:" + CHECK_RESULT $? + phpize --version | grep -E "Version|No" + CHECK_RESULT $? + phpize --clean | grep "Cannot find config.m4" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/php/oe_test_php-config/oe_test_php-config.sh b/testcases/cli-test/php/oe_test_php-config/oe_test_php-config.sh new file mode 100644 index 0000000..3b99772 --- /dev/null +++ b/testcases/cli-test/php/oe_test_php-config/oe_test_php-config.sh @@ -0,0 +1,65 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/20 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of php-config command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL php-devel + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php-config --help | grep "Usage:" + CHECK_RESULT $? + php-config --version | grep ".*" + CHECK_RESULT $? + php-config --vernum | grep "0" + CHECK_RESULT $? + php-config --prefix | grep "/usr" + CHECK_RESULT $? + php-config --includes | grep "/usr" + CHECK_RESULT $? + php-config --ldflags + CHECK_RESULT $? + php-config --libs | grep "-" + CHECK_RESULT $? + php-config --extension-dir | grep "/usr/lib64/php/modules" + CHECK_RESULT $? + php-config --include-dir | grep "/usr/include/php" + CHECK_RESULT $? + php-config --php-binary | grep "/usr/bin/php" + CHECK_RESULT $? + php-config --php-sapis | grep "apache2handler embed fpm cli phpdbg cgi" + CHECK_RESULT $? + php-config --configure-options | grep "\--" + CHECK_RESULT $? + php-config --man-dir | grep "/usr/share/man" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/php/oe_test_php-fpm/oe_test_php-fpm.sh b/testcases/cli-test/php/oe_test_php-fpm/oe_test_php-fpm.sh new file mode 100644 index 0000000..d20262a --- /dev/null +++ b/testcases/cli-test/php/oe_test_php-fpm/oe_test_php-fpm.sh @@ -0,0 +1,49 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/20 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of php-fpm command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL php-fpm + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php-fpm --help | grep "Usage:" + CHECK_RESULT $? + php-fpm -v | grep "PHP" + CHECK_RESULT $? + php-fpm -i | grep "_SERVER" + CHECK_RESULT $? + php-fpm -m | grep -E "\[PHP Modules\]|\[Zend Modules\]" + CHECK_RESULT $? + php-fpm --test + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/php/oe_test_php/oe_test_php.sh b/testcases/cli-test/php/oe_test_php/oe_test_php.sh new file mode 100644 index 0000000..fb84b18 --- /dev/null +++ b/testcases/cli-test/php/oe_test_php/oe_test_php.sh @@ -0,0 +1,92 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/16 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of php command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL "php-cli php-devel" + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + php --help | grep "\-" + CHECK_RESULT $? + php --version | grep "PHP" + CHECK_RESULT $? + expect <" {send "quit\r"} + expect eof +EOF + php -c ./ ../common/my_script.php | grep "PHP test" + CHECK_RESULT $? + php -c ../common/myphp.ini ../common/my_script.php | grep "PHP test" + CHECK_RESULT $? + php -n -f ../common/my_script.php | grep "PHP test" + CHECK_RESULT $? + php -r '$foo = ini_get("max_execution_time"); var_dump($foo);' | grep 'string(1) "0"' + CHECK_RESULT $? + php -d max_execution_time=20 -r '$foo = ini_get("max_execution_time"); var_dump($foo);' | grep 'string(2) "20"' + CHECK_RESULT $? + php -e ../common/my_script.php | grep "PHP test" + CHECK_RESULT $? + php -i | grep -E "phpinfo|Configuration|Phar|PHP License" + CHECK_RESULT $? + php -l ../common/my_script.php | grep "No syntax errors detected in.*" + CHECK_RESULT $? + php -l ../common/test.php | grep "No syntax errors detected in.*" + CHECK_RESULT $? + php -m | grep -E "\[PHP Modules\]|\[Zend Modules\]" + CHECK_RESULT $? + php -r '$foo = get_defined_constants(); var_dump($foo);' | grep -E "=>|int" + CHECK_RESULT $? + find ../common/my_script.php | php -B '$l=0;' -R '$l += count(@file($argn));' -E 'echo "Total Lines: $l\n";' | grep "Total Lines: 8" + CHECK_RESULT $? + find ../common/test.php | php -B '$l=0;' -R '$l += count(@file($argn));' -E 'echo "Total Lines: $l\n";' | grep "Total Lines: 95" + CHECK_RESULT $? + expect <Hello World

'; ?>" + CHECK_RESULT $? + php --ini | grep "ini" + CHECK_RESULT $? + php --rf ini_get | grep "function ini_get" + CHECK_RESULT $? + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ diff --git a/testcases/cli-test/php/oe_test_phpdbg/oe_test_phpdbg.sh b/testcases/cli-test/php/oe_test_phpdbg/oe_test_phpdbg.sh new file mode 100644 index 0000000..6af746c --- /dev/null +++ b/testcases/cli-test/php/oe_test_phpdbg/oe_test_phpdbg.sh @@ -0,0 +1,77 @@ +#!/usr/bin/bash + +# Copyright (c) 2020. Huawei Technologies Co.,Ltd.ALL rights reserved. +# This program is licensed under Mulan PSL v2. +# You can use it according to the terms and conditions of the Mulan PSL v2. +# http://license.coscl.org.cn/MulanPSL2 +# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, +# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, +# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. + +# ############################################# +# @Author : liujuan +# @Contact : lchutian@163.com +# @Date : 2020/10/20 +# @License : Mulan PSL v2 +# @Desc : verify the uasge of php-dbg command +# ############################################ + +source "$OET_PATH/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL php-dbg + LOG_INFO "Finish preparing the test environment." +} + +function run_test() { + LOG_INFO "Start to run test." + expect < " {send "list\r"} + expect "prompt> " {send "info\r"} + expect "prompt> " {send "print\r"} + expect "prompt> " {send "frame\r"} + expect "prompt> " {send "generator\r"} + expect "prompt> " {send "back\r"} + expect "prompt> " {send "help\r"} + expect "" {send "q\r"} + expect "prompt> " {send "exec\r"} + expect "prompt> " {send "stdin\r"} + expect "prompt> " {send "run\r"} + expect "prompt> " {send "step\r"} + expect "prompt> " {send "continue\r"} + expect "prompt> " {send "until\r"} + expect "prompt> " {send "next\r"} + expect "prompt> " {send "finish\r"} + expect "prompt> " {send "leave\r"} + expect "prompt> " {send "break\r"} + expect "prompt> " {send "watch\r"} + expect "prompt> " {send "clear\r"} + expect "prompt> " {send "clean\r"} + expect "prompt> " {send "set\r"} + expect "prompt> " {send "source\r"} + expect "prompt> " {send "register\r"} + expect "prompt> " {send "sh\r"} + expect "prompt> " {send "ev\r"} + expect "prompt> " {send "quit\r"} + expect eof +EOF + LOG_INFO "End of the test." +} + +function post_test() { + LOG_INFO "Start to restore the test environment." + DNF_REMOVE + LOG_INFO "Finish restoring the test environment." +} + +main $@ -- Gitee