Merge pull request #32 from eswierk/master
Add test for BSN shell command extension, etc.
diff --git a/profiles/default.py b/profiles/default.py
deleted file mode 100644
index 592797e..0000000
--- a/profiles/default.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""
-Default profile
-
-No tests skipped.
-"""
-
-#@var skip_test_list The list of tests to skip for this run
-skip_test_list = [
-]
-
-#@var run_test_list List of tests to run which would normally be skipped
-run_test_list = [
-]
diff --git a/profiles/example.py b/profiles/example.py
deleted file mode 100644
index 0928119..0000000
--- a/profiles/example.py
+++ /dev/null
@@ -1,35 +0,0 @@
-"""
-Sample profile
-
-A profile determines run specific behavior. It is meant to capture
-variations between different switch targets.
-
-A profile defines two target specific variables.
-
-1. A set of tests to skip
-
-TO BE IMPLEMENTED:
-
-2. A set of tests to run (overriding the default "skip" priority)
-optionally specifying a test parameters specific to the test run
-
-@todo Allow a test to be run multiple times with different params
-"""
-
-#@var skip_test_list The list of tests to skip for this run
-skip_test_list = []
-
-# A list of test cases
-#@var run_test_list List of tests to run which would normally be skipped
-run_test_list = []
-
-#
-# Ideally, we should allow parameters to be specified
-#
-# run_test_list = (
-# testcase = [dict(param1), dict(param2), ...],
-# )
-#
-# for test_dict in profile.run_test_list:
-# for test_name, test_params in test_dict.items():
-# ...
diff --git a/profiles/noing.py b/profiles/noing.py
deleted file mode 100644
index 4389dd4..0000000
--- a/profiles/noing.py
+++ /dev/null
@@ -1,24 +0,0 @@
-"""
-No-ingress action profile
-
-Profile for switch that does not support the IN_PORT port
-in the output action.
-
-We also don't run the port config modify test for this profile.
-"""
-
-#@var skip_test_list The list of tests to skip for this run
-skip_test_list = [
- "PortConfigMod",
- "FloodMinusPort",
- "ModifyL2DstIngressMC",
- "ModifyL2DstIngress",
- "DirectMC",
- "AllPlusIngress",
- "FloodPlusIngress",
- "ModifyVIDToIngress",
-]
-
-#@var run_test_list List of tests to run which would normally be skipped
-run_test_list = [
-]
diff --git a/tests/bsn_shell.py b/tests/bsn_shell.py
new file mode 100644
index 0000000..f4d9969
--- /dev/null
+++ b/tests/bsn_shell.py
@@ -0,0 +1,47 @@
+"""
+"""
+import struct
+
+import logging
+
+from oftest import config
+import oftest.controller as controller
+import oftest.cstruct as ofp
+import oftest.message as message
+import oftest.base_tests as base_tests
+
+from oftest.testutils import *
+
+@nonstandard
+class BSNShellCommand(base_tests.SimpleDataPlane):
+ """
+ Exercise BSN vendor extension for running a shell command on the switch
+ """
+
+ def bsn_shell_command(self, cmd):
+ """
+ Use the BSN_SHELL_COMMAND vendor command to run the given command
+ and receive the output
+ """
+ m = message.vendor()
+ m.vendor = 0x005c16c7
+ m.data = struct.pack("!LL", 6, 0) + cmd
+ rc = self.controller.message_send(m)
+ self.assertNotEqual(rc, -1, "Error sending shell command")
+ out = ""
+ while True:
+ m, r = self.controller.poll(ofp.OFPT_VENDOR, 60)
+ self.assertEqual(m.vendor, 0x005c16c7, "Wrong vendor ID")
+ subtype = struct.unpack("!L", m.data[:4])[0]
+ if subtype == 7:
+ out += m.data[4:]
+ elif subtype == 8:
+ status = struct.unpack("!LL", m.data)[1]
+ return status, out
+ else:
+ assert False, "Wrong subtype"
+
+ def runTest(self):
+ status, out = self.bsn_shell_command("echo _one space_")
+ self.assertEqual(status, 0, "Shell command returned %s != 0" % status)
+ self.assertEqual(out, "_one space_\n", "Shell command output: '%r'" % out)