aboutsummaryrefslogtreecommitdiff
path: root/pkg/systemd/activation_test.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-06-25 03:27:44 -0400
committerGitHub <noreply@github.com>2021-06-25 03:27:44 -0400
commit2d191968b513d327e39376bf8fadd2b4267d15a2 (patch)
tree8ab45b2d9486444a703dfc94bd891176a757ba4b /pkg/systemd/activation_test.go
parent8c7ce94b813014d8abb0a96b72db78d20cdaae18 (diff)
parent364e8a26da2d49c3ea06cc9c0470e47925dcd192 (diff)
downloadpodman-2d191968b513d327e39376bf8fadd2b4267d15a2.tar.gz
podman-2d191968b513d327e39376bf8fadd2b4267d15a2.tar.bz2
podman-2d191968b513d327e39376bf8fadd2b4267d15a2.zip
Merge pull request #10416 from tych0/activation-drop-FDNAMES
pkg/systemd: don't require LISTEN_FDNAMES for socket activation
Diffstat (limited to 'pkg/systemd/activation_test.go')
-rw-r--r--pkg/systemd/activation_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/systemd/activation_test.go b/pkg/systemd/activation_test.go
new file mode 100644
index 000000000..d2553777b
--- /dev/null
+++ b/pkg/systemd/activation_test.go
@@ -0,0 +1,32 @@
+package systemd
+
+import (
+ "fmt"
+ "os"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSocketActivated(t *testing.T) {
+ assert := assert.New(t)
+
+ assert.False(SocketActivated())
+
+ // different pid
+ assert.NoError(os.Setenv("LISTEN_PID", "1"))
+ assert.False(SocketActivated())
+
+ // same pid no fds
+ assert.NoError(os.Setenv("LISTEN_PID", fmt.Sprintf("%d", os.Getpid())))
+ assert.NoError(os.Setenv("LISTEN_FDS", "0"))
+ assert.False(SocketActivated())
+
+ // same pid some fds
+ assert.NoError(os.Setenv("LISTEN_FDS", "1"))
+ assert.True(SocketActivated())
+
+ // FDNAME is ok too (but not required)
+ assert.NoError(os.Setenv("LISTEN_FDNAMES", "/meshuggah/rocks"))
+ assert.True(SocketActivated())
+}