Re: [PATCH v3 3/3] tools: hv: add vmbus testing tool

2019-08-21 Thread Branden Bonaby
On Thu, Aug 22, 2019 at 01:36:09AM +, Harry Zhang wrote:
> Tool function issues:  Please validate args errors for  '-p' and '--path',  
> in or following validate_args_path().  
> 
> Comments of functionality:
> - it's confusing when fuzz_testing are all OFF, then user run ' python3 
> /home/lisa/vmbus_testing -p 
> /sys/kernel/debug/hyperv/000d3a6e-4548-000d-3a6e-4548000d3a6e delay -d 0 0 -D 
> ' which will enable all delay testing state ('Y' in state files).  even I 
> used "-D", "--dis_all" param. 
> - if we have subparsers of "disable-all" for the testing tool, then 
> probably we don't need the mutually_exclusive_group under subparsers of 
> "delay"
> - the path argument (-p) could be an argument for subparsers of "delay" 
> and "view" only.
> 
> Regards,
> Harry
>

So I made the choice to keep disabling the state and disabling delay
testing seperate, because once we start adding other testing options
you wouldn't want to inadvertently disable all testing especially
if you were doing more than one type of test at a time.
So with your configuration

'python3 /home/lisa/vmbus_testing -p 
/sys/kernel/debug/hyperv/000d3a6e-4548-000d-3a6e-4548000d3a6e delay -d 0 0 -D '

this would stop all delay testing on all the devices but wouldn't change
their test state to OFF 'N'.So thats why I have the option -s --state to
change the state to Off with a -s 0. Then to disable all types of testing
and change the state to OFF thats where the 'disable-all' subparser  comes in.
with:

'python3 /home/lisa/vmbus_testing disable-all

For that last point I don't understand what you mean, are you saying it would be
better to have something like this using  delay as an example?

'python3 /home/lisa/vmbus_testing delay -p 
/sys/kernel/debug/hyperv/000d3a6e-4548-000d-3a6e-4548000d3a6e'

If thats what you mean I figured it was better to make the -p accessible
to all test type so I made it apart of the main parser. This would allow
us to just have it there once instead of having to make a -p for every
subparser.

Also maybe I need to change the examples and the help text
because with the -D option for delay you wouldnt actually need to put in 
the path. As

'python3 /home/lisa/vmbus_testing delay -d 0 0 -D '

would suffice to stop delay testing on all devices; -E would enable
it for all devices and change the state to On 'Y' if it wasn't already.

let me know your thoughts

branden bonaby


RE: [PATCH v3 3/3] tools: hv: add vmbus testing tool

2019-08-21 Thread Harry Zhang
Tool function issues:  Please validate args errors for  '-p' and '--path',  in 
or following validate_args_path().  

Comments of functionality:
-   it's confusing when fuzz_testing are all OFF, then user run ' python3 
/home/lisa/vmbus_testing -p 
/sys/kernel/debug/hyperv/000d3a6e-4548-000d-3a6e-4548000d3a6e delay -d 0 0 -D ' 
which will enable all delay testing state ('Y' in state files).  even I used 
"-D", "--dis_all" param. 
-   if we have subparsers of "disable-all" for the testing tool, then 
probably we don't need the mutually_exclusive_group under subparsers of "delay"
-   the path argument (-p) could be an argument for subparsers of "delay" 
and "view" only.

Regards,
Harry

-Original Message-
From: linux-hyperv-ow...@vger.kernel.org  
On Behalf Of Branden Bonaby
Sent: Tuesday, August 20, 2019 4:40 PM
To: KY Srinivasan ; Haiyang Zhang ; 
Stephen Hemminger ; sas...@kernel.org
Cc: brandonbonaby94 ; linux-hyp...@vger.kernel.org; 
linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/3] tools: hv: add vmbus testing tool

This is a userspace tool to drive the testing. Currently it supports 
introducing user specified delay in the host to guest communication path on a 
per-channel basis.

Signed-off-by: Branden Bonaby 
---
Changes in v3:
 - Align python tool to match Linux coding style.

Changes in v2:
 - Move testing location to new location in debugfs.

 tools/hv/vmbus_testing | 342 +
 1 file changed, 342 insertions(+)
 create mode 100644 tools/hv/vmbus_testing

diff --git a/tools/hv/vmbus_testing b/tools/hv/vmbus_testing new file mode 
100644 index ..0f249f6ee698
--- /dev/null
+++ b/tools/hv/vmbus_testing
@@ -0,0 +1,342 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: GPL-2.0
+#
+# Program to allow users to fuzz test Hyper-V drivers # by interfacing 
+with Hyper-V debugfs directories # author: Branden Bonaby
+
+import os
+import cmd
+import argparse
+from collections import defaultdict
+from argparse import RawDescriptionHelpFormatter
+
+# debugfs paths for vmbus must exist (same as in lsvmbus) 
+debugfs_sys_path = "/sys/kernel/debug/hyperv"
+if not os.path.isdir(debugfs_sys_path):
+print("{} doesn't exist/check permissions".format(debugfs_sys_path))
+exit(-1)
+# Do not change unless, you change the debugfs attributes # in 
+"/sys/kernel/debug/hyperv//". All fuzz testing # attributes will 
+start with "fuzz_test".
+pathlen = len(debugfs_sys_path)
+fuzz_state_location = "fuzz_test_state"
+fuzz_states = {
+0 : "Disable",
+1 : "Enable"
+}
+
+fuzz_methods = {
+1 : "Delay_testing"
+}
+
+fuzz_delay_types = {
+1 : "fuzz_test_buffer_interrupt_delay",
+2 : "fuzz_test_message_delay"
+}
+
+def parse_args():
+parser = argparse.ArgumentParser(description = "vmbus_testing "
+"[-s] [0|1] [-q] [-p] \n""vmbus_testing [-s]"
+" [0|1] [-q][-p]  delay [-d] [val][val] 
[-E|-D]\n"
+"vmbus_testing [-q] disable-all\n"
+"vmbus_testing [-q] view [-v|-V]\n"
+"vmbus_testing --version",
+epilog = "Current testing options {}".format(fuzz_methods),
+prog = 'vmbus_testing',
+formatter_class = RawDescriptionHelpFormatter)
+subparsers = parser.add_subparsers(dest = "action")
+parser.add_argument("--version", action = "version",
+version = '%(prog)s 1.0')
+parser.add_argument("-q","--quiet", action = "store_true",
+help = "silence none important test messages")
+parser.add_argument("-s","--state", metavar = "", type = int,
+choices = range(0, 2),
+help = "Turn testing ON or OFF for a single device."
+" The value (1) will turn testing ON. The value"
+" of (0) will turn testing OFF with the default set"
+" to (0).")
+parser.add_argument("-p","--path", metavar = "",
+help = "Refers to the debugfs path to a vmbus device."
+" If the path is not a valid path to a vmbus device,"
+" the program will exit. The path must be the"
+" absolute path; use the lsvmbus command to find"
+" the path.")
+parser_delay = subparsers.add_parser("delay",
+help = "Delay buffer/message reads in microseconds.",
+description = "vmbus_testing -s [0|1] [-q] -p "
+" delay -d "
+"[buffer-delay-value] [message-delay-value]\n"
+"vmbus_testing [-q] delay [buffer-delay-value] "
+"[message-delay-value] -E\n"
+"vmbus_testing [-q] delay [buffer-delay-value] "
+