diff --git a/suite2cases/CreateImage b/suite2cases/CreateImage new file mode 100644 index 0000000000000000000000000000000000000000..f1fbb2b4be515960355e0a32628283a33cac743b --- /dev/null +++ b/suite2cases/CreateImage @@ -0,0 +1 @@ +oe_test_CreateImage diff --git a/suite2cases/bcrypt b/suite2cases/bcrypt new file mode 100644 index 0000000000000000000000000000000000000000..66db6332cdbc33952ef2ff914a56c89ce0385c04 --- /dev/null +++ b/suite2cases/bcrypt @@ -0,0 +1 @@ +oe_test_bcrypt diff --git a/suite2cases/cmake b/suite2cases/cmake new file mode 100644 index 0000000000000000000000000000000000000000..337ac47b2bb103f83830c0d17e00170f866f5056 --- /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 0000000000000000000000000000000000000000..704a074f5bd7a8226b75f644eabd0275ea00834b --- /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 0000000000000000000000000000000000000000..de4f51e3d142984b42febd7f8d1afcf6ea0a08aa --- /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 0000000000000000000000000000000000000000..2688bab2494da7bf4f720e0f320a42d9e2b88821 --- /dev/null +++ b/suite2cases/jq @@ -0,0 +1 @@ +oe_test_jq diff --git a/suite2cases/kmod b/suite2cases/kmod new file mode 100644 index 0000000000000000000000000000000000000000..631905feeb83974f73a1c2bf4b0bf79ae945f13e --- /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 0000000000000000000000000000000000000000..a7ef44a041351f091f2c51c8a565c16a86ed9e7b --- /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 0000000000000000000000000000000000000000..573fc20bdcdab7bb3f3c8d301064fbc88fbc6357 --- /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 0000000000000000000000000000000000000000..d3a8d01c3bfd6219b4dcfccd912ab4bc7197a614 --- /dev/null +++ b/suite2cases/mutt @@ -0,0 +1 @@ +oe_test_mutt diff --git a/suite2cases/openvpn b/suite2cases/openvpn new file mode 100644 index 0000000000000000000000000000000000000000..1839372035bdbc6a69c3b53f8a3f4e8106495e18 --- /dev/null +++ b/suite2cases/openvpn @@ -0,0 +1 @@ +oe_test_openvpn diff --git a/suite2cases/php b/suite2cases/php new file mode 100644 index 0000000000000000000000000000000000000000..8b920255b7f7980af36ee40758a5a1c3feb63466 --- /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 0000000000000000000000000000000000000000..6a492330557830b18994d5acf21be6c91fd0f704 --- /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 0000000000000000000000000000000000000000..63c66825b42e0afe27feb9bb4b6cf2b88f76e34f --- /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 0000000000000000000000000000000000000000..f3b620ced9a1d6fcb7e8a51fb110b826a4e8c34f --- /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 0000000000000000000000000000000000000000..c535b22a18422e96575db213c0c4f5ff632e0a8e --- /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 0000000000000000000000000000000000000000..40d879fa55607294eeba8b6d9a13fa535838dc42 --- /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 0000000000000000000000000000000000000000..7365c916be7e90568593a2bb11d470b0aeda12ae --- /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 0000000000000000000000000000000000000000..5ec9987dba44dc43cb380e612946d942c12169c6 --- /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 0000000000000000000000000000000000000000..c9e2e50223a31f8df62c0ec0ef2366ce5071b67c --- /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 0000000000000000000000000000000000000000..7f72bdb2ec4283a65416cf358b131faa8553b5f6 --- /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 0000000000000000000000000000000000000000..5ec9987dba44dc43cb380e612946d942c12169c6 --- /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 0000000000000000000000000000000000000000..c9e2e50223a31f8df62c0ec0ef2366ce5071b67c --- /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 0000000000000000000000000000000000000000..4fa33e0a46be5384e3f91cb3806afa354d136301 --- /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 0000000000000000000000000000000000000000..1a21ab3a610ae17bcc3abde9a8c3786e09a45b4c --- /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 0000000000000000000000000000000000000000..b41666cf01af43aa962f2947bed4511d14c46d09 --- /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 0000000000000000000000000000000000000000..c8945a5d85d226924ccd07dec21c047f39b6af66 --- /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 0000000000000000000000000000000000000000..1a21ab3a610ae17bcc3abde9a8c3786e09a45b4c --- /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 0000000000000000000000000000000000000000..3c1d622bbc673cc9308cb02c7cb7bae176d016b6 --- /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 0000000000000000000000000000000000000000..c8945a5d85d226924ccd07dec21c047f39b6af66 --- /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 0000000000000000000000000000000000000000..652107a8015e89db6dbe3746eba1c0cec8974777 --- /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 0000000000000000000000000000000000000000..2c1f8e2aa992542a50b521264905640dda6e1373 --- /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 0000000000000000000000000000000000000000..652107a8015e89db6dbe3746eba1c0cec8974777 --- /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 0000000000000000000000000000000000000000..c9e2e50223a31f8df62c0ec0ef2366ce5071b67c --- /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 0000000000000000000000000000000000000000..eed3e0b01e7ad1ef99243499ebd7ff0323341b13 --- /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 0000000000000000000000000000000000000000..c8945a5d85d226924ccd07dec21c047f39b6af66 --- /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 0000000000000000000000000000000000000000..1cb98b19c7fe5aee65c4a791f91952acd751f087 --- /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 0000000000000000000000000000000000000000..5d2127bc773337c92c2a06f96ee45999fcab5925 --- /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 0000000000000000000000000000000000000000..3238654757ae294047ab2b6b0ae8609f52d6a3ee --- /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 0000000000000000000000000000000000000000..b1bfbff0383b84a2c4902abf81fa23c5c0e8f3ba --- /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 0000000000000000000000000000000000000000..286b5e91af998fb5033a81c0d93803bbe4834b0d --- /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 0000000000000000000000000000000000000000..cba841086020fe942185dcf4473f10fde76558de --- /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 0000000000000000000000000000000000000000..b2d91e783e768ae2eb56bb30f86a01ec3c4ce037 --- /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 0000000000000000000000000000000000000000..b77b76e204f5c16ba116e26cbf6abb3560c5d1eb --- /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 0000000000000000000000000000000000000000..9d23697cb0b0d3ddf699940abb595e850373a5a7 --- /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 0000000000000000000000000000000000000000..0cc25973f6c01bf5d2c23aa50eab6abd5ad6d29f --- /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 0000000000000000000000000000000000000000..55a544c50db5b614dccac22b928d84f6d5785590 --- /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 0000000000000000000000000000000000000000..d3169b7b490fedf645ceb03d165124ffe6710c36 --- /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 0000000000000000000000000000000000000000..c9dae2614bad9282f6409e004f7d140a6fb5edb1 --- /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 0000000000000000000000000000000000000000..41d38f47962873b4fbe526f716feb4f2a2560fbf --- /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 0000000000000000000000000000000000000000..8add4a31a59e755a77e2bb38c5a3b3674f908418 --- /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 0000000000000000000000000000000000000000..40c18319137b86d7ce4115e9301ba618bfa30cf8 --- /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 0000000000000000000000000000000000000000..bd9879a37614dcbcbc3a6868112457fd160db31b --- /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 0000000000000000000000000000000000000000..32bcfbdac04f8a12b519baad0152942146bb1dd6 --- /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 0000000000000000000000000000000000000000..9fba0354a5bc0745159a5d512513fa00d4498dd1 --- /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 0000000000000000000000000000000000000000..0343dae2e237e3887658f9bb81bc3650ac7f8832 --- /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 0000000000000000000000000000000000000000..c4b345263869705b5f0a90e922c99480c60b4e5c --- /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 0000000000000000000000000000000000000000..49cff5b195839faf794b4dabf5cfcff86cbef9e2 --- /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 0000000000000000000000000000000000000000..8a6b2a82661286df506a05564358e38f2aabfbd9 --- /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 0000000000000000000000000000000000000000..d06a537333fd7d493f021b79c70d933292c10cd3 --- /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 0000000000000000000000000000000000000000..f42d9671176cbafe2f8eaa45eb79e3e3548e577a --- /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 0000000000000000000000000000000000000000..4c9f0cba07d1d575fe912e7bef7bd42b1a5840a3 --- /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 0000000000000000000000000000000000000000..c512f678990caff45394a0f0e1b857168c7b6c87 --- /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 0000000000000000000000000000000000000000..bb09faf4e9d7df97759a6c712e5b62b65b7c9fe5 --- /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 0000000000000000000000000000000000000000..4cc401ae2cb8c16c37ef550fc4e2fa34b6552dd2 --- /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 0000000000000000000000000000000000000000..a69ac148a736d8281ce82f17ac3a380a1d52fad0 --- /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 0000000000000000000000000000000000000000..ecf33ea3c38d9c4d10346a47229da48507a68573 --- /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 0000000000000000000000000000000000000000..3b997725b25e5568bc2f083eb104e33c42f2b2de --- /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 0000000000000000000000000000000000000000..d20262ad8fd556744f9b2e9f4bf961cdf2bace93 --- /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 0000000000000000000000000000000000000000..fb84b187cd6837acdba79be4950c319c3d09da54 --- /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 0000000000000000000000000000000000000000..6af746c6382644ad7fb7fa287151a8cbfa1ce2c7 --- /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 $@