|
|
0790b6 |
From d8ca5e0a429b8f7395e136e713980db6a7ac8dc2 Mon Sep 17 00:00:00 2001
|
|
|
0790b6 |
From: Mohammed Gamal <mgamal@redhat.com>
|
|
|
0790b6 |
Date: Wed, 15 Apr 2020 12:00:30 +0200
|
|
|
0790b6 |
Subject: [PATCH 2/2] Add vmbus_testing tool build files
|
|
|
0790b6 |
|
|
|
0790b6 |
RH-Author: Mohammed Gamal <mgamal@redhat.com>
|
|
|
0790b6 |
Message-id: <20200414183955.194006-3-mgamal@redhat.com>
|
|
|
0790b6 |
Patchwork-id: 94690
|
|
|
0790b6 |
O-Subject: [RHEL8.3 virt hyperv-daemons PATCH v5 2/2] Add vmbus_testing tool build files
|
|
|
0790b6 |
Bugzilla: 1816750
|
|
|
0790b6 |
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
0790b6 |
RH-Acked-by: Cathy Avery <cavery@redhat.com>
|
|
|
0790b6 |
|
|
|
0790b6 |
Add the vmbus_testing tool to redhat build dirs
|
|
|
0790b6 |
|
|
|
0790b6 |
Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
|
|
|
0790b6 |
---
|
|
|
0790b6 |
redhat/hyperv-daemons.spec.template | 2 +
|
|
|
0790b6 |
vmbus_testing | 376 ++++++++++++++++++++++++++++
|
|
|
0790b6 |
2 files changed, 378 insertions(+)
|
|
|
0790b6 |
create mode 100755 vmbus_testing
|
|
|
0790b6 |
|
|
|
0790b6 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0790b6 |
---
|
|
|
0790b6 |
redhat/hyperv-daemons.spec.template | 2 +
|
|
|
0790b6 |
vmbus_testing | 376 ++++++++++++++++++++++++++++++++++++
|
|
|
0790b6 |
2 files changed, 378 insertions(+)
|
|
|
0790b6 |
create mode 100755 vmbus_testing
|
|
|
0790b6 |
|
|
|
0790b6 |
diff --git a/vmbus_testing b/vmbus_testing
|
|
|
0790b6 |
new file mode 100755
|
|
|
0790b6 |
index 0000000..e721290
|
|
|
0790b6 |
--- /dev/null
|
|
|
0790b6 |
+++ b/vmbus_testing
|
|
|
0790b6 |
@@ -0,0 +1,376 @@
|
|
|
0790b6 |
+#!/usr/bin/env python3
|
|
|
0790b6 |
+# SPDX-License-Identifier: GPL-2.0
|
|
|
0790b6 |
+#
|
|
|
0790b6 |
+# Program to allow users to fuzz test Hyper-V drivers
|
|
|
0790b6 |
+# by interfacing with Hyper-V debugfs attributes.
|
|
|
0790b6 |
+# Current test methods available:
|
|
|
0790b6 |
+# 1. delay testing
|
|
|
0790b6 |
+#
|
|
|
0790b6 |
+# Current file/directory structure of hyper-V debugfs:
|
|
|
0790b6 |
+# /sys/kernel/debug/hyperv/UUID
|
|
|
0790b6 |
+# /sys/kernel/debug/hyperv/UUID/<test-state filename>
|
|
|
0790b6 |
+# /sys/kernel/debug/hyperv/UUID/<test-method sub-directory>
|
|
|
0790b6 |
+#
|
|
|
0790b6 |
+# author: Branden Bonaby <brandonbonaby94@gmail.com>
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+import os
|
|
|
0790b6 |
+import cmd
|
|
|
0790b6 |
+import argparse
|
|
|
0790b6 |
+import glob
|
|
|
0790b6 |
+from argparse import RawDescriptionHelpFormatter
|
|
|
0790b6 |
+from argparse import RawTextHelpFormatter
|
|
|
0790b6 |
+from enum import Enum
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Do not change unless, you change the debugfs attributes
|
|
|
0790b6 |
+# in /drivers/hv/debugfs.c. All fuzz testing
|
|
|
0790b6 |
+# attributes will start with "fuzz_test".
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# debugfs path for hyperv must exist before proceeding
|
|
|
0790b6 |
+debugfs_hyperv_path = "/sys/kernel/debug/hyperv"
|
|
|
0790b6 |
+if not os.path.isdir(debugfs_hyperv_path):
|
|
|
0790b6 |
+ print("{} doesn't exist/check permissions".format(debugfs_hyperv_path))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+class dev_state(Enum):
|
|
|
0790b6 |
+ off = 0
|
|
|
0790b6 |
+ on = 1
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# File names, that correspond to the files created in
|
|
|
0790b6 |
+# /drivers/hv/debugfs.c
|
|
|
0790b6 |
+class f_names(Enum):
|
|
|
0790b6 |
+ state_f = "fuzz_test_state"
|
|
|
0790b6 |
+ buff_f = "fuzz_test_buffer_interrupt_delay"
|
|
|
0790b6 |
+ mess_f = "fuzz_test_message_delay"
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Both single_actions and all_actions are used
|
|
|
0790b6 |
+# for error checking and to allow for some subparser
|
|
|
0790b6 |
+# names to be abbreviated. Do not abbreviate the
|
|
|
0790b6 |
+# test method names, as it will become less intuitive
|
|
|
0790b6 |
+# as to what the user can do. If you do decide to
|
|
|
0790b6 |
+# abbreviate the test method name, make sure the main
|
|
|
0790b6 |
+# function reflects this change.
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+all_actions = [
|
|
|
0790b6 |
+ "disable_all",
|
|
|
0790b6 |
+ "D",
|
|
|
0790b6 |
+ "enable_all",
|
|
|
0790b6 |
+ "view_all",
|
|
|
0790b6 |
+ "V"
|
|
|
0790b6 |
+]
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+single_actions = [
|
|
|
0790b6 |
+ "disable_single",
|
|
|
0790b6 |
+ "d",
|
|
|
0790b6 |
+ "enable_single",
|
|
|
0790b6 |
+ "view_single",
|
|
|
0790b6 |
+ "v"
|
|
|
0790b6 |
+]
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+def main():
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ file_map = recursive_file_lookup(debugfs_hyperv_path, dict())
|
|
|
0790b6 |
+ args = parse_args()
|
|
|
0790b6 |
+ if (not args.action):
|
|
|
0790b6 |
+ print ("Error, no options selected...exiting")
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+ arg_set = { k for (k,v) in vars(args).items() if v and k != "action" }
|
|
|
0790b6 |
+ arg_set.add(args.action)
|
|
|
0790b6 |
+ path = args.path if "path" in arg_set else None
|
|
|
0790b6 |
+ if (path and path[-1] == "/"):
|
|
|
0790b6 |
+ path = path[:-1]
|
|
|
0790b6 |
+ validate_args_path(path, arg_set, file_map)
|
|
|
0790b6 |
+ if (path and "enable_single" in arg_set):
|
|
|
0790b6 |
+ state_path = locate_state(path, file_map)
|
|
|
0790b6 |
+ set_test_state(state_path, dev_state.on.value, args.quiet)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ # Use subparsers as the key for different actions
|
|
|
0790b6 |
+ if ("delay" in arg_set):
|
|
|
0790b6 |
+ validate_delay_values(args.delay_time)
|
|
|
0790b6 |
+ if (args.enable_all):
|
|
|
0790b6 |
+ set_delay_all_devices(file_map, args.delay_time,
|
|
|
0790b6 |
+ args.quiet)
|
|
|
0790b6 |
+ else:
|
|
|
0790b6 |
+ set_delay_values(path, file_map, args.delay_time,
|
|
|
0790b6 |
+ args.quiet)
|
|
|
0790b6 |
+ elif ("disable_all" in arg_set or "D" in arg_set):
|
|
|
0790b6 |
+ disable_all_testing(file_map)
|
|
|
0790b6 |
+ elif ("disable_single" in arg_set or "d" in arg_set):
|
|
|
0790b6 |
+ disable_testing_single_device(path, file_map)
|
|
|
0790b6 |
+ elif ("view_all" in arg_set or "V" in arg_set):
|
|
|
0790b6 |
+ get_all_devices_test_status(file_map)
|
|
|
0790b6 |
+ elif ("view_single" in arg_set or "v" in arg_set):
|
|
|
0790b6 |
+ get_device_test_values(path, file_map)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Get the state location
|
|
|
0790b6 |
+def locate_state(device, file_map):
|
|
|
0790b6 |
+ return file_map[device][f_names.state_f.value]
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Validate delay values to make sure they are acceptable to
|
|
|
0790b6 |
+# enable delays on a device
|
|
|
0790b6 |
+def validate_delay_values(delay):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ if (delay[0] == -1 and delay[1] == -1):
|
|
|
0790b6 |
+ print("\nError, At least 1 value must be greater than 0")
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+ for i in delay:
|
|
|
0790b6 |
+ if (i < -1 or i == 0 or i > 1000):
|
|
|
0790b6 |
+ print("\nError, Values must be equal to -1 "
|
|
|
0790b6 |
+ "or be > 0 and <= 1000")
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Validate argument path
|
|
|
0790b6 |
+def validate_args_path(path, arg_set, file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ if (not path and any(element in arg_set for element in single_actions)):
|
|
|
0790b6 |
+ print("Error, path (-p) REQUIRED for the specified option. "
|
|
|
0790b6 |
+ "Use (-h) to check usage.")
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+ elif (path and any(item in arg_set for item in all_actions)):
|
|
|
0790b6 |
+ print("Error, path (-p) NOT REQUIRED for the specified option. "
|
|
|
0790b6 |
+ "Use (-h) to check usage." )
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+ elif (path not in file_map and any(item in arg_set
|
|
|
0790b6 |
+ for item in single_actions)):
|
|
|
0790b6 |
+ print("Error, path '{}' not a valid vmbus device".format(path))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# display Testing status of single device
|
|
|
0790b6 |
+def get_device_test_values(path, file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for name in file_map[path]:
|
|
|
0790b6 |
+ file_location = file_map[path][name]
|
|
|
0790b6 |
+ print( name + " = " + str(read_test_files(file_location)))
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# Create a map of the vmbus devices and their associated files
|
|
|
0790b6 |
+# [key=device, value = [key = filename, value = file path]]
|
|
|
0790b6 |
+def recursive_file_lookup(path, file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for f_path in glob.iglob(path + '**/*'):
|
|
|
0790b6 |
+ if (os.path.isfile(f_path)):
|
|
|
0790b6 |
+ if (f_path.rsplit("/",2)[0] == debugfs_hyperv_path):
|
|
|
0790b6 |
+ directory = f_path.rsplit("/",1)[0]
|
|
|
0790b6 |
+ else:
|
|
|
0790b6 |
+ directory = f_path.rsplit("/",2)[0]
|
|
|
0790b6 |
+ f_name = f_path.split("/")[-1]
|
|
|
0790b6 |
+ if (file_map.get(directory)):
|
|
|
0790b6 |
+ file_map[directory].update({f_name:f_path})
|
|
|
0790b6 |
+ else:
|
|
|
0790b6 |
+ file_map[directory] = {f_name:f_path}
|
|
|
0790b6 |
+ elif (os.path.isdir(f_path)):
|
|
|
0790b6 |
+ recursive_file_lookup(f_path,file_map)
|
|
|
0790b6 |
+ return file_map
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# display Testing state of devices
|
|
|
0790b6 |
+def get_all_devices_test_status(file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for device in file_map:
|
|
|
0790b6 |
+ if (get_test_state(locate_state(device, file_map)) is 1):
|
|
|
0790b6 |
+ print("Testing = ON for: {}"
|
|
|
0790b6 |
+ .format(device.split("/")[5]))
|
|
|
0790b6 |
+ else:
|
|
|
0790b6 |
+ print("Testing = OFF for: {}"
|
|
|
0790b6 |
+ .format(device.split("/")[5]))
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# read the vmbus device files, path must be absolute path before calling
|
|
|
0790b6 |
+def read_test_files(path):
|
|
|
0790b6 |
+ try:
|
|
|
0790b6 |
+ with open(path,"r") as f:
|
|
|
0790b6 |
+ file_value = f.readline().strip()
|
|
|
0790b6 |
+ return int(file_value)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ except IOError as e:
|
|
|
0790b6 |
+ errno, strerror = e.args
|
|
|
0790b6 |
+ print("I/O error({0}): {1} on file {2}"
|
|
|
0790b6 |
+ .format(errno, strerror, path))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+ except ValueError:
|
|
|
0790b6 |
+ print ("Element to int conversion error in: \n{}".format(path))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# writing to vmbus device files, path must be absolute path before calling
|
|
|
0790b6 |
+def write_test_files(path, value):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ try:
|
|
|
0790b6 |
+ with open(path,"w") as f:
|
|
|
0790b6 |
+ f.write("{}".format(value))
|
|
|
0790b6 |
+ except IOError as e:
|
|
|
0790b6 |
+ errno, strerror = e.args
|
|
|
0790b6 |
+ print("I/O error({0}): {1} on file {2}"
|
|
|
0790b6 |
+ .format(errno, strerror, path))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# set testing state of device
|
|
|
0790b6 |
+def set_test_state(state_path, state_value, quiet):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ write_test_files(state_path, state_value)
|
|
|
0790b6 |
+ if (get_test_state(state_path) is 1):
|
|
|
0790b6 |
+ if (not quiet):
|
|
|
0790b6 |
+ print("Testing = ON for device: {}"
|
|
|
0790b6 |
+ .format(state_path.split("/")[5]))
|
|
|
0790b6 |
+ else:
|
|
|
0790b6 |
+ if (not quiet):
|
|
|
0790b6 |
+ print("Testing = OFF for device: {}"
|
|
|
0790b6 |
+ .format(state_path.split("/")[5]))
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# get testing state of device
|
|
|
0790b6 |
+def get_test_state(state_path):
|
|
|
0790b6 |
+ #state == 1 - test = ON
|
|
|
0790b6 |
+ #state == 0 - test = OFF
|
|
|
0790b6 |
+ return read_test_files(state_path)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# write 1 - 1000 microseconds, into a single device using the
|
|
|
0790b6 |
+# fuzz_test_buffer_interrupt_delay and fuzz_test_message_delay
|
|
|
0790b6 |
+# debugfs attributes
|
|
|
0790b6 |
+def set_delay_values(device, file_map, delay_length, quiet):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ try:
|
|
|
0790b6 |
+ interrupt = file_map[device][f_names.buff_f.value]
|
|
|
0790b6 |
+ message = file_map[device][f_names.mess_f.value]
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ # delay[0]- buffer interrupt delay, delay[1]- message delay
|
|
|
0790b6 |
+ if (delay_length[0] >= 0 and delay_length[0] <= 1000):
|
|
|
0790b6 |
+ write_test_files(interrupt, delay_length[0])
|
|
|
0790b6 |
+ if (delay_length[1] >= 0 and delay_length[1] <= 1000):
|
|
|
0790b6 |
+ write_test_files(message, delay_length[1])
|
|
|
0790b6 |
+ if (not quiet):
|
|
|
0790b6 |
+ print("Buffer delay testing = {} for: {}"
|
|
|
0790b6 |
+ .format(read_test_files(interrupt),
|
|
|
0790b6 |
+ interrupt.split("/")[5]))
|
|
|
0790b6 |
+ print("Message delay testing = {} for: {}"
|
|
|
0790b6 |
+ .format(read_test_files(message),
|
|
|
0790b6 |
+ message.split("/")[5]))
|
|
|
0790b6 |
+ except IOError as e:
|
|
|
0790b6 |
+ errno, strerror = e.args
|
|
|
0790b6 |
+ print("I/O error({0}): {1} on files {2}{3}"
|
|
|
0790b6 |
+ .format(errno, strerror, interrupt, message))
|
|
|
0790b6 |
+ exit(-1)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# enabling delay testing on all devices
|
|
|
0790b6 |
+def set_delay_all_devices(file_map, delay, quiet):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for device in (file_map):
|
|
|
0790b6 |
+ set_test_state(locate_state(device, file_map),
|
|
|
0790b6 |
+ dev_state.on.value,
|
|
|
0790b6 |
+ quiet)
|
|
|
0790b6 |
+ set_delay_values(device, file_map, delay, quiet)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# disable all testing on a SINGLE device.
|
|
|
0790b6 |
+def disable_testing_single_device(device, file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for name in file_map[device]:
|
|
|
0790b6 |
+ file_location = file_map[device][name]
|
|
|
0790b6 |
+ write_test_files(file_location, dev_state.off.value)
|
|
|
0790b6 |
+ print("ALL testing now OFF for {}".format(device.split("/")[-1]))
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# disable all testing on ALL devices
|
|
|
0790b6 |
+def disable_all_testing(file_map):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ for device in file_map:
|
|
|
0790b6 |
+ disable_testing_single_device(device, file_map)
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+def parse_args():
|
|
|
0790b6 |
+ parser = argparse.ArgumentParser(prog = "vmbus_testing",usage ="\n"
|
|
|
0790b6 |
+ "%(prog)s [delay] [-h] [-e|-E] -t [-p]\n"
|
|
|
0790b6 |
+ "%(prog)s [view_all | V] [-h]\n"
|
|
|
0790b6 |
+ "%(prog)s [disable_all | D] [-h]\n"
|
|
|
0790b6 |
+ "%(prog)s [disable_single | d] [-h|-p]\n"
|
|
|
0790b6 |
+ "%(prog)s [view_single | v] [-h|-p]\n"
|
|
|
0790b6 |
+ "%(prog)s --version\n",
|
|
|
0790b6 |
+ description = "\nUse lsvmbus to get vmbus device type "
|
|
|
0790b6 |
+ "information.\n" "\nThe debugfs root path is "
|
|
|
0790b6 |
+ "/sys/kernel/debug/hyperv",
|
|
|
0790b6 |
+ formatter_class = RawDescriptionHelpFormatter)
|
|
|
0790b6 |
+ subparsers = parser.add_subparsers(dest = "action")
|
|
|
0790b6 |
+ parser.add_argument("--version", action = "version",
|
|
|
0790b6 |
+ version = '%(prog)s 0.1.0')
|
|
|
0790b6 |
+ parser.add_argument("-q","--quiet", action = "store_true",
|
|
|
0790b6 |
+ help = "silence none important test messages."
|
|
|
0790b6 |
+ " This will only work when enabling testing"
|
|
|
0790b6 |
+ " on a device.")
|
|
|
0790b6 |
+ # Use the path parser to hold the --path attribute so it can
|
|
|
0790b6 |
+ # be shared between subparsers. Also do the same for the state
|
|
|
0790b6 |
+ # parser, as all testing methods will use --enable_all and
|
|
|
0790b6 |
+ # enable_single.
|
|
|
0790b6 |
+ path_parser = argparse.ArgumentParser(add_help=False)
|
|
|
0790b6 |
+ path_parser.add_argument("-p","--path", metavar = "",
|
|
|
0790b6 |
+ help = "Debugfs path to a vmbus device. The path "
|
|
|
0790b6 |
+ "must be the absolute path to the device.")
|
|
|
0790b6 |
+ state_parser = argparse.ArgumentParser(add_help=False)
|
|
|
0790b6 |
+ state_group = state_parser.add_mutually_exclusive_group(required = True)
|
|
|
0790b6 |
+ state_group.add_argument("-E", "--enable_all", action = "store_const",
|
|
|
0790b6 |
+ const = "enable_all",
|
|
|
0790b6 |
+ help = "Enable the specified test type "
|
|
|
0790b6 |
+ "on ALL vmbus devices.")
|
|
|
0790b6 |
+ state_group.add_argument("-e", "--enable_single",
|
|
|
0790b6 |
+ action = "store_const",
|
|
|
0790b6 |
+ const = "enable_single",
|
|
|
0790b6 |
+ help = "Enable the specified test type on a "
|
|
|
0790b6 |
+ "SINGLE vmbus device.")
|
|
|
0790b6 |
+ parser_delay = subparsers.add_parser("delay",
|
|
|
0790b6 |
+ parents = [state_parser, path_parser],
|
|
|
0790b6 |
+ help = "Delay the ring buffer interrupt or the "
|
|
|
0790b6 |
+ "ring buffer message reads in microseconds.",
|
|
|
0790b6 |
+ prog = "vmbus_testing",
|
|
|
0790b6 |
+ usage = "%(prog)s [-h]\n"
|
|
|
0790b6 |
+ "%(prog)s -E -t [value] [value]\n"
|
|
|
0790b6 |
+ "%(prog)s -e -t [value] [value] -p",
|
|
|
0790b6 |
+ description = "Delay the ring buffer interrupt for "
|
|
|
0790b6 |
+ "vmbus devices, or delay the ring buffer message "
|
|
|
0790b6 |
+ "reads for vmbus devices (both in microseconds). This "
|
|
|
0790b6 |
+ "is only on the host to guest channel.")
|
|
|
0790b6 |
+ parser_delay.add_argument("-t", "--delay_time", metavar = "", nargs = 2,
|
|
|
0790b6 |
+ type = check_range, default =[0,0], required = (True),
|
|
|
0790b6 |
+ help = "Set [buffer] & [message] delay time. "
|
|
|
0790b6 |
+ "Value constraints: -1 == value "
|
|
|
0790b6 |
+ "or 0 < value <= 1000.\n"
|
|
|
0790b6 |
+ "Use -1 to keep the previous value for that delay "
|
|
|
0790b6 |
+ "type, or a value > 0 <= 1000 to change the delay "
|
|
|
0790b6 |
+ "time.")
|
|
|
0790b6 |
+ parser_dis_all = subparsers.add_parser("disable_all",
|
|
|
0790b6 |
+ aliases = ['D'], prog = "vmbus_testing",
|
|
|
0790b6 |
+ usage = "%(prog)s [disable_all | D] -h\n"
|
|
|
0790b6 |
+ "%(prog)s [disable_all | D]\n",
|
|
|
0790b6 |
+ help = "Disable ALL testing on ALL vmbus devices.",
|
|
|
0790b6 |
+ description = "Disable ALL testing on ALL vmbus "
|
|
|
0790b6 |
+ "devices.")
|
|
|
0790b6 |
+ parser_dis_single = subparsers.add_parser("disable_single",
|
|
|
0790b6 |
+ aliases = ['d'],
|
|
|
0790b6 |
+ parents = [path_parser], prog = "vmbus_testing",
|
|
|
0790b6 |
+ usage = "%(prog)s [disable_single | d] -h\n"
|
|
|
0790b6 |
+ "%(prog)s [disable_single | d] -p\n",
|
|
|
0790b6 |
+ help = "Disable ALL testing on a SINGLE vmbus device.",
|
|
|
0790b6 |
+ description = "Disable ALL testing on a SINGLE vmbus "
|
|
|
0790b6 |
+ "device.")
|
|
|
0790b6 |
+ parser_view_all = subparsers.add_parser("view_all", aliases = ['V'],
|
|
|
0790b6 |
+ help = "View the test state for ALL vmbus devices.",
|
|
|
0790b6 |
+ prog = "vmbus_testing",
|
|
|
0790b6 |
+ usage = "%(prog)s [view_all | V] -h\n"
|
|
|
0790b6 |
+ "%(prog)s [view_all | V]\n",
|
|
|
0790b6 |
+ description = "This shows the test state for ALL the "
|
|
|
0790b6 |
+ "vmbus devices.")
|
|
|
0790b6 |
+ parser_view_single = subparsers.add_parser("view_single",
|
|
|
0790b6 |
+ aliases = ['v'],parents = [path_parser],
|
|
|
0790b6 |
+ help = "View the test values for a SINGLE vmbus "
|
|
|
0790b6 |
+ "device.",
|
|
|
0790b6 |
+ description = "This shows the test values for a SINGLE "
|
|
|
0790b6 |
+ "vmbus device.", prog = "vmbus_testing",
|
|
|
0790b6 |
+ usage = "%(prog)s [view_single | v] -h\n"
|
|
|
0790b6 |
+ "%(prog)s [view_single | v] -p")
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ return parser.parse_args()
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+# value checking for range checking input in parser
|
|
|
0790b6 |
+def check_range(arg1):
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+ try:
|
|
|
0790b6 |
+ val = int(arg1)
|
|
|
0790b6 |
+ except ValueError as err:
|
|
|
0790b6 |
+ raise argparse.ArgumentTypeError(str(err))
|
|
|
0790b6 |
+ if val < -1 or val > 1000:
|
|
|
0790b6 |
+ message = ("\n\nvalue must be -1 or 0 < value <= 1000. "
|
|
|
0790b6 |
+ "Value program received: {}\n").format(val)
|
|
|
0790b6 |
+ raise argparse.ArgumentTypeError(message)
|
|
|
0790b6 |
+ return val
|
|
|
0790b6 |
+
|
|
|
0790b6 |
+if __name__ == "__main__":
|
|
|
0790b6 |
+ main()
|
|
|
0790b6 |
--
|
|
|
0790b6 |
1.8.3.1
|
|
|
0790b6 |
|