#!/bin/sh

# basic tests for X

export PATH=$PATH:/usr/X11R6/bin
export DISPLAY=:0

test_command () {
	if whence $1 >/dev/null 2>&1
	then
		if eval "$@" >/dev/null 2>&1
		then
			mt_success "test of $1 succeeds"
		else
			mt_failed "test of $1 fails, exit status = $?"
		fi
	else
		mt_message "this test needs $1, ignoring this test"
	fi
}

time=10
pass=0
while [ $time -gt 0 ]
do
	if [ -S /tmp/.X11-unix/X0 ]
	then
		pass=1
		time=0
	else
		time=$(($time - 1))
		sleep 1
	fi
done

if [ $pass -eq 1 ]
then
	mt_success "X unix domain socket found"
else
	mt_failed "X unix domain socket missing"
fi

test_command xterm -e /bin/sh -c :
test_command xmodmap -pm
test_command xrdb -query
test_command xsetroot -solid gray
test_command xset b on
