aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/seccomp
diff options
context:
space:
mode:
Diffstat (limited to 'container/seccomp')
-rw-r--r--container/seccomp/libseccomp.go3
-rw-r--r--container/seccomp/libseccomp_test.go9
-rw-r--r--container/seccomp/proc.go4
-rw-r--r--container/seccomp/seccomp_test.go6
-rw-r--r--container/seccomp/syscall_test.go10
5 files changed, 20 insertions, 12 deletions
diff --git a/container/seccomp/libseccomp.go b/container/seccomp/libseccomp.go
index c7a3b670..21236a06 100644
--- a/container/seccomp/libseccomp.go
+++ b/container/seccomp/libseccomp.go
@@ -117,7 +117,7 @@ func Export(fd int, rules []NativeRule, flags ExportFlag) error {
var ret C.int
- rulesPinner := new(runtime.Pinner)
+ var rulesPinner runtime.Pinner
for i := range rules {
rule := &rules[i]
rulesPinner.Pin(rule)
@@ -189,6 +189,5 @@ func syscallResolveName(s string) (trap int) {
v := C.CString(s)
trap = int(C.seccomp_syscall_resolve_name(v))
C.free(unsafe.Pointer(v))
-
return
}
diff --git a/container/seccomp/libseccomp_test.go b/container/seccomp/libseccomp_test.go
index 81f52511..d947105c 100644
--- a/container/seccomp/libseccomp_test.go
+++ b/container/seccomp/libseccomp_test.go
@@ -13,6 +13,8 @@ import (
)
func TestExport(t *testing.T) {
+ t.Parallel()
+
testCases := []struct {
name string
flags ExportFlag
@@ -32,14 +34,15 @@ func TestExport(t *testing.T) {
{"hakurei tty", 0, PresetExt | PresetDenyNS | PresetDenyDevel, false},
}
- buf := make([]byte, 8)
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+
e := New(Preset(tc.presets, tc.flags), tc.flags)
want := bpfExpected[bpfPreset{tc.flags, tc.presets}]
digest := sha512.New()
- if _, err := io.CopyBuffer(digest, e, buf); (err != nil) != tc.wantErr {
+ if _, err := io.Copy(digest, e); (err != nil) != tc.wantErr {
t.Errorf("Exporter: error = %v, wantErr %v", err, tc.wantErr)
return
}
@@ -47,7 +50,7 @@ func TestExport(t *testing.T) {
t.Errorf("Close: error = %v", err)
}
if got := digest.Sum(nil); !slices.Equal(got, want) {
- t.Fatalf("Export() hash = %x, want %x",
+ t.Fatalf("Export: hash = %x, want %x",
got, want)
return
}
diff --git a/container/seccomp/proc.go b/container/seccomp/proc.go
index 7027cc6b..fb6f5430 100644
--- a/container/seccomp/proc.go
+++ b/container/seccomp/proc.go
@@ -21,9 +21,7 @@ Methods of Encoder are not safe for concurrent use.
An Encoder must not be copied after first use.
*/
-type Encoder struct {
- *exporter
-}
+type Encoder struct{ *exporter }
func (e *Encoder) Read(p []byte) (n int, err error) {
if err = e.prepare(); err != nil {
diff --git a/container/seccomp/seccomp_test.go b/container/seccomp/seccomp_test.go
index a3dcad56..c19f2c49 100644
--- a/container/seccomp/seccomp_test.go
+++ b/container/seccomp/seccomp_test.go
@@ -10,6 +10,8 @@ import (
)
func TestLibraryError(t *testing.T) {
+ t.Parallel()
+
testCases := []struct {
name string
sample *seccomp.LibraryError
@@ -41,6 +43,8 @@ func TestLibraryError(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+
if errors.Is(tc.sample, tc.compare) != tc.wantIs {
t.Errorf("errors.Is(%#v, %#v) did not return %v",
tc.sample, tc.compare, tc.wantIs)
@@ -54,6 +58,8 @@ func TestLibraryError(t *testing.T) {
}
t.Run("invalid", func(t *testing.T) {
+ t.Parallel()
+
wantPanic := "invalid libseccomp error"
defer func() {
if r := recover(); r != wantPanic {
diff --git a/container/seccomp/syscall_test.go b/container/seccomp/syscall_test.go
index 933f060b..e385a12c 100644
--- a/container/seccomp/syscall_test.go
+++ b/container/seccomp/syscall_test.go
@@ -5,15 +5,17 @@ import (
)
func TestSyscallResolveName(t *testing.T) {
+ t.Parallel()
+
for name, want := range Syscalls() {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
+
if got := syscallResolveName(name); got != want {
- t.Errorf("syscallResolveName(%q) = %d, want %d",
- name, got, want)
+ t.Errorf("syscallResolveName(%q) = %d, want %d", name, got, want)
}
if got, ok := SyscallResolveName(name); !ok || got != want {
- t.Errorf("SyscallResolveName(%q) = %d, want %d",
- name, got, want)
+ t.Errorf("SyscallResolveName(%q) = %d, want %d", name, got, want)
}
})
}