diff --git a/tests/hghave.py b/tests/hghave.py
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvaGdoYXZlLnB5..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvaGdoYXZlLnB5 100755
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -233,6 +233,9 @@
     finally:
         os.rmdir(d)
 
+def has_root():
+    return os.geteuid() == 0
+
 def has_pyflakes():
     return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
                        r"<stdin>:1: 're' imported but unused",
@@ -312,6 +315,7 @@
     "p4": (has_p4, "Perforce server and client"),
     "pyflakes": (has_pyflakes, "Pyflakes python linter"),
     "pygments": (has_pygments, "Pygments source highlighting library"),
+    "root": (has_root, "root permissions"),
     "serve": (has_serve, "platform and python can manage 'hg serve -d'"),
     "ssl": (has_ssl, "python >= 2.6 ssl module and python OpenSSL"),
     "svn": (has_svn, "subversion client and admin tools"),
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1ibGFja2JveC50..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1ibGFja2JveC50 100644
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -65,7 +65,7 @@
   $ hg rollback
   repository tip rolled back to revision 1 (undo pull)
 
-#if unix-permissions
+#if unix-permissions no-root
   $ chmod 000 .hg/blackbox.log
   $ hg --debug incoming
   warning: cannot write to blackbox.log: Permission denied
@@ -98,7 +98,7 @@
   (run 'hg update' to get a working copy)
 
 a failure reading from the log is fine
-#if unix-permissions
+#if unix-permissions no-root
   $ hg blackbox -l 3
   abort: Permission denied: $TESTTMP/blackboxtest2/.hg/blackbox.log
   [255]
diff --git a/tests/test-clone.t b/tests/test-clone.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1jbG9uZS50..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1jbG9uZS50 100644
--- a/tests/test-clone.t
+++ b/tests/test-clone.t
@@ -543,7 +543,7 @@
   $ rm -rf b # work around bug with http clone
 
 
-#if unix-permissions
+#if unix-permissions no-root
 
 Inaccessible source
 
@@ -596,7 +596,7 @@
   [255]
 
 
-#if unix-permissions
+#if unix-permissions no-root
 
 leave existing directory in place after clone failure
 
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1jb21tYW5kLXRlbXBsYXRlLnQ=..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1jb21tYW5kLXRlbXBsYXRlLnQ= 100644
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -447,7 +447,7 @@
 
 Error if style not readable:
 
-#if unix-permissions
+#if unix-permissions no-root
   $ touch q
   $ chmod 0 q
   $ hg log --style ./q
@@ -479,7 +479,7 @@
 Error if include fails:
 
   $ echo 'changeset = q' >> t
-#if unix-permissions
+#if unix-permissions no-root
   $ hg log --style ./t
   abort: template file ./q: Permission denied
   [255]
diff --git a/tests/test-convert.t b/tests/test-convert.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1jb252ZXJ0LnQ=..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1jb252ZXJ0LnQ= 100644
--- a/tests/test-convert.t
+++ b/tests/test-convert.t
@@ -310,7 +310,7 @@
   abort: cannot create new bundle repository
   [255]
 
-#if unix-permissions
+#if unix-permissions no-root
 
 conversion to dir without permissions should fail
 
diff --git a/tests/test-journal-exists.t b/tests/test-journal-exists.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1qb3VybmFsLWV4aXN0cy50..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1qb3VybmFsLWV4aXN0cy50 100644
--- a/tests/test-journal-exists.t
+++ b/tests/test-journal-exists.t
@@ -22,7 +22,7 @@
 
 Check that zero-size journals are correctly aborted:
 
-#if unix-permissions
+#if unix-permissions no-root
   $ hg bundle -qa repo.hg
   $ chmod -w foo/.hg/store/00changelog.i
 
diff --git a/tests/test-lock-badness.t b/tests/test-lock-badness.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1sb2NrLWJhZG5lc3MudA==..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1sb2NrLWJhZG5lc3MudA== 100644
--- a/tests/test-lock-badness.t
+++ b/tests/test-lock-badness.t
@@ -1,5 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
-
+#if unix-permissions no-root
   $ hg init a
   $ echo a > a/a
   $ hg -R a ci -A -m a
@@ -21,4 +20,4 @@
   [255]
 
   $ chmod 700 a/.hg/store
-
+#endif
diff --git a/tests/test-permissions.t b/tests/test-permissions.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1wZXJtaXNzaW9ucy50..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1wZXJtaXNzaW9ucy50 100644
--- a/tests/test-permissions.t
+++ b/tests/test-permissions.t
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#ifdef unix-permissions no-root
 
   $ hg init t
   $ cd t
@@ -70,3 +70,5 @@
   $ chmod +rx dir
 
   $ cd ..
+
+#endif
diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1waGFzZXMtZXhjaGFuZ2UudA==..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1waGFzZXMtZXhjaGFuZ2UudA== 100644
--- a/tests/test-phases-exchange.t
+++ b/tests/test-phases-exchange.t
@@ -1062,7 +1062,7 @@
   |
   o  0 public a-A - 054250a37db4
   
-#if unix-permissions
+#if unix-permissions no-root
 
 Pushing From an unlockable repo
 --------------------------------
diff --git a/tests/test-pull-permission.t b/tests/test-pull-permission.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1wdWxsLXBlcm1pc3Npb24udA==..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1wdWxsLXBlcm1pc3Npb24udA== 100644
--- a/tests/test-pull-permission.t
+++ b/tests/test-pull-permission.t
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#if unix-permissions no-root
 
   $ hg init a
   $ cd a
@@ -30,3 +30,5 @@
   1 files, 1 changesets, 1 total revisions
 
   $ cd ..
+
+#endif
diff --git a/tests/test-repair-strip.t b/tests/test-repair-strip.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1yZXBhaXItc3RyaXAudA==..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1yZXBhaXItc3RyaXAudA== 100644
--- a/tests/test-repair-strip.t
+++ b/tests/test-repair-strip.t
@@ -1,4 +1,4 @@
-  $ "$TESTDIR/hghave" unix-permissions || exit 80
+#if unix-permissions no-root
 
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "mq=">> $HGRCPATH
@@ -130,3 +130,5 @@
   2 files, 2 changesets, 2 total revisions
 
   $ cd ..
+
+#endif
diff --git a/tests/test-serve.t b/tests/test-serve.t
index 23edc6673f0d8dc2dafbb00a59243ba4de306bf4_dGVzdHMvdGVzdC1zZXJ2ZS50..e54a078153f79d9065b79a7ff5b20524ff850cec_dGVzdHMvdGVzdC1zZXJ2ZS50 100644
--- a/tests/test-serve.t
+++ b/tests/test-serve.t
@@ -45,9 +45,10 @@
 
 With -v and -p daytime (should fail because low port)
 
+#if no-root
   $ KILLQUIETLY=Y
   $ hgserve -p daytime
   abort: cannot start server at 'localhost:13': Permission denied
   abort: child process failed to start
   % errors
   $ KILLQUIETLY=N
@@ -48,9 +49,10 @@
   $ KILLQUIETLY=Y
   $ hgserve -p daytime
   abort: cannot start server at 'localhost:13': Permission denied
   abort: child process failed to start
   % errors
   $ KILLQUIETLY=N
+#endif
 
 With --prefix foo