From cf835d72bd5c0bc050ee26e52d8f5e3ed18f1363 Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Wed, 15 Apr 2009 12:43:56 -0300
Subject: [PATCH 23/38] tests/behaviour: Allow the user to run a single test

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 tests/behaviour/runtests |    9 +++++++--
 tests/behaviour/tf.py    |    6 +++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/tests/behaviour/runtests b/tests/behaviour/runtests
index 645a3bf..2860493 100755
--- a/tests/behaviour/runtests
+++ b/tests/behaviour/runtests
@@ -5,7 +5,8 @@ import tf
 
 possible_tests = ('normal', 'corruption', 'fi')
 if len(sys.argv) < 2 or sys.argv[1] not in possible_tests + ('all',):
-	print 'Usage: runtests', '|'.join(possible_tests + ('all',))
+	print 'Usage: runtests', '|'.join(possible_tests + ('all',)),
+	print '[test_name]'
 	sys.exit(1)
 
 if sys.argv[1] == 'all':
@@ -13,7 +14,11 @@ if sys.argv[1] == 'all':
 else:
 	mnames = ('t_' + sys.argv[1],)
 
+specific_test = None
+if len(sys.argv) >= 3:
+	specific_test = sys.argv[2]
+
 for mn in mnames:
 	print '--', mn
-	tf.autorun(__import__(mn))
+	tf.autorun(__import__(mn), specific_test)
 
diff --git a/tests/behaviour/tf.py b/tests/behaviour/tf.py
index 016fd1e..7dbd2eb 100644
--- a/tests/behaviour/tf.py
+++ b/tests/behaviour/tf.py
@@ -216,7 +216,7 @@ def gen_ret_after(n, notyet, itstime):
 	return newf
 
 
-def autorun(module):
+def autorun(module, specific_test = None):
 	"Runs all the functions in the given module that begin with 'test'."
 	for name in sorted(dir(module)):
 		if not name.startswith('test'):
@@ -227,6 +227,10 @@ def autorun(module):
 			name = name[len('test'):]
 			if name.startswith('_'):
 				name = name[1:]
+
+			if specific_test and name != specific_test:
+				continue
+
 			desc = ''
 			if obj.__doc__:
 				desc = obj.__doc__
-- 
1.6.2.2.646.gb214

