diff mbox series

[2/2] live-image: add an option for creating oem-tests.lst

Message ID 20200205213447.18509-2-alex.hung@canonical.com
State Accepted
Headers show
Series None | expand

Commit Message

Alex Hung Feb. 5, 2020, 9:34 p.m. UTC
This allows users to create oem-tests.lst for automating
tests in fwts-live, and thus removes needs users to modify fwts-live
images or partitions manually.

Signed-off-by: Alex Hung <alex.hung@canonical.com>
---
 live-image/fwts-frontend-text | 74 +++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

Comments

Ivan Hu Feb. 24, 2020, 4:04 a.m. UTC | #1
On 2/6/20 5:34 AM, Alex Hung wrote:
> This allows users to create oem-tests.lst for automating
> tests in fwts-live, and thus removes needs users to modify fwts-live
> images or partitions manually.
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  live-image/fwts-frontend-text | 74 +++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/live-image/fwts-frontend-text b/live-image/fwts-frontend-text
> index 7b16b981..7fe4533f 100755
> --- a/live-image/fwts-frontend-text
> +++ b/live-image/fwts-frontend-text
> @@ -154,6 +154,76 @@ select_tests()
>  	done
>  }
>  
> +#
> +#  Get user choices to create oem-tests.lst
> +#
> +select_oem_automation()
> +{
> +	while true
> +	do
> +		declare -a tests
> +		x=0
> +		#
> +		#  Discover available tests
> +		#
> +		fwts --batch --batch-experimental --uefitests --unsafe --show-tests | grep "^ "| sort | uniq > $OPTIONS
> +		while read test text
> +		do
> +			((x++))
> +			tests[$x]=$test
> +			txt="${txt} ${x} \"${text}\" off"
> +		done < $OPTIONS
> +		rm $OPTIONS
> +
> +		#
> +		# Construct and run dialog
> +		#
> +		echo dialog --backtitle '"$FWTS"' --title '"Select Tests for Automation"' --help-button  --checklist '"Select from the list below the test(s) for oem-tests.lst. Use up/down cursor keys, space to select and enter to start:"' 20 70 $x $txt > $DIALOG_CMD
> +		. $DIALOG_CMD 2> $OPTIONS
> +		ret=$?
> +		rm $DIALOG_CMD
> +
> +		#
> +		# Scan return selections and build fwts test scenarios
> +		#
> +		x=0
> +		for i in `cat $OPTIONS`
> +		do
> +			((x++))
> +			i=${i#\"}
> +			i=${i%\"}
> +			run_tests="$run_tests ${tests[$i]}"
> +		done
> +
> +		#
> +		# Handle dialog exit states:
> +		#
> +		case $ret in
> +		0)
> +			if [ $x -eq 0 ]; then
> +				dialog --backtitle "$FWTS" --title "No Tests Selected!" --msgbox \
> +			"   You did not select any tests to be run." 5 50
> +			else
> +				# remove leading space and output to oem-tests.lst
> +				echo "TESTS=$(echo $run_tests)" > $OEM_TESTS_FILE
> +				echo "POST=poweroff" >> $OEM_TESTS_FILE
> +				dialog --backtitle "$FWTS" --title "Auto-tests Saved!" --msgbox \
> +					" Auto-tests are saved to $OEM_TESTS_FILE" 5 50
> +				finish
> +			fi
> +			;;
> +		1)
> +			return
> +			;;
> +		2)
> +			do_help
> +			;;
> +		255)
> +			no_tests_finish
> +			;;
> +		esac
> +	done
> +}
>  #
>  #  View the results log
>  #
> @@ -314,6 +384,7 @@ do
>  			"Recommended" "Recommended Tests" off \
>  			"Recommended for IFV" "Recommended Tests for F/W Vendors" off \
>  			"Selected" "Select Individual Tests" off \
> +			"Automated" "Create Auto-Tests" off \
>  			"Abort" "Abort Testing" off \
>  			2> $OPTIONS
>  			;;
> @@ -369,6 +440,9 @@ do
>  		'Selected')
>  			select_tests
>  			;;
> +		'Automated')
> +			select_oem_automation
> +			;;
>  		'Abort')
>  			no_tests_finish
>  			;;
> 


