Skip to content

Commit

Permalink
Test statically-linked ELF binary
Browse files Browse the repository at this point in the history
  • Loading branch information
kthomas committed Feb 6, 2024
1 parent 2984fd8 commit a7ca4f1
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions spec/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,30 +396,41 @@ var _ = Describe("nex node", func() {

Describe("deploying an ELF binary workload", func() {
var deployRequest *controlapi.DeployRequest
var err error

Context("when the ELF binary is not statically-linked", func() {
var err error
AfterEach(func() {
os.Remove("./echoservice")
})

AfterEach(func() {
os.Remove("./echoservice")
})
JustBeforeEach(func() {
deployRequest, err = newDeployRequest(*nodeID, "echoservice", "nex example echoservice", "./echoservice", map[string]string{"NATS_URL": "nats://127.0.0.1:4222"}, log)
Expect(err).To(BeNil())

nodeClient := controlapi.NewApiClientWithNamespace(_fixtures.natsConn, time.Millisecond*250, "default", log)
_, err = nodeClient.StartWorkload(deployRequest)
})

Context("when the ELF binary is not statically-linked", func() {
BeforeEach(func() {
cmd := exec.Command("go", "build", "../examples/echoservice")
_ = cmd.Start()
_ = cmd.Wait()
})

JustBeforeEach(func() {
deployRequest, err = newDeployRequest(*nodeID, "echoservice", "nex example echoservice", "./echoservice", map[string]string{"NATS_URL": "nats://127.0.0.1:4222"}, log)
Expect(err).To(BeNil())
It("should fail to deploy the ELF workload", func(ctx SpecContext) {
Expect(err.Error()).To(ContainSubstring("elf binary contains at least one dynamically linked dependency"))
})
})

nodeClient := controlapi.NewApiClientWithNamespace(_fixtures.natsConn, time.Millisecond*250, "default", log)
_, err = nodeClient.StartWorkload(deployRequest)
Context("when the ELF binary is statically-linked", func() {
BeforeEach(func() {
cmd := exec.Command("go", "build", "-tags", "netgo", "-ldflags", "-extldflags -static", "../examples/echoservice")
_ = cmd.Start()
_ = cmd.Wait()
})

It("should fail to deploy the ELF workload", func(ctx SpecContext) {
Expect(err.Error()).To(ContainSubstring("elf binary contains at least one dynamically linked dependency"))
It("should deploy the ELF workload", func(ctx SpecContext) {
Expect(err).To(BeNil())
})
})
})
Expand Down Expand Up @@ -531,3 +542,4 @@ func newDeployRequest(nodeID, name, desc, path string, env map[string]string, lo

return controlapi.NewDeployRequest(opts...)
}

0 comments on commit a7ca4f1

Please sign in to comment.