add rust&optipng cases

This commit is contained in:
suhangself
2021-10-26 14:30:06 +08:00
parent 9c0f3975c7
commit fcabc15cf0
23 changed files with 996 additions and 0 deletions

11
suite2cases/optipng.json Normal file
View File

@@ -0,0 +1,11 @@
{
"path": "$OET_PATH/testcases/cli-test/optipng",
"cases": [
{
"name": "oe_test_optipng_01"
},
{
"name": "oe_test_optipng_02"
}
]
}

23
suite2cases/rust.json Normal file
View File

@@ -0,0 +1,23 @@
{
"path": "$OET_PATH/testcases/cli-test/rust",
"cases": [
{
"name": "oe_test_rustc_01"
},
{
"name": "oe_test_rustc_02"
},
{
"name": "oe_test_rustc_03"
},
{
"name": "oe_test_rustdoc"
},
{
"name": "oe_test_cargo_01"
},
{
"name": "oe_test_cargo_02"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@@ -0,0 +1,102 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-08-09
# @License : Mulan PSL v2
# @Desc : Image compression tool optiPNG
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL optipng
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
optipng -help |grep "Synopsis"
CHECK_RESULT $? 0 0 "Help information printing failed"
optipng -v |grep -E "version"
CHECK_RESULT $? 0 0 "Version information printing failed"
cp ../common/ini.png test.png
CHECK_RESULT $?
optipng test.png -log test.log
CHECK_RESULT $?
ls |grep test.log
CHECK_RESULT $? 0 0 "Failed to output the log file"
cp ../common/ini.png test1.png
CHECK_RESULT $?
optipng -o1 test1.png -log test1.log
CHECK_RESULT $?
grep -i "output" test1.log
CHECK_RESULT $? 0 0 "Failed to set the level"
cp ../common/ini.png test2.png
CHECK_RESULT $?
optipng -backup test2.png
CHECK_RESULT $?
ls |grep test2.png.bak
CHECK_RESULT $? 0 0 "Failed to back up files"
optipng -clobber test2.png.bak -log test2a.log
CHECK_RESULT $?
grep -i "output" test2a.log
CHECK_RESULT $? 0 0 "Overwrite file failed"
cp ../common/ini.png test3.png
CHECK_RESULT $?
optipng test3.png
CHECK_RESULT $?
optipng -force test3.png -log test3.log
CHECK_RESULT $?
grep -i "output" test3.log
CHECK_RESULT $? 0 0 "Force run failure"
cp ../common/ini.png test4.png
CHECK_RESULT $?
optipng -preserve test4.png -log test4.log
CHECK_RESULT $?
grep -i "output" test4.log
CHECK_RESULT $? 0 0 "Failure to retain properties"
cp ../common/ini.png test5.png
CHECK_RESULT $?
optipng -quiet test5.png
CHECK_RESULT $? 0 0 "Silent run failure"
cp ../common/ini.png test6.png
CHECK_RESULT $?
optipng -simulate test6.png -log test6.log
CHECK_RESULT $?
grep -i "simulation mode" test6.log
CHECK_RESULT $? 0 0 "Simulation run failure"
cp ../common/ini.png test7.png
CHECK_RESULT $?
optipng test7.png -out test7.gif
CHECK_RESULT $?
ls |grep test7.gif
CHECK_RESULT $? 0 0 "Failed to output file"
cp ../common/ini.png test8.png
CHECK_RESULT $?
optipng test8.png -dir ./
CHECK_RESULT $?
ls |grep test8.png
CHECK_RESULT $? 0 0 "Failed to specify path"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,86 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-08-09
# @License : Mulan PSL v2
# @Desc : Image compression tool optiPNG
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL optipng
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
cp ../common/ini.png test9.png
CHECK_RESULT $?
optipng -f 2 test9.png -log test9.log
CHECK_RESULT $?
grep -i "f = 2" test9.log
CHECK_RESULT $? 0 0 "Filter failure"
cp ../common/ini.png test10.png
CHECK_RESULT $?
optipng -i 1 test10.png -log test10a.log
CHECK_RESULT $?
grep -i "output" test10a.log
CHECK_RESULT $? 0 0 "Interlaced scan failed"
optipng -i 0 test10.png -log test10b.log
CHECK_RESULT $?
grep -iE "output|interlaced" test10a.log
CHECK_RESULT $? 0 0 "Non-interlaced scan failed"
cp ../common/ini.png test11.png
CHECK_RESULT $?
optipng -zc 6 -zm 4 -zs 1 -zw 4k test11.png -log test11.log
CHECK_RESULT $?
grep -iE "output|zc = 6|zm = 4|zs = 1" test11.log
CHECK_RESULT $? 0 0 "Failed to set zlib"
cp ../common/ini.png test12.png
CHECK_RESULT $?
optipng -full test12.png -log test12.log
CHECK_RESULT $?
grep -iE "output|IDAT size" test12.log
CHECK_RESULT $? 0 0 "Report printing failed"
cp ../common/ini.png test13.png
CHECK_RESULT $?
optipng -nb -nc -np -nx test13.png -log test13.log
CHECK_RESULT $?
grep -i "output" test13.log
CHECK_RESULT $? 0 0 "Failed to set nb or nc or np or nx"
cp ../common/ini.png test14.png
CHECK_RESULT $?
optipng -nz test14.png -log test14.log
CHECK_RESULT $?
grep -i "trying" test14.log
CHECK_RESULT $? 1 0 "Failed to set nz"
cp ../common/ini.png test15.png
CHECK_RESULT $?
optipng -strip all test15.png -log test15.log
CHECK_RESULT $?
grep -iE "output|Stripping metadata" test15.log
CHECK_RESULT $? 0 0 "Failed to delete metadata"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,5 @@
fn main() {
if cfg!(hello) {
println!("world!");
}
}

View File

@@ -0,0 +1 @@
pub fn foo() {}

View File

@@ -0,0 +1,4 @@
extern crate myhello;
fn main() {
myhello::print_hello();
}

View File

@@ -0,0 +1,3 @@
pub fn print_hello() {
println!("Hello World!");
}

View File

@@ -0,0 +1,3 @@
pub fn main() {
println!("hello world!");
}

View File

@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}

View File

@@ -0,0 +1,3 @@
fn main() {
100u8 << 10;
}

View File

@@ -0,0 +1,61 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-18
# @License : Mulan PSL v2
# @Desc : Rust language tools cargo
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL cargo
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
cargo -h | grep "USAGE"
CHECK_RESULT $? 0 0 "Help information printing failed"
cargo -V |grep "cargo"
CHECK_RESULT $? 0 0 "Failed to output the version information"
cargo --list |grep "Installed Commands"
CHECK_RESULT $? 0 0 "Failed to list commands"
cargo --explain E0004 |grep -i "Erroneous code example"
CHECK_RESULT $? 0 0 "Failed to interpret code command"
cargo -vV | grep "release"
CHECK_RESULT $? 0 0 "Failed to list details"
cargo new hello -q
CHECK_RESULT $?
cd hello && cargo run --color always
CHECK_RESULT $?
cargo run --offline |grep "Hello, world!"
CHECK_RESULT $? 0 0 "Failed to run offline"
cargo -Z help |grep "Available unstable (nightly-only) flags"
CHECK_RESULT $?
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
cd ../ && rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,71 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-18
# @License : Mulan PSL v2
# @Desc : Rust language tools cargo
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL cargo
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
cargo new hello_world
CHECK_RESULT $?
ls |grep "hello_world"
CHECK_RESULT $? 0 0 "Failed to create a new package"
cd hello_world && cargo build
CHECK_RESULT $?
./target/debug/hello_world |grep "Hello, world!"
CHECK_RESULT $? 0 0 "Failed to compile package"
cargo run |grep "Hello, world!"
CHECK_RESULT $? 0 0 "Failed to run package"
cargo test |grep -E "running|test result"
CHECK_RESULT $? 0 0 "Failed to execute tests"
cargo bench |grep -E "running|test result"
CHECK_RESULT $?0 0 "Failed to execute the benchmark"
cargo check
CHECK_RESULT $? 0 0 "Failure check kit"
cargo doc && ls target/ |grep "doc"
CHECK_RESULT $? 0 0 "Failed to build the package document"
ls |grep "target"
CHECK_RESULT $?
cargo clean |grep "target"
CHECK_RESULT $? 1 0 "Failed to delete a file"
mkdir INI && cd INI
CHECK_RESULT $?
cargo init && ls |grep "src"
CHECK_RESULT $? 0 0 "Failed to create a new package"
cargo update && ls |grep "Cargo.lock"
CHECK_RESULT $? 0 0 "Failed to update file"
cargo search && cargo search serde |grep "serde"
CHECK_RESULT $? 0 0 "Failed to search for serde package"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
cd ../ && rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,51 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-20
# @License : Mulan PSL v2
# @Desc : Rust language tools clippy
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL clippy
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
cargo-clippy -h |grep "Usage"
CHECK_RESULT $? 0 0 "Help information printing failed"
cargo-clippy -V |grep "clippy"
CHECK_RESULT $? 0 0 "Failed to output the version information"
clippy-driver -h |grep "Usage"
CHECK_RESULT $? 0 0 "Help information printing failed"
clippy-driver -V |grep "clippy"
CHECK_RESULT $? 0 0 "Failed to output the version information"
clippy-driver --rustc test.rs
CHECK_RESULT $?
./hello |grep "Hello, world!"
CHECK_RESULT $? 0 0 "Failed to pass parameters"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,43 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-20
# @License : Mulan PSL v2
# @Desc : Rust language tools rls
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rls
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
rls -h |grep "help"
CHECK_RESULT $? 0 0 "Help information printing failed"
rls -V |grep "rls"
CHECK_RESULT $? 0 0 "Failed to output the version information"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,44 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-20
# @License : Mulan PSL v2
# @Desc : Rust language tools rust-gdb
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust-gdb
DNF_INSTALL rust
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
rust-gdb -h |grep "Usage"
CHECK_RESULT $? 0 0 "Help information printing failed"
rust-gdb --version |grep "gdb"
CHECK_RESULT $? 0 0 "Failed to output the version information"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,44 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-20
# @License : Mulan PSL v2
# @Desc : Rust language tools rust-lldb
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust-lldb
DNF_INSTALL rust
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
rust-lldb -h |grep "USAGE"
CHECK_RESULT $? 0 0 "Help information printing failed"
rust-lldb -v |grep "version"
CHECK_RESULT $? 0 0 "Failed to output the version information"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,118 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-09-22
# @License : Mulan PSL v2
# @Desc : Image compression tool rustc
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust
cp ../common/hello.rs hello.rs
cp ../common/pub.rs pub.rs
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
rustc -h |grep -i "usage"
CHECK_RESULT $? 0 0 "Help information printing failed"
rustc --cfg hello hello.rs
CHECK_RESULT $?
ls |grep -w "hello"
CHECK_RESULT $?
./hello |grep "world!"
CHECK_RESULT $? 0 0 "Failed to print world"
rustc -L . hello.rs --crate-name hello1
CHECK_RESULT $?
ls |grep "hello1"
CHECK_RESULT $? 0 0 "Failed to output the hello1 file"
rustc --crate-type bin pub.rs
CHECK_RESULT $?
ls |grep "pub"
CHECK_RESULT $? 0 0 "Failed to output the pub file"
rustc --crate-type lib pub.rs --crate-name _lib
CHECK_RESULT $?
ls |grep "lib_lib.rlib"
CHECK_RESULT $? 0 0 "Failed to output the lib_lib.rlib file"
rustc --crate-type rlib pub.rs --crate-name _rlib
CHECK_RESULT $?
ls |grep "lib_rlib.rlib"
CHECK_RESULT $? 0 0 "Failed to output the lib_rlib.rlib file"
rustc --crate-type dylib pub.rs --crate-name _dy
CHECK_RESULT $?
ls |grep "lib_dy.so"
CHECK_RESULT $? 0 0 "Failed to output the lib_dy.so file"
rustc --crate-type cdylib pub.rs --crate-name _cdy
CHECK_RESULT $?
ls |grep "lib_cdy.so"
CHECK_RESULT $? 0 0 "Failed to output the lib_cdy.so file"
rustc --crate-type staticlib pub.rs
CHECK_RESULT $?
ls |grep "libpub.a"
CHECK_RESULT $? 0 0 "Failed to output the libpub.a file"
rustc pub.rs --crate-name craname
CHECK_RESULT $?
ls |grep "craname"
CHECK_RESULT $? 0 0 "Failed to output the craname file"
rustc --edition 2018 hello.rs --crate-name editname
CHECK_RESULT $?
ls |grep "editname"
CHECK_RESULT $? 0 0 "Failed to output the editname file"
rustc --emit asm hello.rs
CHECK_RESULT $?
ls |grep "hello.s"
CHECK_RESULT $? 0 0 "Failed to output the hello.s file"
rustc --emit llvm-bc hello.rs
CHECK_RESULT $?
ls |grep "hello.bc"
CHECK_RESULT $? 0 0 "Failed to output the hello.bc file"
rustc --emit llvm-ir hello.rs
CHECK_RESULT $?
ls |grep "hello.ll"
CHECK_RESULT $? 0 0 "Failed to output the hello.ll file"
rustc --emit obj hello.rs
CHECK_RESULT $?
ls |grep "hello.o"
CHECK_RESULT $? 0 0 "Failed to output the hello.o file"
rustc --emit metadata hello.rs
CHECK_RESULT $?
ls |grep "hello.rmeta"
CHECK_RESULT $? 0 0 "Failed to output the hello.rmeta file"
rustc --emit link hello.rs --crate-name linname
CHECK_RESULT $?
ls |grep "linname"
CHECK_RESULT $? 0 0 "Failed to output the linname file"
rustc --emit dep-info hello.rs
CHECK_RESULT $?
ls |grep "hello.d"
CHECK_RESULT $? 0 0 "Failed to output the hello.d file"
rustc --emit mir hello.rs
CHECK_RESULT $?
ls |grep "hello.mir"
CHECK_RESULT $? 0 0 "Failed to output the hello.mir file"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,98 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-09-22
# @License : Mulan PSL v2
# @Desc : Rust language tools rustc
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust
cp ../common/hello.rs hello.rs
cp ../common/lib.rs lib.rs
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
rustc --print crate-name hello.rs |grep "hello"
CHECK_RESULT $? 0 0 "Failed to output the hello file"
rustc --print file-names hello.rs |grep "hello"
CHECK_RESULT $? 0 0 "Failed to output the hello file"
rustc --print sysroot hello.rs |grep "/usr"
CHECK_RESULT $? 0 0 "Failed to output the sysroot information"
rustc --print target-libdir hello.rs |grep "/usr/lib/rustlib"
CHECK_RESULT $? 0 0 "Failed to output the target libdir"
rustc --print cfg hello.rs |grep -E "debug|target|unix"
CHECK_RESULT $? 0 0 "Failed to output the cfg information"
rustc --print target-list hello.rs |grep -E "*"
CHECK_RESULT $? 0 0 "Failed to output the target list"
rustc --print target-cpus hello.rs |grep -i "cpu"
CHECK_RESULT $? 0 0 "Failed to output the target cpus"
rustc --print target-features hello.rs |grep "features"
CHECK_RESULT $? 0 0 "Failed to output the target features"
rustc --print relocation-models hello.rs |grep "Available relocation models"
CHECK_RESULT $? 0 0 "Failed to output the relocation models"
rustc --print code-models hello.rs |grep "Available code models"
CHECK_RESULT $? 0 0 "Failed to output the code models"
rustc --print tls-models hello.rs |grep "Available TLS models"
CHECK_RESULT $? 0 0 "Failed to output the stls models"
rustc --print native-static-libs hello.rs --crate-name priname
CHECK_RESULT $?
ls |grep "priname"
CHECK_RESULT $? 0 0 "Failed to output the priname file"
rustc -g hello.rs -o hello_g
CHECK_RESULT $?
ls |grep "hello_g"
CHECK_RESULT $? 0 0 "Failed to output the hello_g file"
rustc -O hello.rs -o hello_O
CHECK_RESULT $?
ls |grep "hello_O"
CHECK_RESULT $? 0 0 "Failed to output the hello_O file"
rustc -o demo hello.rs
CHECK_RESULT $?
ls |grep "demo"
CHECK_RESULT $? 0 0 "Failed to output the demo file"
rustc --out-dir ./ hello.rs --crate-name dirname
CHECK_RESULT $?
ls |grep "dirname"
CHECK_RESULT $? 0 0 "Failed to output the dirname file"
rustc --explain E0426 |grep -i "Erroneous code example"
CHECK_RESULT $?
rustc --test hello.rs --crate-name testname
CHECK_RESULT $?
./testname |grep "running"
CHECK_RESULT $? 0 0 "Test tool build failed"
rustc lib.rs --crate-type=lib -W missing-docs >Wlog 2>&1
CHECK_RESULT $?
grep "warning" Wlog
CHECK_RESULT $? 0 0 "Failed to set Linter option Warn"
rustc lib.rs --crate-type=lib -A missing-docs -o hello_A
CHECK_RESULT $?
ls |grep "hello_A"
CHECK_RESULT $? 0 0 "Failed to set Linter option Allow"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,79 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-09-22
# @License : Mulan PSL v2
# @Desc : Rust language tools rustc
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust
cp ../common/lib.rs lib.rs
cp ../common/war.rs war.rs
cp ../common/hello.rs hello.rs
cp ../common/myhello.rs myhello.rs
cp ../common/main.rs main.rs
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
rustc lib.rs --crate-type=lib -D missing-docs >Dlog 2>&1
CHECK_RESULT $? 1
grep "error" Dlog
CHECK_RESULT $? 0 0 "Failed to set Linter option Deny"
rustc lib.rs --crate-type=lib -F missing-docs >Flog 2>&1
CHECK_RESULT $? 1
grep "error" Flog
CHECK_RESULT $? 0 0 "Failed to set Linter option Forbit"
rustc war.rs --cap-lints warn >caplog 2>&1
CHECK_RESULT $?
grep "warning" caplog
CHECK_RESULT $? 0 0 "Failed to set Linter level warning"
rustc -C opt-level=2 hello.rs -o hello_C
CHECK_RESULT $?
ls |grep "hello_C"
CHECK_RESULT $? 0 0 "Failed to output the hello_C file"
rustc -V |grep "rustc"
CHECK_RESULT $? 0 0 "Failed to output the version information"
rustc -v hello.rs -o hello_v
CHECK_RESULT $?
ls |grep "hello_v"
CHECK_RESULT $? 0 0 "Failed to output the hello_v file"
rustc -C help |grep "Available codegen options"
CHECK_RESULT $?
rustc -W help |grep "Available lint options"
CHECK_RESULT $?
rustc --crate-type staticlib myhello.rs
CHECK_RESULT $?
rustc --crate-type rlib myhello.rs
CHECK_RESULT $?
rustc -L. -l myhello main.rs
CHECK_RESULT $?
./main |grep "Hello World!"
CHECK_RESULT $? 0 0 "Link library failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,94 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-18
# @License : Mulan PSL v2
# @Desc : Rust language tools rustdoc
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rust
cp ../common/hello.rs hello.rs
cp ../common/test.rs test.rs
cp ../common/lib.rs lib.rs
cp ../common/war.rs war.rs
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start to run test."
rustdoc -h |grep -i "Options"
CHECK_RESULT $? 0 0 "Help information printing failed"
rustdoc -V |grep "rustdoc"
CHECK_RESULT $? 0 0 "Failed to output the version information"
rustdoc -v -V |grep -iE "binary|release|version"
CHECK_RESULT $?
rustdoc test.rs -o doc --crate-name mycrate
CHECK_RESULT $?
ls | grep "doc"
CHECK_RESULT $?
ls doc |grep "mycrate"
CHECK_RESULT $? 0 0 "Failed to specify the output path"
rustdoc test.rs -L doc/
CHECK_RESULT $?
rustdoc hello.rs --cfg hello
ls doc |grep "hello"
CHECK_RESULT $? 0 0 "Failed to pass configuration parameters"
rustdoc test.rs --extern doc/
CHECK_RESULT $?
rustdoc test.rs -C target_feature=+avx
CHECK_RESULT $?
rustdoc --document-private-items test.rs
CHECK_RESULT $?
rustdoc test.rs --test |grep -E "running|tests"
CHECK_RESULT $? 0 0 "Failed to run the test code"
rustdoc test.rs --html-in-header doc/hello/all.html
CHECK_RESULT $?
rustdoc test.rs --html-after-content doc/hello/all.html
CHECK_RESULT $?
rustdoc test.rs --html-after-content doc/hello/all.html
CHECK_RESULT $?
rustdoc test.rs --markdown-no-toc
CHECK_RESULT $?
rustdoc test.rs -e doc/dark.css
CHECK_RESULT $?
rustdoc lib.rs --crate-type=lib -W missing-docs >Wlog 2>&1
grep "warning" Wlog
CHECK_RESULT $? 0 0 "Failed to set Linter option Warn"
rustdoc lib.rs --crate-type=lib -A missing-docs -o hello_A
ls |grep "hello_A"
CHECK_RESULT $? 0 0 "Failed to set Linter option Allow"
rustdoc lib.rs --crate-type=lib -D missing-docs >Dlog 2>&1
grep "error" Dlog
CHECK_RESULT $? 0 0 "Failed to set Linter option Deny"
rustdoc lib.rs --crate-type=lib -F missing-docs >Flog 2>&1
grep "error" Flog
CHECK_RESULT $? 0 0 "Failed to set Linter option Forbit"
rustdoc war.rs --cap-lints warn
CHECK_RESULT $? 0 0 "Failed to set Linter level warning"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
rm -rf $(ls | grep -v ".sh")
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@

View File

@@ -0,0 +1,49 @@
#!/usr/bin/bash
# Copyright (c) 2021 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 : suhang
# @Contact : suhangself@163.com
# @Date : 2021-10-19
# @License : Mulan PSL v2
# @Desc : Rust language tools rustfmt
# ##############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function pre_test() {
LOG_INFO "Start to prepare the test environment!"
DNF_INSTALL rustfmt
LOG_INFO "End to prepare the test environment!"
}
function run_test() {
LOG_INFO "Start executing testcase!"
cargo-fmt -h | grep "USAGE"
CHECK_RESULT $? 0 0 "cargo-fmt Help information printing failed"
cargo-fmt --version |grep "rustfmt"
CHECK_RESULT $? 0 0 "Failed to output the version information of cargo-fmt"
cargo-fmt -v |grep "rustfmt"
CHECK_RESULT $? 0 0 "Failed to list details"
rustfmt -V |grep "rustfmt"
CHECK_RESULT $? 0 0 "Failed to output the version information of rustfmt"
rustfmt -h |grep "usage"
CHECK_RESULT $? 0 0 "rustfmt Help information printing failed"
LOG_INFO "End to run test."
}
function post_test() {
LOG_INFO "start environment cleanup."
DNF_REMOVE
LOG_INFO "Finish environment cleanup!"
}
main $@