-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
to check whether loading `.so` or `.dylib` from `java.library.path` works, when not calling `FuseBuilder.setLibraryPath(...)`
- Loading branch information
1 parent
40a812f
commit 0a8a238
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
jfuse-tests/src/test/java/org/cryptomator/jfuse/tests/FallbackLibLoadingIT.java
This file contains 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,49 @@ | ||
package org.cryptomator.jfuse.tests; | ||
|
||
import org.cryptomator.jfuse.api.Fuse; | ||
import org.cryptomator.jfuse.examples.RandomFileSystem; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
import org.junit.jupiter.api.condition.EnabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
@EnabledIfSystemProperty(named = "fuse.lib.path", matches = ".+") | ||
public class FallbackLibLoadingIT { | ||
|
||
@Test | ||
@EnabledOnOs(OS.LINUX) | ||
@DisplayName("loads fuse lib from java.library.path, if not calling FuseBuilder.setLibraryPath(...)") | ||
public void loadFromJavaLibraryPathOnLinux(@TempDir Path p) throws IOException, TimeoutException { | ||
loadFromJavaLibraryPath(p, "libfuse3.so"); | ||
} | ||
|
||
@Test | ||
@EnabledOnOs(OS.MAC) | ||
@DisplayName("loads fuse lib from java.library.path, if not calling FuseBuilder.setLibraryPath(...)") | ||
public void loadFromJavaLibraryPathOnMacOS(@TempDir Path p) throws IOException, TimeoutException { | ||
loadFromJavaLibraryPath(p, "libfuse-t.dylib"); | ||
} | ||
|
||
private void loadFromJavaLibraryPath(Path tmpLibPath, String libFileName) throws IOException, TimeoutException { | ||
var libPath = System.getProperty("fuse.lib.path"); | ||
var symlinkPath = tmpLibPath.resolve(libFileName); | ||
Files.createSymbolicLink(symlinkPath, Path.of(libPath)); | ||
|
||
System.setProperty("java.library.path", tmpLibPath.toString()); | ||
|
||
var builder = Fuse.builder(); | ||
var fs = new RandomFileSystem(builder.errno()); | ||
var fuse = Assertions.assertDoesNotThrow(() -> builder.build(fs)); | ||
fuse.close(); | ||
} | ||
|
||
} |