| 1 |
//go:build !linux |
| 2 |
|
| 3 |
package landlock_test |
| 4 |
|
| 5 |
import ( |
| 6 |
"strings" |
| 7 |
"testing" |
| 8 |
|
| 9 |
"github.com/landlock-lsm/go-landlock/landlock" |
| 10 |
) |
| 11 |
|
| 12 |
func TestRestrictNonLinux_BestEffort(t *testing.T) { |
| 13 |
err := landlock.V3.BestEffort().RestrictPaths( |
| 14 |
landlock.RODirs("/"), |
| 15 |
) |
| 16 |
if err != nil { |
| 17 |
t.Errorf("expected success (downgraded to doing nothing)") |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
func TestRestrictNonLinux_Strict(t *testing.T) { |
| 22 |
err := landlock.V3.RestrictPaths( |
| 23 |
landlock.RODirs("/"), |
| 24 |
) |
| 25 |
errStr := "missing kernel Landlock support" |
| 26 |
if !strings.Contains(err.Error(), errStr) { |
| 27 |
t.Errorf("expected error with %q, got %v", errStr, err) |
| 28 |
} |
| 29 |
} |