unit-test: Support running as non-root

This is nice to have so that all of the generated files in our workspace
are owned by our user so we don't have to deal with ownership issues
after the build has completed.

Tested:
    Built all of the openbmc packages locally and found no regressions.

Change-Id: I0811ac4e356a023a1238e291f8184dfe01eb003e
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index e6c1661..f086b94 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -309,7 +309,7 @@
     check_call_cmd(pkgdir, './bootstrap.sh')
     check_call_cmd(pkgdir, './configure', *conf_flags)
     check_call_cmd(pkgdir, *make_parallel)
-    check_call_cmd(pkgdir, *(make_parallel + [ 'install' ]))
+    check_call_cmd(pkgdir, 'sudo', '-n', '--', *(make_parallel + [ 'install' ]))
 
 def install_deps(dep_list):
     """
@@ -339,7 +339,7 @@
         dep_tree = head
     os.chdir(pkgdir)
     # Open package's configure.ac
-    with open("/root/.depcache", "r") as depcache:
+    with open("/tmp/depcache", "r") as depcache:
         cached = depcache.readline()
     with open("configure.ac", "rt") as configure_ac:
         # Retrieve dependency list from package's configure.ac
@@ -560,7 +560,7 @@
         top_dir = os.path.join(WORKSPACE, UNIT_TEST_PKG)
         os.chdir(top_dir)
         # Refresh dynamic linker run time bindings for dependencies
-        check_call_cmd(top_dir, 'ldconfig')
+        check_call_cmd(top_dir, 'sudo', '-n', '--', 'ldconfig')
         # Run package unit tests
         run_unit_tests(top_dir)
         maybe_run_valgrind(top_dir)