Add a test case for a too short command

Added a new test case to tpm2_smoke.py:

  SmokeTest.test_too_short_cmd()

This test will send a command to the TPM whose command length is
longer than the number of bytes sent. The driver should reject
this command and not allow it to pass through.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
diff --git a/tpm2_smoke.py b/tpm2_smoke.py
index feeb5d6..e68b273 100755
--- a/tpm2_smoke.py
+++ b/tpm2_smoke.py
@@ -6,7 +6,7 @@
 from tpm2 import ProtocolError
 import unittest
 import logging
-
+import struct
 
 class SmokeTest(unittest.TestCase):
     def setUp(self):
@@ -139,6 +139,22 @@
 
         self.assertEqual(rc, tpm2.TPM2_RC_SIZE)
 
+    def test_too_short_cmd(self):
+        rejected = False
+        try:
+            fmt = '>HIII'
+            cmd = struct.pack(fmt,
+                              tpm2.TPM2_ST_NO_SESSIONS,
+                              struct.calcsize(fmt) + 1,
+                              tpm2.TPM2_CC_FLUSH_CONTEXT,
+                              0xDEADBEEF)
+
+            self.client.send_cmd(cmd)
+        except IOError, e:
+            rejected = True
+        except:
+            pass
+        self.assertEqual(rejected, True)
 
 class SpaceTest(unittest.TestCase):
     def setUp(self):