|
| 1 | +/* |
| 2 | + * Copyright 2022 Uber Technologies, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.uber.h3core; |
| 17 | + |
| 18 | +import static org.junit.Assert.assertNotNull; |
| 19 | +import static org.junit.Assume.assumeTrue; |
| 20 | + |
| 21 | +import com.google.common.collect.ImmutableList; |
| 22 | +import java.io.IOException; |
| 23 | +import java.util.List; |
| 24 | +import org.junit.BeforeClass; |
| 25 | +import org.junit.Test; |
| 26 | + |
| 27 | +/** |
| 28 | + * Test that particular resource names exist in the built artifact when cross compiling. Although we |
| 29 | + * cannot test that those resources run correctly (since they can't be loaded), we can at least test |
| 30 | + * that the cross compiler put resources in the right locations. This test is only run if the system |
| 31 | + * property <code>h3.use.docker</code> has the value <code>true</code>. |
| 32 | + */ |
| 33 | +public class TestH3CoreCrossCompile { |
| 34 | + @BeforeClass |
| 35 | + public static void assumptions() { |
| 36 | + assumeTrue( |
| 37 | + "Docker cross compilation enabled", "true".equals(System.getProperty("h3.use.docker"))); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void testResourcesExist() throws IOException { |
| 42 | + List<String> resources = |
| 43 | + ImmutableList.of( |
| 44 | + "/linux-x64/libh3-java.so", |
| 45 | + "/linux-x86/libh3-java.so", |
| 46 | + "/linux-arm64/libh3-java.so", |
| 47 | + "/linux-armv5/libh3-java.so", |
| 48 | + "/linux-armv7/libh3-java.so", |
| 49 | + "/linux-ppc64le/libh3-java.so", |
| 50 | + "/linux-s390x/libh3-java.so", |
| 51 | + "/windows-x64/libh3-java.dll", |
| 52 | + "/windows-x86/libh3-java.dll", |
| 53 | + "/darwin-x64/libh3-java.dylib", |
| 54 | + "/darwin-arm/libh3-java.dylib", |
| 55 | + "/freebsd-x64/libh3-java.so", |
| 56 | + "/android-arm/libh3-java.so", |
| 57 | + "/android-arm64/libh3-java.so"); |
| 58 | + for (String name : resources) { |
| 59 | + assertNotNull(name + " is an included resource", H3CoreLoader.class.getResource(name)); |
| 60 | + } |
| 61 | + } |
| 62 | +} |
0 commit comments