libct/nsenter/nsenter_test.go: fix and improve#3158
libct/nsenter/nsenter_test.go: fix and improve#3158thaJeztah merged 5 commits intoopencontainers:masterfrom
Conversation
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
left some comments/questions, but don't think they're blockers
06d98dc to
de7ec14
Compare
|
Rebased; renamed |
|
@AkihiroSuda PTAL |
|
Had to rebase after #3144 merge. @thaJeztah @AkihiroSuda PTAL |
de7ec14 to
940d66d
Compare
libcontainer/nsenter/nsenter_test.go
Outdated
|
|
||
| if err := cmd.Start(); err != nil { | ||
| t.Fatalf("nsenter failed to start %v", err) | ||
| t.Fatal("nsenter failed to start:", err) |
There was a problem hiding this comment.
Why? The previous form seems completely legit.
There was a problem hiding this comment.
A semicolon was missing. While adding it, I guess I decided to simplify it, that's it.
There was a problem hiding this comment.
The other reason is, I was using the same form in the subsequent patches, so I added it here, too, for uniformity.
Nevermind though, I re-did this commit so it uses %v in this and similar cases, and moved the patch to be the last one.
PTAL @AkihiroSuda
1. Make sure we close all file descriptors at the end of the test. 2. Make sure we close child fds after the start. 3. Use newPipe for logs as well, for simplicity and uniformity. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
The test was not working since at least commit 64bb59f renamed pid to stage2_pid (or maybe even earlier), so the pid was never received (i.e. pid.Pid was 0). The problem was not caught because os.FindProcess never return an error on Unix. Factor out and fix pid decode function: - use DisallowUnknownInput to get error if JSON will be changed; - check pids to make sure they are valid - and use unix.Wait4 to reap zombies. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Instead of reading a single message, do read all the logs from the init, and use DisallowUnknownFields for stricter checking. While at it, use reapChildren to reap zombies (and add an extra check). Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
- add missing colons before error message; - unify error messages after cmd.Start and cmd.Wait, so that they show context and the error itself. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
940d66d to
33dcb99
Compare
Fix and improve nsenter_test.go (originally part of #3114).