-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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,30 @@ | |
| </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" | ||
| depends="test-compile"> | ||
| <!-- Build library path including both test location and system paths --> | ||
| <condition property="tcnative.library.path" value="${test.apr.loc};C:\Windows\System32"> | ||
| <os family="windows"/> | ||
| </condition> | ||
| <condition property="tcnative.library.path" value="${test.apr.loc}:/usr/local/lib:/opt/homebrew/lib:/usr/lib"> | ||
|
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. I think the hardcoded paths should be replaced with ${java.library.path}. |
||
| <os family="mac"/> | ||
| </condition> | ||
| <property name="tcnative.library.path" value="${test.apr.loc}:/lib:/usr/lib:/lib64:/usr/lib64"/> | ||
|
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. Same replacement applies here. |
||
|
|
||
| <!-- 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="-Djava.library.path=${tcnative.library.path}"/> | ||
| <jvmarg value="--enable-native-access=ALL-UNNAMED"/> | ||
| <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"> | ||
|
|
||
| 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"); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior of test-only-nio target with adding test-compile dependency. Could split that into two targets and make test-tcnative-exists depend on a compile-tcnative-check target.