This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree 2 files changed +17
-7
lines changed
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package rpc
17
17
import (
18
18
"io/ioutil"
19
19
"os"
20
+ "syscall"
20
21
"testing"
21
22
22
23
etcd "github.com/coreos/etcd/client"
@@ -89,19 +90,21 @@ func TestRegistryMuxUnitManagement(t *testing.T) {
89
90
}
90
91
defer os .RemoveAll (uDir )
91
92
93
+ if syscall .Geteuid () != 0 {
94
+ t .Skipf ("non-root user cannot call systemd unit manager. skip." )
95
+ }
96
+ if info , err := os .Stat ("/run/systemd/system" ); err != nil || ! info .IsDir () {
97
+ t .Skipf ("systemd is not available. skip." )
98
+ }
99
+
92
100
state := & machine.MachineState {
93
101
ID : "id" ,
94
102
PublicIP : "127.0.0.1" ,
95
103
Metadata : make (map [string ]string , 0 ),
96
104
}
97
105
mgr , err := systemd .NewSystemdUnitManager (uDir , false )
98
106
if err != nil {
99
- // NOTE: ideally we should fail with t.Fatalf(), but then it would always
100
- // fail on travis CI, because apparently systemd dbus socket is not
101
- // available there. So let's just skip the test for now.
102
- // In the long run, we should find a way to test it correctly on travis.
103
- // - dpark 20160812
104
- t .Skipf ("unexpected error creating systemd unit manager: %v" , err )
107
+ t .Fatalf ("unexpected error creating systemd unit manager: %v" , err )
105
108
}
106
109
107
110
mach := machine .NewCoreOSMachine (* state , mgr )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
"io/ioutil"
20
20
"net"
21
21
"os"
22
+ "runtime"
22
23
"strconv"
23
24
"syscall"
24
25
"testing"
@@ -165,7 +166,13 @@ func TestWrongHostKeyFile(t *testing.T) {
165
166
// If run as root, drop privileges temporarily
166
167
if id := syscall .Geteuid (); id == 0 {
167
168
if err := syscall .Setuid (12345 ); err != nil {
168
- t .Fatalf ("error setting uid: %v" , err )
169
+ if runtime .GOOS == "linux" {
170
+ // On Linux syscall.Setuid is not supported, so we should not fail
171
+ // the test, but just skip for now. - dpark 20161021
172
+ t .Skipf ("error setting uid: %v" , err )
173
+ } else {
174
+ t .Fatalf ("error setting uid: %v" , err )
175
+ }
169
176
}
170
177
defer syscall .Setuid (id )
171
178
}
You can’t perform that action at this time.
0 commit comments