From df0cdfbaac74408a74126cbdbcd76dbf1ac1c39a Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Wed, 14 Jun 2017 16:20:11 +0530 Subject: [PATCH 1/6] Adding ppc64le specific fixes for tests "expression/builtin_math_test.go" and "store/tikv/lock_test.go" --- expression/builtin_math_test.go | 30 ++++++++++++++++++++++++++++-- store/tikv/lock_test.go | 11 +++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index 0d6a28a8b64df..9ff46569a24f8 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -16,7 +16,7 @@ package expression import ( "math" "math/rand" - + "runtime" . "github.com/pingcap/check" "github.com/pingcap/tidb/ast" "github.com/pingcap/tidb/mysql" @@ -79,6 +79,7 @@ func (s *testEvaluatorSuite) TestCeil(c *C) { func (s *testEvaluatorSuite) TestExp(c *C) { defer testleak.AfterTest(c)() + if runtime.GOARCH == "ppc64le" { for _, t := range []struct { num interface{} ret interface{} @@ -102,7 +103,32 @@ func (s *testEvaluatorSuite) TestExp(c *C) { v, err := f.eval(nil) c.Assert(err, t.err) c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - } + }}else{ + for _, t := range []struct { + num interface{} + ret interface{} + err Checker + }{ + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {nil, nil, IsNil}, + {"abce", nil, NotNil}, + {"", nil, NotNil}, + } { + fc := funcs[ast.Exp] + f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) + c.Assert(err, IsNil) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + }} + } func (s *testEvaluatorSuite) TestFloor(c *C) { diff --git a/store/tikv/lock_test.go b/store/tikv/lock_test.go index 8c85b1ab012a1..6503f442c86ad 100644 --- a/store/tikv/lock_test.go +++ b/store/tikv/lock_test.go @@ -16,7 +16,7 @@ package tikv import ( "math" "time" - + "runtime" . "github.com/pingcap/check" "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/tidb/kv" @@ -210,7 +210,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) { From c52847778723287d633564317e699f5dc0e6a998 Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Wed, 14 Jun 2017 18:15:36 +0530 Subject: [PATCH 2/6] Create builtin_math_test.go --- expression/builtin_math_test.go | 94 ++++++++++++++++----------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index 9ff46569a24f8..4fb8a5c65e926 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -80,54 +80,54 @@ func (s *testEvaluatorSuite) TestCeil(c *C) { func (s *testEvaluatorSuite) TestExp(c *C) { defer testleak.AfterTest(c)() if runtime.GOARCH == "ppc64le" { - for _, t := range []struct { - num interface{} - ret interface{} - err Checker - }{ - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {nil, nil, IsNil}, - {"abce", nil, NotNil}, - {"", nil, NotNil}, - } { - fc := funcs[ast.Exp] - f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) - c.Assert(err, IsNil) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - }}else{ for _, t := range []struct { - num interface{} - ret interface{} - err Checker - }{ - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {nil, nil, IsNil}, - {"abce", nil, NotNil}, - {"", nil, NotNil}, - } { - fc := funcs[ast.Exp] - f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) - c.Assert(err, IsNil) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - }} + num interface{} + ret interface{} + err Checker + }{ + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {nil, nil, IsNil}, + {"abce", nil, NotNil}, + {"", nil, NotNil}, + } { + fc := funcs[ast.Exp] + f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) + c.Assert(err, IsNil) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + } } else { + for _, t := range []struct { + num interface{} + ret interface{} + err Checker + }{ + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {nil, nil, IsNil}, + {"abce", nil, NotNil}, + {"", nil, NotNil}, + } { + fc := funcs[ast.Exp] + f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) + c.Assert(err, IsNil) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + }} } From 005b3d8fba218ed0aff1e739f15976516678cabd Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Wed, 14 Jun 2017 18:34:23 +0530 Subject: [PATCH 3/6] Create builtin_math_test.go --- expression/builtin_math_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index 4fb8a5c65e926..f47a2fe35e32c 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -17,6 +17,7 @@ import ( "math" "math/rand" "runtime" + . "github.com/pingcap/check" "github.com/pingcap/tidb/ast" "github.com/pingcap/tidb/mysql" From 7044ff15e1f8bb69b180458e0ad9390fe20cadbc Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Thu, 15 Jun 2017 11:39:11 +0530 Subject: [PATCH 4/6] ppc64le specific fixes --- expression/builtin_math_test.go | 54 +++++++++++++++++---------------- store/tikv/lock_test.go | 20 ++++++------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index f47a2fe35e32c..402a4c5f08e01 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -17,7 +17,7 @@ import ( "math" "math/rand" "runtime" - + . "github.com/pingcap/check" "github.com/pingcap/tidb/ast" "github.com/pingcap/tidb/mysql" @@ -104,31 +104,33 @@ func (s *testEvaluatorSuite) TestExp(c *C) { v, err := f.eval(nil) c.Assert(err, t.err) c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - } } else { - for _, t := range []struct { - num interface{} - ret interface{} - err Checker - }{ - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {nil, nil, IsNil}, - {"abce", nil, NotNil}, - {"", nil, NotNil}, - } { - fc := funcs[ast.Exp] - f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) - c.Assert(err, IsNil) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - }} + } + } else { + for _, t := range []struct { + num interface{} + ret interface{} + err Checker + }{ + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {nil, nil, IsNil}, + {"abce", nil, NotNil}, + {"", nil, NotNil}, + } { + fc := funcs[ast.Exp] + f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) + c.Assert(err, IsNil) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + } + } } diff --git a/store/tikv/lock_test.go b/store/tikv/lock_test.go index 6503f442c86ad..8ab142f4c3923 100644 --- a/store/tikv/lock_test.go +++ b/store/tikv/lock_test.go @@ -14,14 +14,14 @@ package tikv import ( - "math" - "time" - "runtime" . "github.com/pingcap/check" "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/tikv/tikvrpc" goctx "golang.org/x/net/context" + "math" + "runtime" + "time" ) type testLockSuite struct { @@ -210,13 +210,13 @@ func (s *testLockSuite) mustGetLock(c *C, key []byte) *Lock { } func (s *testLockSuite) ttlEquals(c *C, x, y uint64) { -// 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) - } + // 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) + } } From fa1ef9e3e4b24b3a3618dce17e56d0fe42bdb705 Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Thu, 15 Jun 2017 16:38:19 +0530 Subject: [PATCH 5/6] ppc64le specific fixes --- expression/builtin_math_test.go | 83 ++++++++++++--------------------- store/tikv/lock_test.go | 7 +-- 2 files changed, 34 insertions(+), 56 deletions(-) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index 402a4c5f08e01..6148b5908d4e1 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -79,61 +79,38 @@ func (s *testEvaluatorSuite) TestCeil(c *C) { } func (s *testEvaluatorSuite) TestExp(c *C) { - defer testleak.AfterTest(c)() - if runtime.GOARCH == "ppc64le" { - for _, t := range []struct { - num interface{} - ret interface{} - err Checker - }{ - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {nil, nil, IsNil}, - {"abce", nil, NotNil}, - {"", nil, NotNil}, - } { - fc := funcs[ast.Exp] - f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) - c.Assert(err, IsNil) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - } - } else { - for _, t := range []struct { - num interface{} - ret interface{} - err Checker - }{ - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {nil, nil, IsNil}, - {"abce", nil, NotNil}, - {"", nil, NotNil}, - } { - fc := funcs[ast.Exp] - f, err := fc.getFunction(datumsToConstants(types.MakeDatums(t.num)), s.ctx) - c.Assert(err, IsNil) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - } - } - + defer testleak.AfterTest(c)() + testcases := []struct { + num interface{} + ret interface{} + err Checker + } { + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {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) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + } } + func (s *testEvaluatorSuite) TestFloor(c *C) { defer testleak.AfterTest(c)() diff --git a/store/tikv/lock_test.go b/store/tikv/lock_test.go index 8ab142f4c3923..5e55a1f2df189 100644 --- a/store/tikv/lock_test.go +++ b/store/tikv/lock_test.go @@ -14,14 +14,15 @@ package tikv import ( + "math" + "runtime" + "time" + . "github.com/pingcap/check" "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/tikv/tikvrpc" goctx "golang.org/x/net/context" - "math" - "runtime" - "time" ) type testLockSuite struct { From c18161d751973f2e8225f472955b61cafbbe9f40 Mon Sep 17 00:00:00 2001 From: YugandhaD Date: Thu, 15 Jun 2017 16:49:36 +0530 Subject: [PATCH 6/6] ppc64le specific fixes --- expression/builtin_math_test.go | 59 ++++++++++++++++----------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/expression/builtin_math_test.go b/expression/builtin_math_test.go index 6148b5908d4e1..612c938eb6984 100644 --- a/expression/builtin_math_test.go +++ b/expression/builtin_math_test.go @@ -79,38 +79,37 @@ func (s *testEvaluatorSuite) TestCeil(c *C) { } func (s *testEvaluatorSuite) TestExp(c *C) { - defer testleak.AfterTest(c)() - testcases := []struct { - num interface{} - ret interface{} - err Checker - } { - {int64(1), float64(2.718281828459045), IsNil}, - {float64(1.23), float64(3.4212295362896734), IsNil}, - {float64(-1.23), float64(0.2922925776808594), IsNil}, - {float64(-1), float64(0.36787944117144233), IsNil}, - {float64(0), float64(1), IsNil}, - {"1.23", float64(3.4212295362896734), IsNil}, - {"-1.23", float64(0.2922925776808594), IsNil}, - {"0", float64(1), IsNil}, - {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) - v, err := f.eval(nil) - c.Assert(err, t.err) - c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) - } + defer testleak.AfterTest(c)() + testcases := []struct { + num interface{} + ret interface{} + err Checker + }{ + {int64(1), float64(2.718281828459045), IsNil}, + {float64(1.23), float64(3.4212295362896734), IsNil}, + {float64(-1.23), float64(0.2922925776808594), IsNil}, + {float64(-1), float64(0.36787944117144233), IsNil}, + {float64(0), float64(1), IsNil}, + {"1.23", float64(3.4212295362896734), IsNil}, + {"-1.23", float64(0.2922925776808594), IsNil}, + {"0", float64(1), IsNil}, + {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) + v, err := f.eval(nil) + c.Assert(err, t.err) + c.Assert(v, testutil.DatumEquals, types.NewDatum(t.ret)) + } } - func (s *testEvaluatorSuite) TestFloor(c *C) { defer testleak.AfterTest(c)()