start:rflash_option_c_without_specify_noderange
description: basic usage check for option c. if without specify noderange for rflash command, should offer usage message
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -c
check:output=~Usage:
cmd:rflash -c 1.tar
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid nodes and/or groups in noderange
end

start:rflash_option_l_without_specify_noderange
description: basic usage check for option l. if without specify noderange for rflash command, should offer usage message
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -l
check:output=~Usage:
end

start:rflash_option_a_without_specify_noderange
description: basic usage check for option a. if without specify noderange for rflash command, should offer usage message
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -a
check:output=~Usage:
cmd:rflash -a 1.tar
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid nodes and/or groups in noderange
cmd:rflash -a 123abc
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid nodes and/or groups in noderange
end

start:rflash_option_u_without_specify_noderange
description: basic usage check for option u. if without specify noderange for rflash command, should offer usage message
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -u
check:output=~Usage:
cmd:rflash -u  1.tar
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid nodes and/or groups in noderange
end

start:rflash_option_d_without_specify_noderange
description: basic usage check for option d. if without specify noderange for rflash command, should offer usage message
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -d
check:output=~Usage:
cmd:rflash -d /1234
check:output=~Usage:
cmd:rflash --delete 1234abc
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid nodes and/or groups in noderange
end

start:rflash_without_option
description: basic usage check, if without option, should throw out a error
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN 1.tar
check:rc != 0
check:output=~Error: (\[.*?\]: )?Invalid option specified when a file is provided:
end

start:rflash_unsupport_multiple_option_a_u
description: basic usage check. If specify multiple options a+u, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a 1.tz -u
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_a_c
description: basic usage check. If specify multiple options a+c, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a 1.tz -c
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_a_l
description: basic usage check. If specify multiple options a+l, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a 1.tz -l
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_a_d
description: basic usage check. If specify multiple options a+d, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a 1.tz -d
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_c_l
description: basic usage check. If specify multiple options c+l, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c 1.tz -l
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_c_u
description: basic usage check. If specify multiple options c+u, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c 1.tz -u
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_c_d
description: basic usage check. If specify multiple options c+d, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c 1.tz -d
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_l_d
description: basic usage check. If specify multiple options l+d, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -l -d
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_l_u
description: basic usage check. If specify multiple options l+u, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -l -u
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_unsupport_multiple_option_u_d
description: basic usage check. If specify multiple options u+d, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -u -d
check:output=~Error: (\[.*?\]: )?Multiple options are not supported
check:rc != 0
end

start:rflash_option_c_file_not_exist
description: basic usage check for option c. if the file does not exist, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c /tmp/abc123.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN -c /tmp/
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN /tmp/abc123.tz -c
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN /tmp/ -c
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN  1.tar -c
check:output=~Error: (\[.*?\]: )?Cannot access
check:rc != 0
cmd:rflash $$CN -c /tmp/1.tar
check:output=~Error: (\[.*?\]: )?Cannot access
check:rc != 0
end

start:rflash_option_c_with_multiple_values
description: basic usage check for option c. if there are multiple value assigned to c option,  should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c /tmp/abc123.tz /tmp/abc124.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN -c  1.tz 2.tz 3.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN 1.tz 2.tz 3.tz -c
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
cmd:rflash $$CN 1.tz -c 2.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:rc != 0
end

start:rflash_option_c_against_node
description:  Make sure the -c option against node works
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -c |tee /tmp/rflash_option_c.output
check:rc == 0
cmd:grep -i ibm /tmp/rflash_option_c.output |grep -i 'HOST Firmware Product' | grep -i 'Active)\*' | wc -l
check:rc==0
check:output=~1
cmd:grep -i ibm /tmp/rflash_option_c.output |grep -i 'BMC Firmware Product' | grep -i 'Active)\*' | wc -l
check:rc==0
check:output=~1
cmd:rm -rf /tmp/rflash_option_c.output
check:rc==0
end

start:rflash_option_check_with_V_against_node
description:  Make sure the --check option with V works
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN --check -V |tee /tmp/rflash_option_check_with_V.output
check:rc == 0
cmd:grep -i ibm /tmp/rflash_option_check_with_V.output |grep -i 'HOST Firmware Product' | grep -i 'Active)\*' | wc -l
check:rc==0
check:output=~1
cmd:grep -i ibm /tmp/rflash_option_check_with_V.output |grep -i 'BMC Firmware Product' | grep -i 'Active)\*' | wc -l
check:rc==0
check:output=~1
cmd:rm -rf /tmp/rflash_option_check_with_V.output
check:rc==0
end


start:rflash_option_l_with_value
description: basic usage check for option l. if there is value for l option,  should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -l /tmp/abc123.tz
check:output=~Error: (\[.*?\]: )?Invalid option
check:rc != 0
cmd: rflash $$CN /tmp/abc123.tz -l
check:output=~Error: (\[.*?\]: )?Invalid option
check:rc != 0
end

start:rflash_option_l
description:  Make sure the -l option works
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -l |tee /tmp/rflash_option_l.output
check:rc == 0
cmd:grep -i ' bmc ' /tmp/rflash_option_l.output | grep -i 'Active(\*)' | wc -l
check:rc==0
check:output=~1
cmd:grep -i ' host ' /tmp/rflash_option_l.output | grep -i 'Active(\*)' | wc -l
check:rc==0
check:output=~1
cmd:rm -rf /tmp/rflash_option_l.output
check:rc==0
end


