mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Add package level And/Or calls to TopologyManager socketmask abstraction
This commit is contained in:
parent
434fd34e0b
commit
0edfd4be35
@ -171,3 +171,17 @@ func (s *socketMask) GetSockets() []int {
|
||||
}
|
||||
return sockets
|
||||
}
|
||||
|
||||
//And is a package level implementation of 'and' between first and masks
|
||||
func And(first SocketMask, masks ...SocketMask) SocketMask {
|
||||
s := *first.(*socketMask)
|
||||
s.And(masks...)
|
||||
return &s
|
||||
}
|
||||
|
||||
//Or is a package level implementation of 'or' between first and masks
|
||||
func Or(first SocketMask, masks ...SocketMask) SocketMask {
|
||||
s := *first.(*socketMask)
|
||||
s.Or(masks...)
|
||||
return &s
|
||||
}
|
||||
|
@ -106,6 +106,12 @@ func TestAnd(t *testing.T) {
|
||||
for _, tc := range tcases {
|
||||
firstMask, _ := NewSocketMask(tc.firstMaskBit)
|
||||
secondMask, _ := NewSocketMask(tc.secondMaskBit)
|
||||
|
||||
result := And(firstMask, secondMask)
|
||||
if result.String() != string(tc.andMask) {
|
||||
t.Errorf("Expected mask to be %v, got %v", tc.andMask, result)
|
||||
}
|
||||
|
||||
firstMask.And(secondMask)
|
||||
if firstMask.String() != string(tc.andMask) {
|
||||
t.Errorf("Expected mask to be %v, got %v", tc.andMask, firstMask)
|
||||
@ -130,6 +136,12 @@ func TestOr(t *testing.T) {
|
||||
for _, tc := range tcases {
|
||||
firstMask, _ := NewSocketMask(tc.firstMaskBit)
|
||||
secondMask, _ := NewSocketMask(tc.secondMaskBit)
|
||||
|
||||
result := Or(firstMask, secondMask)
|
||||
if result.String() != string(tc.orMask) {
|
||||
t.Errorf("Expected mask to be %v, got %v", tc.orMask, result)
|
||||
}
|
||||
|
||||
firstMask.Or(secondMask)
|
||||
if firstMask.String() != string(tc.orMask) {
|
||||
t.Errorf("Expected mask to be %v, got %v", tc.orMask, firstMask)
|
||||
|
Loading…
Reference in New Issue
Block a user