seccomp_test.go 767 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //go:build linux
  2. package oci
  3. import (
  4. "encoding/json"
  5. "os"
  6. "testing"
  7. "github.com/docker/docker/profiles/seccomp"
  8. )
  9. func TestSeccompLoadProfile(t *testing.T) {
  10. profiles := []string{"default.json", "default-old-format.json", "example.json"}
  11. for _, p := range profiles {
  12. t.Run(p, func(t *testing.T) {
  13. f, err := os.ReadFile("fixtures/" + p)
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. rs := DefaultLinuxSpec()
  18. if _, err := seccomp.LoadProfile(string(f), &rs); err != nil {
  19. t.Fatal(err)
  20. }
  21. })
  22. }
  23. }
  24. func TestSeccompLoadDefaultProfile(t *testing.T) {
  25. b, err := json.Marshal(seccomp.DefaultProfile())
  26. if err != nil {
  27. t.Fatal(err)
  28. }
  29. rs := DefaultLinuxSpec()
  30. if _, err := seccomp.LoadProfile(string(b), &rs); err != nil {
  31. t.Fatal(err)
  32. }
  33. }