start:rflash_option_u_file_not_exist
description: basic usage check for option u. if the file does not exist, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -u /tmp/abc123.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -u /tmp/
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /tmp/abc123.tz -u
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /tmp/ -u
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tar -u
check:output=~Error: (\[.*?\]: )?Cannot access
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -u /tmp/1.tar
check:output=~Error: (\[.*?\]: )?Cannot access
check:output!~Attempting to
check:rc != 0
end

start:rflash_option_u_with_multiple_values
description: basic usage check for option u. if there are multiple value assigned to u option,  should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -u /tmp/abc123.tz /tmp/abc124.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -u 1.tz 2.tz 3.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tz 2.tz 3.tz -u
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tz -u 2.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
end

start:rflash_option_a_file_not_exist
description: basic usage check for option a. if the file does not exist, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a /tmp/abc123.tz
check:output=~rror: Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -a /tmp/
check:output=~rror: Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /tmp/abc123.tz -a
check:output=~rror: Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /tmp/ -a
check:output=~rror: Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tar -a
check:output=~Error: (\[.*?\]: )?Cannot access
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -a /tmp/1.tar
check:output=~Error: (\[.*?\]: )?Cannot access
check:output!~Attempting to
check:rc != 0
end

start:rflash_option_a_with_multiple_values
description: basic usage check for option a. if there are multiple value assigned to a option, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a /tmp/abc123.tz /tmp/abc124.tz
check:output=~Error: (\[.*?\]: )?Invalid firmware specified with
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -a 1.tz 2.tz 3.tz
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tz 2.tz 3.tz -a
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1.tz -a 2.tz
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN 1234567 -a 2345678
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN -a 123 abc asdbas
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to
check:rc != 0
end


start:rflash_option_a_with_non_existent_id
description: basic usage check for option a. if active a non-existent firmware ID, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -a 1234567
check:output=~Error: (\[.*?\]: )?Invalid ID provided to activate
check:rc != 0
cmd:rflash $$CN -a d123abc
check:output=~Error: (\[.*?\]: )?Invalid ID provided to activate
check:rc != 0
end

start:rflash_option_delete_with_multiple_values
description: basic usage check for option delete. if there are multiple value assigned to delete option, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN --delete 1234567 2345678
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to delete
check:rc != 0
cmd:rflash $$CN 1234567 2345678 --delete
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to delete
check:rc != 0
cmd:rflash $$CN 1234567 --delete 2345678
check:output=~Error: (\[.*?\]: )?More than one firmware specified is not supported
check:output!~Attempting to delete
check:rc != 0
end

start:rflash_option_delete_with_non_existent_id
description: basic usage check for option --delete. if delete a non-existent firmware ID, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN --delete 1234567
check:output=~Error: (\[.*?\]: )?Invalid ID provided to delete
check:rc != 0
cmd:rflash $$CN --delete d123abc
check:output=~Error: (\[.*?\]: )?Invalid ID provided to delete
check:rc != 0
end

start:rflash_option_d_with_multiple_values
description: basic usage check for option d. if there are multiple value assigned to d option, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rflash $$CN -d /123/   /234/
check:output=~Error: (\[.*?\]: )?More than one
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /123/   /234/  -d
check:output=~Error: (\[.*?\]: )?More than one
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /123/ -d /234/
check:output=~Error: (\[.*?\]: )?More than one
check:output!~Attempting to
check:rc != 0
end


start:rflash_option_d_with_non_existent_dir
description: basic usage check for option -d. if try to oprate non-existent dir by d option, should throw out error message
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:rm -rf /tmp/bogus123
check:rc == 0
cmd:rflash $$CN -d /tmp/bogus123
check:output=~Error: (\[.*?\]: )?Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:rflash $$CN /tmp/bogus123
check:output=~Error: (\[.*?\]: )?Invalid option specified
check:rc != 0
cmd:mkdir -p /tmp/bogus123
check:rc == 0
cmd:rflash $$CN /tmp/bogus123 -d
check:output =~Error: (\[.*?\]: )?No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:touch /tmp/bogus123/obmc-phosphor-image-witherspoon.ubi.mtd.tar
check:rc == 0
cmd:rflash $$CN -d /tmp/bogus123
check:output =~Error: (\[.*?\]: )?No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:touch /tmp/bogus123/witherspoon.pnor.squashfs.tar
check:rc == 0
cmd:rflash $$CN -d /tmp/bogus123
check:output =~Error: (\[.*?\]: )?No BMC tar file found|Can't open directory
check:output!~Attempting to
check:rc != 0
cmd:rm -rf /tmp/bogus123
check:rc == 0
end

start:rflash_usage
description:checke the usage of rflash for openbmc
os:Linux
hcp:openbmc
label:mn_only,hctrl_openbmc
cmd:rflash -h
check:output =~Usage:
check:output =~OpenPOWER OpenBMC specific:
check:output =~ -d.+no-host-reboot
check:output =~ image_id.+--delete
check:rc == 0
end

start:rflash_delete_no_active
description:this case is to check if --delete is not allowed to be used for the active state firmware. This case is for issue 4770.
os:Linux
hcp:openbmc
label:cn_bmc_ready,hctrl_openbmc
cmd:activenum=`rflash $$CN -l |grep -w "Host\s*Active(\*)" |awk '{print $2}'`;rflash $$CN $activenum --delete
check:rc != 0
check:output =~$$CN\s*:\s*(\[.*?\]: )?Error: Deleting currently active firmware on powered on host is not supported
cmd:activenum=`rflash $$CN -l |grep -w "BMC\s*Active(\*)" |awk '{print $2}'`;rflash $$CN $activenum --delete
check:rc != 0
check:output =~~$$CN\s*:\s*(\[.*?\]: )?Error: Deleting currently active BMC firmware is not supported
end

