Add check_for_kernel_feature function

From: Michal Piotrowski <michal.k.k.piotrowski@gmail.com>
Signed-off-by: Martin J. Bligh <mbligh@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@522 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index 4898c89..265c9df 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -410,13 +410,31 @@
 	"""
 	Return path of config file of the currently running kernel
 	"""
+	version = system_output('uname -r')
 	for config in ('/proc/config.gz', \
-		       '/boot/config-%s' % system_output('uname -r') ):
+		       '/boot/config-%s' % version,
+		       '/lib/modules/%s/build/.config' % version):
 		if os.path.isfile(config):
 			return config
 	return None
 
 
+def check_for_kernel_feature(feature):
+	config = running_config()
+
+	if not config:
+		raise "Can't find kernel config file"
+
+	if config.endswith('.gz'):
+		grep = 'zgrep'
+	else:
+		grep = 'grep'
+	grep += ' ^CONFIG_%s= %s' % (feature, config)
+
+	if not system_output(grep, ignorestatus = 1):
+		raise "Kernel doesn't have a %s feature" % (feature)
+
+
 def cpu_online_map():
 	"""
 	Check out the available cpu online map