blob: 1f65c925d7390018fc51e2de375cda52e9b2e4d5 [file] [log] [blame]
// Copyright (C) 2016 The Android Open Source Project
//
// 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.
package device_test
import (
"testing"
"android.googlesource.com/platform/tools/gpu/framework/assert"
"android.googlesource.com/platform/tools/gpu/framework/device"
)
var abiTestData = []struct {
abi device.ABI
name string
width int
align int
pointerSize int
intSize int
endian device.Endian
}{
{device.UnknownABI, "unknown", 0, 0, 0, 0, device.LittleEndian},
{device.AndroidARMv7a, "armeabi-v7a", 32, 4, 4, 4, device.LittleEndian},
{device.AndroidARMv7aHard, "armeabi-v7a-hard", 32, 4, 4, 4, device.LittleEndian},
{device.AndroidARM64v8a, "arm64-v8a", 64, 8, 8, 8, device.LittleEndian},
{device.AndroidX86, "x86", 32, 4, 4, 4, device.LittleEndian},
{device.AndroidX86_64, "x86-64", 64, 8, 8, 8, device.LittleEndian},
{device.AndroidMIPS, "mips", 32, 4, 4, 4, device.LittleEndian},
{device.AndroidMIPS64, "mips64", 64, 8, 8, 8, device.LittleEndian},
}
func TestABI(t *testing.T) {
ctx := assert.Context(t)
for _, test := range abiTestData {
ctx = ctx.S("test", test.name).V("ABI", test.abi.Name)
abi := device.ABIByName(test.name)
// TODO: there's a collision between the x86-64 ABIs for OSX and Android.
// Should the ABI even include the OS?
// assert.For(ctx, "ABIByName").That(abi).Equals(test.abi)
assert.For(ctx, "ABI.Architecture.Bitness").That(abi.Architecture.Bitness()).Equals(test.width)
assert.For(ctx, "ABI.MemoryLayout.PointerAlignment").That(abi.MemoryLayout.PointerAlignment).Equals(test.align)
assert.For(ctx, "ABI.MemoryLayout.IntegerSize").That(abi.MemoryLayout.PointerSize).Equals(test.pointerSize)
assert.For(ctx, "ABI.MemoryLayout.IntegerSize").That(abi.MemoryLayout.IntegerSize).Equals(test.intSize)
assert.For(ctx, "ABI.MemoryLayout.Endian").That(abi.MemoryLayout.Endian).Equals(test.endian)
}
}
func TestABIByName(t *testing.T) {
ctx := assert.Context(t)
abi := device.ABIByName("invalid")
assert.For(ctx, "ABI.Name").That(abi.Name).Equals("invalid")
assert.For(ctx, "ABI.Architecture").That(abi.Architecture).Equals(device.UnknownArchitecture)
assert.For(ctx, "ABI.OS").That(abi.OS).Equals(device.UnknownOS)
}