hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1393113 - /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
Date Tue, 02 Oct 2012 19:13:54 GMT
Author: eli
Date: Tue Oct  2 19:13:53 2012
New Revision: 1393113

URL: http://svn.apache.org/viewvc?rev=1393113&view=rev
Log:
HDFS-3753. Tests don't run with native libraries. Contributed by Colin Patrick McCabe

Added:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java

Added: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java?rev=1393113&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
(added)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestNativeCodeLoader.java
Tue Oct  2 19:13:53 2012
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.hadoop.util;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.util.NativeCodeLoader;
+
+public class TestNativeCodeLoader {
+  static final Log LOG = LogFactory.getLog(TestNativeCodeLoader.class);
+
+  private static boolean requireTestJni() {
+    String rtj = System.getProperty("require.test.libhadoop");
+    if (rtj == null) return false;
+    if (rtj.compareToIgnoreCase("false") == 0) return false;
+    return true;
+  }
+
+  @Test
+  public void testNativeCodeLoaded() {
+    if (requireTestJni() == false) {
+      LOG.info("TestNativeCodeLoader: libhadoop.so testing is not required.");
+      return;
+    }
+    if (!NativeCodeLoader.isNativeCodeLoaded()) {
+      fail("TestNativeCodeLoader: libhadoop.so testing was required, but " +
+          "libhadoop.so was not loaded.");
+    }
+    LOG.info("TestNativeCodeLoader: libhadoop.so is loaded.");
+  }
+}



Mime
View raw message