diff mbox

[i-g-t,1/3] igt/drv_module_reload_basic: add helper for checking module reloaded

Message ID daff442a5a3924829427e3fff70336e00f12ca23.1475504339.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jani Nikula Oct. 3, 2016, 2:20 p.m. UTC
Add a helper for checking whether a module is reloaded, using
lsmod. Also make the grep stricter than before.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 tests/drv_module_reload_basic | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Joonas Lahtinen Oct. 4, 2016, 4:45 a.m. UTC | #1
On ma, 2016-10-03 at 17:20 +0300, Jani Nikula wrote:
> Add a helper for checking whether a module is reloaded, using
> lsmod. Also make the grep stricter than before.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
diff mbox

Patch

diff --git a/tests/drv_module_reload_basic b/tests/drv_module_reload_basic
index 3bba796f0306..4f3172788eca 100755
--- a/tests/drv_module_reload_basic
+++ b/tests/drv_module_reload_basic
@@ -10,6 +10,12 @@  SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 
 # no other drm service should be running, so we can just unbind
 
+# return 0 if module by name $1 is loaded according to lsmod
+function mod_loaded()
+{
+	lsmod | grep -w "^$1" &> /dev/null
+}
+
 function reload() {
 	local snd_hda_intel_unloaded
 
@@ -37,7 +43,7 @@  function reload() {
 	rmmod drm_kms_helper &> /dev/null
 	rmmod drm &> /dev/null
 
-	if lsmod | grep i915 &> /dev/null ; then
+	if mod_loaded i915; then
 		echo WARNING: i915.ko still loaded!
 		return $IGT_EXIT_FAILURE
 	else