Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ppc64le specific fixes for tests "expression/builtin_math_test.go" and "store/tikv/lock_test.go" #3477

Merged
merged 9 commits into from
Jun 19, 2017
9 changes: 7 additions & 2 deletions expression/builtin_math_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package expression
import (
"math"
"math/rand"
"runtime"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/ast"
Expand Down Expand Up @@ -79,7 +80,7 @@ func (s *testEvaluatorSuite) TestCeil(c *C) {

func (s *testEvaluatorSuite) TestExp(c *C) {
defer testleak.AfterTest(c)()
for _, t := range []struct {
testcases := []struct {
num interface{}
ret interface{}
err Checker
Expand All @@ -95,7 +96,11 @@ func (s *testEvaluatorSuite) TestExp(c *C) {
{nil, nil, IsNil},
{"abce", nil, NotNil},
{"", nil, NotNil},
} {
}
for _, t := range testcases {
if runtime.GOARCH == "ppc64le" && t.num == int64(1) {
t.ret = float64(2.7182818284590455)
}
fc := funcs[ast.Exp]
f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx)
c.Assert(err, IsNil)
Expand Down
10 changes: 9 additions & 1 deletion store/tikv/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package tikv

import (
"math"
"runtime"
"time"

. "github.com/pingcap/check"
Expand Down Expand Up @@ -210,7 +211,14 @@ func (s *testLockSuite) mustGetLock(c *C, key []byte) *Lock {
}

func (s *testLockSuite) ttlEquals(c *C, x, y uint64) {
c.Assert(int(math.Abs(float64(x-y))), LessEqual, 2)
// NOTE: On ppc64le, all integers are by default unsigned integers,
// hence we have to seperately cast the value returned by "math.Abs()" function for ppc64le.
if runtime.GOARCH == "ppc64le" {
c.Assert(int(-math.Abs(float64(x-y))), LessEqual, 2)
} else {
c.Assert(int(math.Abs(float64(x-y))), LessEqual, 2)
}

}

func (s *testLockSuite) TestLockTTL(c *C) {
Expand Down