Add a drop_caches function to autotest_utils.

Signed-off-by: Divyesh Shah <[email protected]>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@1883 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index fdea49f..bf05ded 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -590,6 +590,14 @@
     raise error.TestError('Unable to find default gateway')
 
 
+def drop_caches():
+    """Writes back all dirty pages to disk and clears all the caches."""
+    utils.system("sync")
+    utils.system("sync")
+    # We ignore failures here as this will fail on 2.6.11 kernels.
+    utils.system("echo 3 > /proc/sys/vm/drop_caches", ignore_status=True)
+
+
 try:
     from site_utils import *
 except ImportError: