Revision 9831d981fc90760e810066f2f7d67bd2dc9e6b1c authored by Daniel Borkmann on 18 November 2020, 15:46:58 UTC, committed by Daniel Borkmann on 20 November 2020, 10:28:57 UTC
Example invocation:

  ./daemon/cilium-agent --enable-ipv4=true --enable-ipv6=true \
      --datapath-mode=lb-only --bpf-lb-algorithm=maglev       \
      --bpf-lb-maglev-table-size=65521 --bpf-lb-mode=dsr      \
      --bpf-lb-acceleration=native --bpf-lb-dsr-dispatch=ipip \
      --devices=enp2s0np0

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 03f14fe
Raw File
int_test.go
// Copyright 2019 Authors of Cilium
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// +build !privileged_tests

package math

import (
	"testing"

	"gopkg.in/check.v1"
)

func Test(t *testing.T) {
	check.TestingT(t)
}

type MathSuite struct{}

var _ = check.Suite(&MathSuite{})

const (
	maxIntValue = int(^uint(0) >> 1)
	minIntValue = -maxIntValue - 1
)

func (b *MathSuite) TestIntMin(c *check.C) {
	c.Assert(IntMin(10, 20), check.Equals, 10)
	c.Assert(IntMin(20, 10), check.Equals, 10)
	c.Assert(IntMin(10, 10), check.Equals, 10)
	c.Assert(IntMin(-10, 10), check.Equals, -10)
	c.Assert(IntMin(0, 10), check.Equals, 0)
	c.Assert(IntMin(minIntValue, maxIntValue), check.Equals, minIntValue)
}

func (b *MathSuite) TestIntMax(c *check.C) {
	c.Assert(IntMax(10, 20), check.Equals, 20)
	c.Assert(IntMax(20, 10), check.Equals, 20)
	c.Assert(IntMax(10, 10), check.Equals, 10)
	c.Assert(IntMax(-10, 10), check.Equals, 10)
	c.Assert(IntMax(0, 10), check.Equals, 10)
	c.Assert(IntMax(minIntValue, maxIntValue), check.Equals, maxIntValue)
}
back to top