From 21c6c3a907f809561d6fd238546fd6baf50c4c75 Mon Sep 17 00:00:00 2001 From: Weihua Hu Date: Thu, 24 May 2018 16:15:45 +0800 Subject: [PATCH] Add one test case for xcat-inventory export option -f (#5244) --- .../testcase/xcat-inventory/cases.common | 48 ++++++++++++++++--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/xCAT-test/autotest/testcase/xcat-inventory/cases.common b/xCAT-test/autotest/testcase/xcat-inventory/cases.common index 018d74d05..7340bb6eb 100644 --- a/xCAT-test/autotest/testcase/xcat-inventory/cases.common +++ b/xCAT-test/autotest/testcase/xcat-inventory/cases.common @@ -53,13 +53,47 @@ check:output!~Traceback (most recent call last): check:rc!=0 end -#start:xcat_inventory_export_option_f_invalid_file -#description:This case is used to test xcat-inventory export subcommand to handle invalid file for option f -#cmd:xcat-inventory export -f aaa -#check:output=~The specified path does not exist -#check:output !~Traceback -#check:rc!=0 -#end +start:xcat_inventory_export_option_f +description:This case is used to test xcat-inventory export subcommand to handle option f +cmd:dir="/tmp/xcat_inventory_export_option_f";echo ${dir}".old";if [ -d "${dir}" ];then mv ${dir} ${dir}".old"; fi; mkdir -p $dir +check:rc==0 +cmd:lsdef bogusnode > /dev/null 2>&1;if [[ $? -eq 0 ]]; then lsdef bogusnode -z >/tmp/xcat_inventory_export_option_f/bogusnode.stanza ;rmdef bogusnode;fi +check:rc==0 +cmd:mkdef -t node -o bogusnode groups=bogusgroup +check:rc==0 +cmd:xcat-inventory export --format=yaml -t node -o bogusnode | tee /tmp/xcat_inventory_export_option_f/export_yaml_without_f +check:rc==0 +cmd:xcat-inventory export --format=yaml -t node -o bogusnode -f /tmp/xcat_inventory_export_option_f/export_yaml_with_f +check:rc==0 +check:output !~Traceback +cmd:diff /tmp/xcat_inventory_export_option_f/export_yaml_without_f /tmp/xcat_inventory_export_option_f/export_yaml_with_f +check:rc==0 +cmd:xcat-inventory export -t node -o bogusnode | tee /tmp/xcat_inventory_export_option_f/export_json_without_f +check:rc==0 +cmd:xcat-inventory export -t node -o bogusnode --path /tmp/xcat_inventory_export_option_f/export_json_with_f +check:rc==0 +cmd:diff /tmp/xcat_inventory_export_option_f/export_json_without_f /tmp/xcat_inventory_export_option_f/export_json_with_f +check:rc==0 +cmd:xcat-inventory export -t node -o bogusnode -f +check:rc!=0 +check:output ~=usage +check:output ~= error: argument -f/--path: expected one argument +cmd:xcat-inventory export -t node -o bogusnode --path +check:rc!=0 +eck:output ~=usage +check:output ~= error: argument -f/--path: expected one argument +cmd:mkdir /tmp/xcat_inventory_export_option_f/testdir +check:rc==0 +cmd:xcat-inventory export -t node -o bogusnode -f /tmp/xcat_inventory_export_option_f/testdir +check:rc!=0 +check:output ~= Error: the specified file /tmp/xcat_inventory_export_option_f/testdir already exists, is not a file! +cmd:rmdef bogusnode +check:rc==0 +cmd:if [[ -e /tmp/xcat_inventory_export_option_f/bogusnode.stanza ]]; then cat /tmp/xcat_inventory_export_option_f/bogusnode.stanza | mkdef -z;fi +check:rc==0 +cmd:dir="/tmp/xcat_inventory_export_option_f"; rm -rf $dir; if [ -d ${dir}".old" ];then mv ${dir}".old" $dir; fi +check:rc==0 +end start:xcat_inventory_import_option_f_invalid_file description:This case is used to test xcat-inventory import subcommand to handle invalid file for option f