Acked-by: Ivan Hu <ivan.hu@canonical.com>
Colin Ian King Feb. 25, 2020, 8:28 a.m. UTC | #2
On 05/02/2020 21:34, Alex Hung wrote:
> This allows users to create oem-tests.lst for automating
> tests in fwts-live, and thus removes needs users to modify fwts-live
> images or partitions manually.
> 
> Signed-off-by: Alex Hung <alex.hung@canonical.com>
> ---
>  live-image/fwts-frontend-text | 74 +++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/live-image/fwts-frontend-text b/live-image/fwts-frontend-text
> index 7b16b981..7fe4533f 100755
> --- a/live-image/fwts-frontend-text
> +++ b/live-image/fwts-frontend-text
> @@ -154,6 +154,76 @@ select_tests()
>  	done
>  }
>  
> +#
> +#  Get user choices to create oem-tests.lst
> +#
> +select_oem_automation()
> +{
> +	while true
> +	do
> +		declare -a tests
> +		x=0
> +		#
> +		#  Discover available tests
> +		#
> +		fwts --batch --batch-experimental --uefitests --unsafe --show-tests | grep "^ "| sort | uniq > $OPTIONS
> +		while read test text
> +		do
> +			((x++))
> +			tests[$x]=$test
> +			txt="${txt} ${x} \"${text}\" off"
> +		done < $OPTIONS
> +		rm $OPTIONS
> +
> +		#
> +		# Construct and run dialog
> +		#
> +		echo dialog --backtitle '"$FWTS"' --title '"Select Tests for Automation"' --help-button  --checklist '"Select from the list below the test(s) for oem-tests.lst. Use up/down cursor keys, space to select and enter to start:"' 20 70 $x $txt > $DIALOG_CMD
> +		. $DIALOG_CMD 2> $OPTIONS
> +		ret=$?
> +		rm $DIALOG_CMD
> +
> +		#
> +		# Scan return selections and build fwts test scenarios
> +		#
> +		x=0
> +		for i in `cat $OPTIONS`
> +		do
> +			((x++))
> +			i=${i#\"}
> +			i=${i%\"}
> +			run_tests="$run_tests ${tests[$i]}"
> +		done
> +
> +		#
> +		# Handle dialog exit states:
> +		#
> +		case $ret in
> +		0)
> +			if [ $x -eq 0 ]; then
> +				dialog --backtitle "$FWTS" --title "No Tests Selected!" --msgbox \
> +			"   You did not select any tests to be run." 5 50
> +			else
> +				# remove leading space and output to oem-tests.lst
> +				echo "TESTS=$(echo $run_tests)" > $OEM_TESTS_FILE
> +				echo "POST=poweroff" >> $OEM_TESTS_FILE
> +				dialog --backtitle "$FWTS" --title "Auto-tests Saved!" --msgbox \
> +					" Auto-tests are saved to $OEM_TESTS_FILE" 5 50
> +				finish
> +			fi
> +			;;
> +		1)
> +			return
> +			;;
> +		2)
> +			do_help
> +			;;
> +		255)
> +			no_tests_finish
> +			;;
> +		esac
> +	done
> +}
>  #
>  #  View the results log
>  #
> @@ -314,6 +384,7 @@ do
>  			"Recommended" "Recommended Tests" off \
>  			"Recommended for IFV" "Recommended Tests for F/W Vendors" off \
>  			"Selected" "Select Individual Tests" off \
> +			"Automated" "Create Auto-Tests" off \
>  			"Abort" "Abort Testing" off \
>  			2> $OPTIONS
>  			;;
> @@ -369,6 +440,9 @@ do
>  		'Selected')
>  			select_tests
>  			;;
> +		'Automated')
> +			select_oem_automation
> +			;;
>  		'Abort')
>  			no_tests_finish
>  			;;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
diff mbox series

Patch

diff --git a/live-image/fwts-frontend-text b/live-image/fwts-frontend-text
index 7b16b981..7fe4533f 100755
--- a/live-image/fwts-frontend-text
+++ b/live-image/fwts-frontend-text
@@ -154,6 +154,76 @@  select_tests()
 	done
 }
 
+#
+#  Get user choices to create oem-tests.lst
+#
+select_oem_automation()
+{
+	while true
+	do
+		declare -a tests
+		x=0
+		#
+		#  Discover available tests
+		#
+		fwts --batch --batch-experimental --uefitests --unsafe --show-tests | grep "^ "| sort | uniq > $OPTIONS
+		while read test text
+		do
+			((x++))
+			tests[$x]=$test
+			txt="${txt} ${x} \"${text}\" off"
+		done < $OPTIONS
+		rm $OPTIONS
+
+		#
+		# Construct and run dialog
+		#
+		echo dialog --backtitle '"$FWTS"' --title '"Select Tests for Automation"' --help-button  --checklist '"Select from the list below the test(s) for oem-tests.lst. Use up/down cursor keys, space to select and enter to start:"' 20 70 $x $txt > $DIALOG_CMD
+		. $DIALOG_CMD 2> $OPTIONS
+		ret=$?
+		rm $DIALOG_CMD
+
+		#
+		# Scan return selections and build fwts test scenarios
+		#
+		x=0
+		for i in `cat $OPTIONS`
+		do
+			((x++))
+			i=${i#\"}
+			i=${i%\"}
+			run_tests="$run_tests ${tests[$i]}"
+		done
+
+		#
+		# Handle dialog exit states:
+		#
+		case $ret in
+		0)
+			if [ $x -eq 0 ]; then
+				dialog --backtitle "$FWTS" --title "No Tests Selected!" --msgbox \
+			"   You did not select any tests to be run." 5 50
+			else
+				# remove leading space and output to oem-tests.lst
+				echo "TESTS=$(echo $run_tests)" > $OEM_TESTS_FILE
+				echo "POST=poweroff" >> $OEM_TESTS_FILE
+				dialog --backtitle "$FWTS" --title "Auto-tests Saved!" --msgbox \
+					" Auto-tests are saved to $OEM_TESTS_FILE" 5 50
+				finish
+			fi
+			;;
+		1)
+			return
+			;;
+		2)
+			do_help
+			;;
+		255)
+			no_tests_finish
+			;;
+		esac
+	done
+}
 #
 #  View the results log
 #
@@ -314,6 +384,7 @@  do
 			"Recommended" "Recommended Tests" off \
 			"Recommended for IFV" "Recommended Tests for F/W Vendors" off \
 			"Selected" "Select Individual Tests" off \
+			"Automated" "Create Auto-Tests" off \
 			"Abort" "Abort Testing" off \
 			2> $OPTIONS
 			;;
@@ -369,6 +440,9 @@  do
 		'Selected')
 			select_tests
 			;;
+		'Automated')
+			select_oem_automation
+			;;
 		'Abort')
 			no_tests_finish
 			;;