#!/bin/sh # # Author : jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU General Public License for more details. # # Test echo command with some basic options. #
echo_test() { local echo_opt=$1 local echo_content=$2
local echo_cmd="echo $echo_opt$echo_content"
$echo_cmd > temp 2>&1 if [ $? -ne 0 ]; then grep -q -E "unknown option|invalid option" temp if [ $? -eq 0 ]; then tst_res TCONF "$echo_cmd not supported." else tst_res TFAIL "$echo_cmd failed." fi return fi
line=`wc -l temp | awk '{print $1}'`
if [ -z $echo_opt ];then if [ $line -ne 1 ];then tst_res TFAIL "$echo_cmd failed." return fi else if [ $echo_opt = "-e" ];then if [ $line -ne 2 ];then tst_res TFAIL "$echo_cmd failed." return fi fi fi
tst_res TPASS "echo passed with $echo_opt option." }
# # copyright_author: jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #
#!/bin/sh # # Author : jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU General Public License for more details. # # Test rm command with some basic options.
setup() { ROD touch "demoFile" ROD mkdir "demoDir" }
rm_test() { local rm_opt=$1 local rm_file=$2
local rm_cmd="rm $rm_opt$rm_file"
eval$rm_cmd > temp 2>&1 if [ $? -ne 0 ]; then grep -q -E "unknown option|invalid option" temp if [ $? -eq 0 ]; then tst_res TCONF "$rm_cmd not supported." else tst_res TFAIL "$rm_cmd failed." fi return fi
if [ -z $rm_opt ];then if [ -f $rm_file ];then tst_res TFAIL "$rm_cmd failed." return fi else if [ $rm_opt = "-r" ];then if [ -d $rm_file ];then tst_res TFAIL "$rm_cmd failed." return fi fi fi
# # Author : jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #
#!/bin/sh # # Author : jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU General Public License for more details. # # Test unlink command with some basic options. #
# # Author : jitwxs <jitwxs@foxmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. #
我已经将 Linux 内核中的 linux 文件夹拷贝到了 home 目录下,执行 checkpatch 脚本:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[wxs@bogon ltp]$ ../linux/scripts/checkpatch.pl 0001-commands-echo-Add-new-testcase-to-test-echo-1.patch WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17: new file mode 100644
total: 0 errors, 1 warnings, 95 lines checked
NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace.
0001-commands-echo-Add-new-testcase-to-test-echo-1.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
[wxs@bogon ltp]$ ../linux/scripts/checkpatch.pl 0002-commands-rm-Add-new-testcase-to-test-rm-1.patch WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17: new file mode 100644
[wxs@bogon ltp]$ git add runtest/commands [wxs@bogon ltp]$ git add testcases/commands/rm/ [wxs@bogon ltp]$ git commit -s -m "commands/rm:Add new testcase to test rm(1)" [mybranch f670ce7] commands/rm:Add new testcase to test rm(1) 3 files changed, 98 insertions(+) create mode 100644 testcases/commands/rm/Makefile create mode 100644 testcases/commands/rm/rm_tests.sh [wxs@bogon ltp]$ git format-patch -2 0001-commands-echo-Add-new-testcase-to-test-echo-1.patch 0002-commands-rm-Add-new-testcase-to-test-rm-1.patch
重新 checkpatch 检测:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
[wxs@bogon ltp]$ ../linux/scripts/checkpatch.pl 0002-commands-rm-Add-new-testcase-to-test-rm-1.patch WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17: new file mode 100644
total: 0 errors, 1 warnings, 98 lines checked
NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace.
0002-commands-rm-Add-new-testcase-to-test-rm-1.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
[wxs@bogon ltp]$ ../linux/scripts/checkpatch.pl 0003-commands-unlink-Add-new-testcase-to-test-unlink-1.patch WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #17: new file mode 100644
total: 0 errors, 1 warnings, 90 lines checked
NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace.
0003-commands-unlink-Add-new-testcase-to-test-unlink-1.patch has style problems, please review.
NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.