forked from syndtr/gocapability
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kolyshkin/cap-vers
Remove init(), CAP_LAST_CAP; add LastCap
- Loading branch information
Showing
4 changed files
with
89 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package capability | ||
|
||
import "testing" | ||
|
||
func TestLastCap(t *testing.T) { | ||
last, err := LastCap() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Sanity checks. | ||
// | ||
// Based on the fact Go 1.18+ supports Linux >= 2.6.32, and | ||
// - CAP_MAC_ADMIN (33) was added in 2.6.25; | ||
// - CAP_SYSLOG (34) was added in 2.6.38; | ||
// - CAP_CHECKPOINT_RESTORE (40) was added in 5.9, and it is | ||
// the last added capability as of today (July 2024); | ||
// LastCap return value should be between minCap and maxCap. | ||
minCap := CAP_MAC_ADMIN | ||
maxCap := CAP_CHECKPOINT_RESTORE | ||
if last < minCap { | ||
t.Fatalf("LastCap returned %d (%s), expected >= %d (%s)", | ||
last, last, minCap, minCap) | ||
} | ||
if last > maxCap { | ||
t.Fatalf("LastCap returned %d, expected <= %d (%s). Package needs to be updated.", | ||
last, maxCap, maxCap) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters