Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: René Ulbricht <[email protected]>
  • Loading branch information
ulbi committed Jul 13, 2024
1 parent 35add30 commit 391196c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -224,6 +227,26 @@ public static Stream<Arguments> provideOpenhabItemTypes() {
new QuantityType<>("25.00 °F"))));
}

/**
* Checks if the current system supports AVX (Advanced Vector Extensions).
* AVX is a set of CPU instructions that can greatly improve performance for certain operations.
*
* @return true if AVX is supported, false otherwise
*/
public static boolean isAVXSupported() {
try (BufferedReader reader = new BufferedReader(new FileReader("/proc/cpuinfo"))) {
String line;
while ((line = reader.readLine()) != null) {
if (line.toLowerCase().contains("avx")) {
return true;
}
}
} catch (IOException e) {
return false;
}
return false;
}

/**
* Provides a stream of arguments to be used for parameterized tests.
*
Expand All @@ -234,7 +257,7 @@ public static Stream<Arguments> provideOpenhabItemTypes() {
* @return A stream of Arguments, each containing a DatabaseTestContainer instance.
*/
public static Stream<Arguments> provideDatabaseBackends() {
if (DockerClientFactory.instance().isDockerAvailable()) {
if (DockerClientFactory.instance().isDockerAvailable() && isAVXSupported()) {
// If Docker is available, create a stream of Arguments with all backends
return Stream.of(
// Create a DatabaseTestContainer with a MemoryBackend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -63,7 +62,6 @@
*
* @author René Ulbricht - Initial contribution
*/
@Disabled("Fails on CPUs without AVX support, see: https://github.com/openhab/openhab-addons/issues/17046")
public class MongoDBPersistenceServiceTest {

/**
Expand Down

0 comments on commit 391196c

Please sign in to comment.