From 9c0ed88c72cb4a3c43f474c9c67435d83c71958d Mon Sep 17 00:00:00 2001
From: Bob Lantz <rlantz@cs.stanford.edu>
Date: Thu, 4 Oct 2012 18:57:56 -0700
Subject: [PATCH] Create version check utility and add to code check. Fixes #70

---
 Makefile             |  1 +
 util/versioncheck.py | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)
 create mode 100755 util/versioncheck.py

diff --git a/Makefile b/Makefile
index 5cba0c30..4752ca9c 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ clean:
 
 codecheck: $(PYSRC)
 	-echo "Running code check"
+	util/versioncheck.py
 	pyflakes $(PYSRC)
 	pylint --rcfile=.pylint $(PYSRC)
 	pep8 --repeat --ignore=$(P8IGN) $(PYSRC)
diff --git a/util/versioncheck.py b/util/versioncheck.py
new file mode 100755
index 00000000..d9e54831
--- /dev/null
+++ b/util/versioncheck.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+
+from subprocess import check_output as co
+from sys import exit
+
+# Actually run bin/mn rather than importing via python path
+version = 'Mininet ' + co( 'PYTHONPATH=. bin/mn --version', shell=True )
+version = version.strip()
+
+# Find all Mininet path references
+lines = co( "grep -or 'Mininet \w\.\w\.\w\w*' *", shell=True )
+
+error = False
+
+for line in lines.split( '\n' ):
+    if line and 'Binary' not in line:
+        fname, fversion = line.split( ':' )
+        if version != fversion:
+            print "%s: incorrect version '%s' (should be '%s')" % (
+                fname, fversion, version )
+            error = True
+
+if error:
+    exit( 1 )
-- 
GitLab