diff mbox

[kvm-unit-tests,V5,1/5] scripts/runtime: Add ability to mark test as don't run by default

Message ID 1471569014-11063-1-git-send-email-sjitindarsingh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Suraj Jitindar Singh Aug. 19, 2016, 1:10 a.m. UTC
Invoking run_tests.sh without the -g parameter will by default run all of
the tests for a given architecture. This patch series will add a test which
has the ability to bring down the host and thus it might be nice if we
double check that the user actually wants to run that test instead of
them unknowingly bringing down a machine they might not want to.

In order to do this add the option for a tests' group parameter in
unittests.cfg to include "nodefault" on order to indicate that it shouldn't
be run be default.

When tests are invoked via run_tests.sh those with the nodefault group
parameter will be skipped unless explicitly specified by the "-g" command
line option. When tests with the nodefault group parameter are built and
run standalone the user will be prompted on invocation to confirm that
they actually want to run the test.

This allows a developer to mark a test as having potentially adverse
effects and thus requires an extra level of confirmation from the user
before they are invoked. Existing functionality will be preserved and new
tests can choose any group other than "nodefault" if they want to be run
by default.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>

---

Change Log:

V2 -> V3:
	- Move checking on standalone invokation into a function
	  "skip_nodefault" in scripts/runtime.bash
V3 -> V4:
	- Remove superfluous "STANDALONE=yes"
V4 -> V5:
	- Cosmetic changes
---
 arm/unittests.cfg     |  3 +++
 powerpc/unittests.cfg |  3 +++
 scripts/runtime.bash  | 25 ++++++++++++++++++++++++-
 x86/unittests.cfg     |  3 +++
 4 files changed, 33 insertions(+), 1 deletion(-)

Comments

Andrew Jones Aug. 19, 2016, 6:40 a.m. UTC | #1
On Fri, Aug 19, 2016 at 11:10:10AM +1000, Suraj Jitindar Singh wrote:
> Invoking run_tests.sh without the -g parameter will by default run all of
> the tests for a given architecture. This patch series will add a test which
> has the ability to bring down the host and thus it might be nice if we
> double check that the user actually wants to run that test instead of
> them unknowingly bringing down a machine they might not want to.
> 
> In order to do this add the option for a tests' group parameter in
> unittests.cfg to include "nodefault" on order to indicate that it shouldn't
> be run be default.
> 
> When tests are invoked via run_tests.sh those with the nodefault group
> parameter will be skipped unless explicitly specified by the "-g" command
> line option. When tests with the nodefault group parameter are built and
> run standalone the user will be prompted on invocation to confirm that
> they actually want to run the test.
> 
> This allows a developer to mark a test as having potentially adverse
> effects and thus requires an extra level of confirmation from the user
> before they are invoked. Existing functionality will be preserved and new
> tests can choose any group other than "nodefault" if they want to be run
> by default.
> 
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
> Reviewed-by: Andrew Jones <drjones@redhat.com>

Thanks for the cosmetic refresh. My r-b is already on all patches, so the
series is good to go for me.

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Huth Aug. 22, 2016, 10:23 p.m. UTC | #2
On 19.08.2016 08:40, Andrew Jones wrote:
> On Fri, Aug 19, 2016 at 11:10:10AM +1000, Suraj Jitindar Singh wrote:
>> Invoking run_tests.sh without the -g parameter will by default run all of
>> the tests for a given architecture. This patch series will add a test which
>> has the ability to bring down the host and thus it might be nice if we
>> double check that the user actually wants to run that test instead of
>> them unknowingly bringing down a machine they might not want to.
>>
>> In order to do this add the option for a tests' group parameter in
>> unittests.cfg to include "nodefault" on order to indicate that it shouldn't
>> be run be default.
>>
>> When tests are invoked via run_tests.sh those with the nodefault group
>> parameter will be skipped unless explicitly specified by the "-g" command
>> line option. When tests with the nodefault group parameter are built and
>> run standalone the user will be prompted on invocation to confirm that
>> they actually want to run the test.
>>
>> This allows a developer to mark a test as having potentially adverse
>> effects and thus requires an extra level of confirmation from the user
>> before they are invoked. Existing functionality will be preserved and new
>> tests can choose any group other than "nodefault" if they want to be run
>> by default.
>>
>> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
>> Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
>> Reviewed-by: Andrew Jones <drjones@redhat.com>
> 
> Thanks for the cosmetic refresh. My r-b is already on all patches, so the
> series is good to go for me.

