Browse code

Remove dependency on 'os/user', which cannot be used with CGO_ENABLED=0. This allows running the tests without CGO.

Solomon Hykes authored on 2013/06/22 11:40:42
Showing 1 changed files
... ...
@@ -8,10 +8,10 @@ import (
8 8
 	"log"
9 9
 	"net"
10 10
 	"os"
11
-	"os/user"
12 11
 	"strconv"
13 12
 	"strings"
14 13
 	"sync"
14
+	"syscall"
15 15
 	"testing"
16 16
 	"time"
17 17
 )
... ...
@@ -49,10 +49,8 @@ func init() {
49 49
 		return
50 50
 	}
51 51
 
52
-	if usr, err := user.Current(); err != nil {
53
-		panic(err)
54
-	} else if usr.Uid != "0" {
55
-		panic("docker tests needs to be run as root")
52
+	if uid := syscall.Geteuid(); uid != 0 {
53
+		log.Fatal("docker tests needs to be run as root")
56 54
 	}
57 55
 
58 56
 	NetworkBridgeIface = "testdockbr0"