Skip to content

Commit

Permalink
VersionString() API selftest
Browse files Browse the repository at this point in the history
Signed-off-by: grantseltzer <grantseltzer@gmail.com>
  • Loading branch information
grantseltzer committed Mar 16, 2022
1 parent 5aa6aaa commit d992a04
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions selftest/version/Makefile
7 changes: 7 additions & 0 deletions selftest/version/go.mod
@@ -0,0 +1,7 @@
module github.com/aquasecurity/libbpfgo/selftest/perfbuffers

go 1.16

require github.com/aquasecurity/libbpfgo v0.2.1-libbpf-0.4.0

replace github.com/aquasecurity/libbpfgo => ../../
11 changes: 11 additions & 0 deletions selftest/version/go.sum
@@ -0,0 +1,11 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6 changes: 6 additions & 0 deletions selftest/version/main.bpf.c
@@ -0,0 +1,6 @@
//+build ignore
#ifdef asm_inline
#undef asm_inline
#define asm_inline asm
#endif

28 changes: 28 additions & 0 deletions selftest/version/main.go
@@ -0,0 +1,28 @@
package main

import "C"

import (
"log"
"os/exec"
"strings"

"github.com/aquasecurity/libbpfgo"
)

func main() {

cmd := exec.Command("git", "describe", "--tags")
cmd.Dir = "../../libbpf"

b, err := cmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}

// libbpf doesn't put the patch version in exported version
// symbols, so use just prefix to exclude it
if strings.HasPrefix(libbpfgo.VersionString(), string(b)) {
log.Fatalf("Error reading exported symbols for libbpf major and minor version: %s is not %s", libbpfgo.VersionString(), b)
}
}
1 change: 1 addition & 0 deletions selftest/version/run.sh

0 comments on commit d992a04

Please sign in to comment.