Right, series also looks fine to me, too. Radim, Paolo, could you pick
up the patches directly, or do you want me to queue them and send a pull
request?

 Thomas


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Radim Krčmář Aug. 27, 2016, 2:41 p.m. UTC | #3
2016-08-23 00:23+0200, Thomas Huth:
> On 19.08.2016 08:40, Andrew Jones wrote:
>> On Fri, Aug 19, 2016 at 11:10:10AM +1000, Suraj Jitindar Singh wrote:
>> Thanks for the cosmetic refresh. My r-b is already on all patches, so the
>> series is good to go for me.
> 
> Right, series also looks fine to me, too. Radim, Paolo, could you pick
> up the patches directly, or do you want me to queue them and send a pull
> request?

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arm/unittests.cfg b/arm/unittests.cfg
index ffd12e5..3f6fa45 100644
--- a/arm/unittests.cfg
+++ b/arm/unittests.cfg
@@ -12,6 +12,9 @@ 
 #					# specific to only one.
 # groups = <group_name1> <group_name2> ...	# Used to identify test cases
 #						# with run_tests -g ...
+#						# Specify group_name=nodefault
+#						# to have test not run by
+#						# default
 # accel = kvm|tcg		# Optionally specify if test must run with
 #				# kvm or tcg. If not specified, then kvm will
 #				# be used when available.
diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
index ed4fdbe..0098cb6 100644
--- a/powerpc/unittests.cfg
+++ b/powerpc/unittests.cfg
@@ -12,6 +12,9 @@ 
 #					# specific to only one.
 # groups = <group_name1> <group_name2> ...	# Used to identify test cases
 #						# with run_tests -g ...
+#						# Specify group_name=nodefault
+#						# to have test not run by
+#						# default
 # accel = kvm|tcg		# Optionally specify if test must run with
 #				# kvm or tcg. If not specified, then kvm will
 #				# be used when available.
diff --git a/scripts/runtime.bash b/scripts/runtime.bash
index 0503cf0..1bd87bc 100644
--- a/scripts/runtime.bash
+++ b/scripts/runtime.bash
@@ -32,6 +32,23 @@  get_cmdline()
     echo "TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts"
 }
 
+skip_nodefault()
+{
+    [ "$STANDALONE" != "yes" ] && return 0
+
+    while true; do
+        read -p "Test marked not to be run by default, are you sure (y/N)? " yn
+        case $yn in
+            "Y" | "y" | "Yes" | "yes")
+                return 1
+                ;;
+            "" | "N" | "n" | "No" | "no" | "q" | "quit" | "exit")
+                return 0
+                ;;
+        esac
+    done
+}
+
 function run()
 {
     local testname="$1"
@@ -48,10 +65,16 @@  function run()
         return
     fi
 
-    if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then
+    if [ -n "$only_group" ] && ! grep -qw "$only_group" <<<$groups; then
         return
     fi
 
+    if [ -z "$only_group" ] && grep -qw "nodefault" <<<$groups &&
+            skip_nodefault; then
+        echo -e "`SKIP` $testname (test marked as manual run only)"
+        return;
+    fi
+
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
         echo "`SKIP` $1 ($arch only)"
         return 2
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 60747cf..4a1f74e 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -12,6 +12,9 @@ 
 #					# specific to only one.
 # groups = <group_name1> <group_name2> ...	# Used to identify test cases
 #						# with run_tests -g ...
+#						# Specify group_name=nodefault
+#						# to have test not run by
+#						# default
 # accel = kvm|tcg		# Optionally specify if test must run with
 #				# kvm or tcg. If not specified, then kvm will
 #				# be used when available.