Skip to content

Commit 840c1e3

Browse files
committed
Merge remote-tracking branch 'origin/pr/38'
2 parents 4d64bf8 + 0297bc8 commit 840c1e3

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

HACKING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ will run tests in verbose mode.
1111
You need some external resources in order to run the tests, as described below:
1212

1313
1. A firecracker binary (tested with 0.10.1), but any recent version should
14-
work. Must either be installed as `./firecracker` or the path must be
15-
specified through the `FC_TEST_BIN` environment variable.
16-
2. Access to hardware virtualization via `/dev/kvm` and `/dev/vhost-vsock` (ensure you have mode
17-
`+rw`!)
14+
work. Must either be installed as `./testdata/firecracker` or the path must
15+
be specified through the `FC_TEST_BIN` environment variable.
16+
2. Access to hardware virtualization via `/dev/kvm` and `/dev/vhost-vsock`
17+
(ensure you have mode `+rw`!)
1818
3. An uncompressed Linux kernel binary that can boot in Firecracker VM (Must be
1919
installed as `./testdata/vmlinux`)
2020
4. A tap device owned by your userid (Must be either named `fc-test-tap0` or

machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func (m *Machine) StopVMM() error {
378378
}
379379

380380
func (m *Machine) stopVMM() error {
381-
if m.cmd != nil {
381+
if m.cmd != nil && m.cmd.Process != nil {
382382
log.Debug("stopVMM(): sending sigterm to firecracker")
383383
return m.cmd.Process.Signal(syscall.SIGTERM)
384384
}

machine_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ func TestMicroVMExecution(t *testing.T) {
118118

119119
vmmCtx, vmmCancel := context.WithTimeout(ctx, 30*time.Second)
120120
defer vmmCancel()
121-
var exitchannel <-chan error
121+
exitchannel := make(chan error)
122122
go func() {
123-
var err error
124-
exitchannel, err = m.startVMM(vmmCtx)
123+
exitCh, err := m.startVMM(vmmCtx)
125124
if err != nil {
125+
close(exitchannel)
126126
t.Fatalf("Failed to start VMM: %v", err)
127127
}
128+
exitchannel <- <-exitCh
129+
close(exitchannel)
128130
}()
129131
time.Sleep(2 * time.Second)
130132

@@ -139,7 +141,12 @@ func TestMicroVMExecution(t *testing.T) {
139141
t.Run("TestStartInstance", func(t *testing.T) { testStartInstance(vmmCtx, t, m) })
140142

141143
// Let the VMM start and stabilize...
142-
time.Sleep(5 * time.Second)
144+
timer := time.NewTimer(5 * time.Second)
145+
select {
146+
case <-timer.C:
147+
case <-exitchannel:
148+
// if we've already exited, there's no use waiting for the timer
149+
}
143150
t.Run("TestStopVMM", func(t *testing.T) { testStopVMM(ctx, t, m) })
144151
<-exitchannel
145152
}

0 commit comments

Comments
 (0)