1#!/bin/bash
2#
3# Testcase: Load Intel DDX after fbdev was loaded
4#
5
6whoami | grep -q root || {
7	echo "ERROR: not running as root"
8	exit 1
9}
10
11# no other X session should be running
12find /tmp/ -name .X*lock 2>/dev/null | grep -q X && {
13	echo "ERROR: X session already running"
14	exit 1
15}
16
17TMPDIR=$(mktemp -d /tmp/igt.XXXX) || {
18	echo "ERROR: Failed to create temp dir"
19	exit 1
20}
21
22cat > $TMPDIR/xorg.conf.fbdev << EOF
23Section "Device"
24	Driver		"fbdev"
25	Identifier 	"Device[fbdev]"
26EndSection
27EOF
28
29cat > $TMPDIR/xorg.conf.intel << EOF
30Section "Device"
31	Driver		"intel"
32	Identifier 	"Device[intel]"
33EndSection
34EOF
35
36# log before fbdev
37dmesg -c > $TMPDIR/dmesg.1.before.fbdev
38cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.1.before.fbdev
39
40# run fbdev
41xinit -- /usr/bin/X -config $TMPDIR/xorg.conf.fbdev &
42sleep 5
43if [ -f `which intel_reg` ]; then
44`which intel_reg` dump > $TMPDIR/intel_reg_dump.1.fbdev
45fi
46killall X
47
48# log after fbdev & before intel
49dmesg -c > $TMPDIR/dmesg.2.after.fbdev.before.intel
50cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.2.after.fbdev.before.intel
51
52sleep 5
53
54# run intel
55xinit -- /usr/bin/X -config $TMPDIR/xorg.conf.intel &
56sleep 5
57if [ -f `which intel_reg` ]; then
58`which intel_reg` dump > $TMPDIR/intel_reg_dump.2.intel
59fi
60killall X
61
62# log after intel
63dmesg -c > $TMPDIR/dmesg.3.after.intel
64cp /var/log/Xorg.0.log $TMPDIR/Xorg.0.log.3.after.intel
65
66cp $0 $TMPDIR/
67
68tar czf $TMPDIR.tar.gz $TMPDIR/*
69if [ -f $TMPDIR.tar.gz ]; then
70	echo $TMPDIR.tar.gz contains this script, all configs and logs generated on this tests
71fi
72
73exit 0
74