From 0def9d5c02166b50a011b4cc8d4c1d891a04f89d Mon Sep 17 00:00:00 2001 From: Sebastian Nickolls Date: Thu, 25 Apr 2024 17:19:20 +0100 Subject: [PATCH] cmd/internal/obj/arm64: Enable arm64 assembler tests for cross-compiler builds Some of the tests for the arm64 assembler are not running for cross-compiled arm64 builds with GOARCH=arm64. This patch allows the tests to run for all architectures and moves the test that can only run on arm64 into its own conditionally compiled file. Updates #44734 Change-Id: I045870d47cdc1280bfacc1ef275f34504278ed89 Reviewed-on: https://go-review.googlesource.com/c/go/+/587315 Reviewed-by: Cherry Mui LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Sebastian Nickolls --- src/cmd/internal/obj/arm64/asm_arm64_test.go | 297 +------------------ src/cmd/internal/obj/arm64/asm_test.go | 258 ++++++++++++++++ 2 files changed, 259 insertions(+), 296 deletions(-) create mode 100644 src/cmd/internal/obj/arm64/asm_test.go diff --git a/src/cmd/internal/obj/arm64/asm_arm64_test.go b/src/cmd/internal/obj/arm64/asm_arm64_test.go index 068039496a2..83d137a0846 100644 --- a/src/cmd/internal/obj/arm64/asm_arm64_test.go +++ b/src/cmd/internal/obj/arm64/asm_arm64_test.go @@ -4,302 +4,7 @@ package arm64 -import ( - "bytes" - "fmt" - "internal/testenv" - "os" - "path/filepath" - "regexp" - "testing" -) - -func TestSplitImm24uScaled(t *testing.T) { - tests := []struct { - v int32 - shift int - wantErr bool - wantHi int32 - wantLo int32 - }{ - { - v: 0, - shift: 0, - wantHi: 0, - wantLo: 0, - }, - { - v: 0x1001, - shift: 0, - wantHi: 0x1000, - wantLo: 0x1, - }, - { - v: 0xffffff, - shift: 0, - wantHi: 0xfff000, - wantLo: 0xfff, - }, - { - v: 0xffffff, - shift: 1, - wantErr: true, - }, - { - v: 0xfe, - shift: 1, - wantHi: 0x0, - wantLo: 0x7f, - }, - { - v: 0x10fe, - shift: 1, - wantHi: 0x0, - wantLo: 0x87f, - }, - { - v: 0x2002, - shift: 1, - wantHi: 0x2000, - wantLo: 0x1, - }, - { - v: 0xfffffe, - shift: 1, - wantHi: 0xffe000, - wantLo: 0xfff, - }, - { - v: 0x1000ffe, - shift: 1, - wantHi: 0xfff000, - wantLo: 0xfff, - }, - { - v: 0x1001000, - shift: 1, - wantErr: true, - }, - { - v: 0xfffffe, - shift: 2, - wantErr: true, - }, - { - v: 0x4004, - shift: 2, - wantHi: 0x4000, - wantLo: 0x1, - }, - { - v: 0xfffffc, - shift: 2, - wantHi: 0xffc000, - wantLo: 0xfff, - }, - { - v: 0x1002ffc, - shift: 2, - wantHi: 0xfff000, - wantLo: 0xfff, - }, - { - v: 0x1003000, - shift: 2, - wantErr: true, - }, - { - v: 0xfffffe, - shift: 3, - wantErr: true, - }, - { - v: 0x8008, - shift: 3, - wantHi: 0x8000, - wantLo: 0x1, - }, - { - v: 0xfffff8, - shift: 3, - wantHi: 0xff8000, - wantLo: 0xfff, - }, - { - v: 0x1006ff8, - shift: 3, - wantHi: 0xfff000, - wantLo: 0xfff, - }, - { - v: 0x1007000, - shift: 3, - wantErr: true, - }, - } - for _, test := range tests { - hi, lo, err := splitImm24uScaled(test.v, test.shift) - switch { - case err == nil && test.wantErr: - t.Errorf("splitImm24uScaled(%v, %v) succeeded, want error", test.v, test.shift) - case err != nil && !test.wantErr: - t.Errorf("splitImm24uScaled(%v, %v) failed: %v", test.v, test.shift, err) - case !test.wantErr: - if got, want := hi, test.wantHi; got != want { - t.Errorf("splitImm24uScaled(%x, %x) - got hi %x, want %x", test.v, test.shift, got, want) - } - if got, want := lo, test.wantLo; got != want { - t.Errorf("splitImm24uScaled(%x, %x) - got lo %x, want %x", test.v, test.shift, got, want) - } - } - } - for shift := 0; shift <= 3; shift++ { - for v := int32(0); v < 0xfff000+0xfff<