104054e28e24866d76034236843490829b80df40cAndreas Gampe/*
204054e28e24866d76034236843490829b80df40cAndreas Gampe * Copyright (C) 2014 The Android Open Source Project
304054e28e24866d76034236843490829b80df40cAndreas Gampe *
404054e28e24866d76034236843490829b80df40cAndreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
504054e28e24866d76034236843490829b80df40cAndreas Gampe * you may not use this file except in compliance with the License.
604054e28e24866d76034236843490829b80df40cAndreas Gampe * You may obtain a copy of the License at
704054e28e24866d76034236843490829b80df40cAndreas Gampe *
804054e28e24866d76034236843490829b80df40cAndreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
904054e28e24866d76034236843490829b80df40cAndreas Gampe *
1004054e28e24866d76034236843490829b80df40cAndreas Gampe * Unless required by applicable law or agreed to in writing, software
1104054e28e24866d76034236843490829b80df40cAndreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
1204054e28e24866d76034236843490829b80df40cAndreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304054e28e24866d76034236843490829b80df40cAndreas Gampe * See the License for the specific language governing permissions and
1404054e28e24866d76034236843490829b80df40cAndreas Gampe * limitations under the License.
1504054e28e24866d76034236843490829b80df40cAndreas Gampe */
1604054e28e24866d76034236843490829b80df40cAndreas Gampe
1704054e28e24866d76034236843490829b80df40cAndreas Gampe#include "NativeBridgeTest.h"
1804054e28e24866d76034236843490829b80df40cAndreas Gampe
1904054e28e24866d76034236843490829b80df40cAndreas Gampenamespace android {
2004054e28e24866d76034236843490829b80df40cAndreas Gampe
2104054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kISAs[] = { "arm", "arm64", "mips", "x86", "x86_64", "random", "64arm", "64_x86",
2204054e28e24866d76034236843490829b80df40cAndreas Gampe                               "64_x86_64", "", "reallylongstringabcd", nullptr };
2304054e28e24866d76034236843490829b80df40cAndreas Gampe
2404054e28e24866d76034236843490829b80df40cAndreas Gampe#if defined(__arm__)
2504054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "arm";
2604054e28e24866d76034236843490829b80df40cAndreas Gampe#elif defined(__aarch64__)
2704054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "arm64";
2804054e28e24866d76034236843490829b80df40cAndreas Gampe#elif defined(__mips__)
2904054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "mips";
3004054e28e24866d76034236843490829b80df40cAndreas Gampe#elif defined(__i386__)
3104054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "x86";
3204054e28e24866d76034236843490829b80df40cAndreas Gampe#elif defined(__x86_64__)
3304054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "x86_64";
3404054e28e24866d76034236843490829b80df40cAndreas Gampe#else
3504054e28e24866d76034236843490829b80df40cAndreas Gampestatic const char* kRuntimeISA = "unknown";
3604054e28e24866d76034236843490829b80df40cAndreas Gampe#endif
3704054e28e24866d76034236843490829b80df40cAndreas Gampe
3804054e28e24866d76034236843490829b80df40cAndreas GampeTEST_F(NativeBridgeTest, NeedsNativeBridge) {
3904054e28e24866d76034236843490829b80df40cAndreas Gampe    EXPECT_EQ(false, NeedsNativeBridge(kRuntimeISA));
4004054e28e24866d76034236843490829b80df40cAndreas Gampe
4104054e28e24866d76034236843490829b80df40cAndreas Gampe    const size_t kISACount = sizeof(kISAs)/sizeof(kISAs[0]);
4204054e28e24866d76034236843490829b80df40cAndreas Gampe    for (size_t i = 0; i < kISACount; i++) {
4304054e28e24866d76034236843490829b80df40cAndreas Gampe        EXPECT_EQ(kISAs[i] == nullptr ? false : strcmp(kISAs[i], kRuntimeISA) != 0,
4404054e28e24866d76034236843490829b80df40cAndreas Gampe                  NeedsNativeBridge(kISAs[i]));
4504054e28e24866d76034236843490829b80df40cAndreas Gampe    }
4604054e28e24866d76034236843490829b80df40cAndreas Gampe}
4704054e28e24866d76034236843490829b80df40cAndreas Gampe
4804054e28e24866d76034236843490829b80df40cAndreas Gampe}  // namespace android
49