tests: replace pycodestyle with black
[vpp.git] / test / sanity_run_vpp.py
index 527b618..5e2b3c1 100644 (file)
@@ -1,18 +1,36 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 from __future__ import print_function
-from framework import VppTestCase
-from hook import VppDiedError
-from sys import exit
+from multiprocessing import Pipe
+import sys
+import os
+from framework import VppDiedError, VppTestCase, KeepAliveReporter
 
 
 class SanityTestCase(VppTestCase):
-    """ Dummy test case used to check if VPP is able to start """
-    pass
+    """Sanity test case - verify whether VPP is able to start"""
 
-if __name__ == '__main__':
+    cpus = [0]
+
+    # don't ask to debug SanityTestCase
+    @classmethod
+    def wait_for_enter(cls, pid=0):
+        pass
+
+    @classmethod
+    def _debug_quit(cls):
+        try:
+            cls.vpp.poll()
+        except AttributeError:
+            pass
+
+
+def main():
     rc = 0
     tc = SanityTestCase
+    x, y = Pipe()
+    reporter = KeepAliveReporter()
+    reporter.pipe = y
     try:
         tc.setUpClass()
     except VppDiedError:
@@ -20,7 +38,17 @@ if __name__ == '__main__':
     else:
         try:
             tc.tearDownClass()
-        except:
-            pass
+        except Exception:
+            rc = -1
+    x.close()
+    y.close()
+
+    if rc == 0:
+        print("Sanity test case passed.")
+    else:
+        print("Sanity test case failed.")
+    return rc
+
 
-    exit(rc)
+if __name__ == "__main__":
+    sys.exit(main())