-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Improve test feedback by logging the availability checks for OpenSSL and Tomcat Native libraries when they're missing #970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
csutherl
wants to merge
1
commit into
apache:main
Choose a base branch
from
csutherl:add-warnings-for-missing-openssl-tcnative
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+88
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2109,13 +2109,13 @@ | |
| </target> | ||
|
|
||
| <target name="test-nio" description="Runs the JUnit test cases for NIO. Does not stop on errors." | ||
| depends="-test-name-default,setup-jacoco,test-compile,deploy,test-openssl-exists" if="${execute.test.nio}"> | ||
| depends="-test-name-default,setup-jacoco,test-compile,deploy,test-openssl-exists,test-tcnative-exists" if="${execute.test.nio}"> | ||
| <runtests protocol="org.apache.coyote.http11.Http11NioProtocol" | ||
| extension=".NIO" /> | ||
| </target> | ||
|
|
||
| <target name="test-only-nio" description="Runs the JUnit test cases or NIO without test preparations. Does not stop on errors." | ||
| depends="-test-name-default,setup-jacoco,test-openssl-exists" if="${execute.test.nio}"> | ||
| depends="-test-name-default,setup-jacoco,test-openssl-exists,test-tcnative-exists" if="${execute.test.nio}"> | ||
| <runtests protocol="org.apache.coyote.http11.Http11NioProtocol" | ||
| extension=".NIO" /> | ||
| </target> | ||
|
|
@@ -2134,6 +2134,48 @@ | |
| </and> | ||
| </or> | ||
| </condition> | ||
| <echo message="OpenSSL is not available. OpenSSL-related tests will be skipped or may fail." level="warning" unless:set="test.openssl.exists"/> | ||
| </target> | ||
|
|
||
| <target name="test-tcnative-exists" description="Verifies tomcat-native library can be loaded"> | ||
| <!-- Check if main classes are built --> | ||
| <available file="${test.run.classes}/org/apache/tomcat/jni/Library.class" | ||
| property="tomcat.classes.available"/> | ||
|
|
||
| <!-- If main classes don't exist, compile just what we need --> | ||
| <mkdir dir="${test.run.classes}" unless:set="tomcat.classes.available"/> | ||
| <javac srcdir="java" destdir="${test.run.classes}" | ||
| includes="org/apache/tomcat/jni/Library.java,org/apache/tomcat/jni/LibraryNotFoundError.java" | ||
| debug="${compile.debug}" | ||
| includeantruntime="false" | ||
| encoding="UTF-8" | ||
| unless:set="tomcat.classes.available"> | ||
| <compilerarg line="-Xlint:-options"/> | ||
| </javac> | ||
|
|
||
| <!-- Compile the test class --> | ||
| <mkdir dir="${test.classes}"/> | ||
| <javac srcdir="test" destdir="${test.classes}" | ||
| includes="org/apache/tomcat/jni/TesterLibraryLoad.java" | ||
| debug="${compile.debug}" | ||
| includeantruntime="false" | ||
| encoding="UTF-8"> | ||
| <classpath> | ||
| <pathelement location="${test.run.classes}"/> | ||
| <pathelement location="${junit.jar}"/> | ||
| </classpath> | ||
| </javac> | ||
|
|
||
| <!-- Run test - it will check both test.apr.loc and system library paths --> | ||
| <junit printsummary="no" fork="yes" showoutput="false" haltonfailure="false" | ||
| failureproperty="test.tcnative.error" logfailedtests="false"> | ||
| <jvmarg value="${runtests.librarypath}"/> | ||
| <jvmarg value="--enable-native-access=ALL-UNNAMED"/> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can replace with ${native.nativeaccess} for consistency |
||
| <classpath refid="tomcat.test.classpath"/> | ||
| <test name="org.apache.tomcat.jni.TesterLibraryLoad"/> | ||
| </junit> | ||
|
|
||
| <echo message="Tomcat Native is not available. Tomcat Native (JNI) tests will be skipped." if:set="test.tcnative.error" level="warning"/> | ||
| </target> | ||
|
|
||
| <target name="test-httpd-exists" description="Checks for the httpd binary"> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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.tomcat.jni; | ||
|
|
||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
|
|
||
| /** | ||
| * Simple test to verify tomcat-native library can be loaded. | ||
| */ | ||
| public class TesterLibraryLoad { | ||
|
|
||
| @Test | ||
| public void testLibraryLoads() throws Exception { | ||
| try { | ||
| Library.initialize(null); | ||
| Library.terminate(); | ||
| } catch (LibraryNotFoundError e) { | ||
| // Library not available - fail test to set property | ||
| Assert.fail("Library not found"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.