diff mbox

[RFCv2,02/19] kselftests: Exercise hw-independent mock tests for i915.ko

Message ID 20161220130814.10213-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Dec. 20, 2016, 1:07 p.m. UTC
Although being a GPU driver most functionality of i915.ko depends upon
real hardware, many of its internal interfaces can be "mocked" and so
tested independently of any hardware. Expanding the test coverage is not
only useful for i915.ko, but should provide some integration tests for
core infrastructure as well.

Loading i915.ko with mock_selftests=-1 will cause it to execute its mock
tests then exit before attempting to probe hardware. If the driver is
already loaded and bound to hardware, it requires a few more steps to
unbind, and so the simple preliminary modprobe -r will fail, causing the
test to be skipped.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
---
 tools/testing/selftests/drivers/gpu/i915.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100755 tools/testing/selftests/drivers/gpu/i915.sh
diff mbox

Patch

diff --git a/tools/testing/selftests/drivers/gpu/i915.sh b/tools/testing/selftests/drivers/gpu/i915.sh
new file mode 100755
index 000000000000..c06d6e8a8dcc
--- /dev/null
+++ b/tools/testing/selftests/drivers/gpu/i915.sh
@@ -0,0 +1,15 @@ 
+#!/bin/sh
+# Runs hardware independent tests for i915 (drivers/gpu/drm/i915)
+
+if ! /sbin/modprobe -q -r i915; then
+	echo "drivers/gpu/i915: [SKIP]"
+	exit 77
+fi
+
+if /sbin/modprobe -q i915 mock_selftests=-1; then
+	/sbin/modprobe -q -r i915
+	echo "drivers/gpu/i915: ok"
+else
+	echo "drivers/gpu/i915: [FAIL]"
+	exit 1
+fi