--- Makefile.am
+++ Makefile.am
@@ -2,4 +2,4 @@ bin_PROGRAMS = genext2fs
 genext2fs_SOURCES = genext2fs.c
 man_MANS = genext2fs.8
 EXTRA_DIST = $(man_MANS) test-gen.lib test-mount.sh test.sh device_table.txt
-TESTS = test.sh
+TESTS = test-mount.sh test.sh
--- test-gen.lib
+++ test-gen.lib
@@ -52,3 +52,14 @@ calc_digest () {
 	fi
 }
 
+if [ "x$NEED_ROOT" = "xyes" ] ; then
+	my_uid=`id -u`
+	if [ $? != 0 ] ; then
+		echo "Failed to run 'id -u'" 1>&2
+		exit 1
+	fi
+	if [ "x$my_uid" != "x0" ] ; then
+		echo "Skipping test as this requires root access"
+		exit 0
+	fi
+fi
--- test-mount.sh
+++ test-mount.sh
@@ -6,6 +6,7 @@
 
 set -e
 
+NEED_ROOT=yes
 . ./test-gen.lib
 
 test_cleanup () {
--- test.sh
+++ test.sh
@@ -11,6 +11,7 @@
 
 set -e
 
+NEED_ROOT=no
 . ./test-gen.lib
 
 # md5cmp - Calculate MD5 digest and compare it to an expected value.
