Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
390 commits
Select commit Hold shift + click to select a range
451b254
Move doxygen detection after other settings
byrnHDF Sep 29, 2025
e8b2ca8
Revert and set java doxygen
byrnHDF Sep 29, 2025
e892322
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Sep 30, 2025
a9515a0
VL data reads and writes fixed.
byrnHDF Sep 30, 2025
5a3c8e5
Committing clang-format changes
github-actions[bot] Sep 30, 2025
06113d3
Remove test debug files
byrnHDF Sep 30, 2025
dc4495a
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Sep 30, 2025
48cd613
Merge develop changes
byrnHDF Sep 30, 2025
c2623fe
FFM updates of merge with develop
byrnHDF Sep 30, 2025
7f75f02
Committing clang-format changes
github-actions[bot] Sep 30, 2025
4fcb1f2
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 1, 2025
a4621e0
Fix vlen crash
byrnHDF Oct 1, 2025
eda37cc
Committing clang-format changes
github-actions[bot] Oct 1, 2025
638ff21
Merge develop-maven-upload: Integrate Maven deployment with FFM/JNI s…
byrnHDF Oct 1, 2025
122e9e2
Implement matrix-based parallel FFM/JNI builds in maven-staging.yml
byrnHDF Oct 1, 2025
ccc7cde
Fix artifact suffix for macOS platforms in matrix
byrnHDF Oct 1, 2025
cc6c4ac
Fix GitHub Actions matrix job outputs
byrnHDF Oct 1, 2025
2ab9706
Fix test-java-examples-maven job condition
byrnHDF Oct 1, 2025
19226ec
Fix detect-changes job for push events
byrnHDF Oct 1, 2025
1f963b8
Fix job dependencies for comment-pr and cleanup jobs
byrnHDF Oct 1, 2025
2164cb2
Fix Maven artifact validation to support FFM/JNI artifact IDs
byrnHDF Oct 1, 2025
dc04321
Simplify Maven staging workflow - remove unnecessary tarball creation
byrnHDF Oct 1, 2025
60642e7
Add workflow presets for FFM/JNI Maven configurations
byrnHDF Oct 1, 2025
a1352f3
Fix checkout path in maven-staging workflow
byrnHDF Oct 1, 2025
5d276ee
Add build and package presets for FFM/JNI Maven configurations
byrnHDF Oct 1, 2025
e2cd62f
Fix test-java-examples to use dynamic matrix with implementation suffix
byrnHDF Oct 2, 2025
d8a2081
Fix Windows path issues in maven-staging workflow
byrnHDF Oct 2, 2025
0ae45b8
Fix remaining Windows path issues in artifact collection
byrnHDF Oct 2, 2025
d6779bc
Fix validation script to install artifacts locally before testing
byrnHDF Oct 2, 2025
66f42bc
Update release workflow to build and deploy both FFM and JNI Maven ar…
byrnHDF Oct 2, 2025
d2b5ddf
Fix FFM POM to use correct artifact ID variable
byrnHDF Oct 2, 2025
6f76e76
Fix java version and build options. Allow examples
byrnHDF Oct 2, 2025
e98a181
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 2, 2025
f941042
Implement support read/writes and start adding compounds
byrnHDF Oct 3, 2025
2dd1e15
Committing clang-format changes
github-actions[bot] Oct 3, 2025
49c29d3
Implemented Java tests for compound datatypes
byrnHDF Oct 3, 2025
9b8ac6d
Committing clang-format changes
github-actions[bot] Oct 3, 2025
2c8b544
Correct cleanup code
byrnHDF Oct 3, 2025
1c07615
Correct name of provides
byrnHDF Oct 3, 2025
0f430e0
Fix examples for FFM usage
byrnHDF Oct 3, 2025
10af429
Skip Unlimited examples when using FFM
byrnHDF Oct 3, 2025
d8c307d
Update doc issues
byrnHDF Oct 3, 2025
3108705
Committing clang-format changes
github-actions[bot] Oct 3, 2025
8ca7987
Fix Java build duplication
byrnHDF Oct 5, 2025
f85c665
Fix java Examples and jar files names
byrnHDF Oct 5, 2025
6692dd9
Fix windows issue
byrnHDF Oct 5, 2025
ca429ae
Fix JNi builds
byrnHDF Oct 5, 2025
0dae490
Correct configure
byrnHDF Oct 5, 2025
9a16cd5
Correct main syntax
byrnHDF Oct 5, 2025
9457e15
Fix unused functions
byrnHDF Oct 5, 2025
60d3089
Committing clang-format changes
github-actions[bot] Oct 5, 2025
4d326c6
Use generic Object for unsupported structs
byrnHDF Oct 5, 2025
1aece89
Fixed comment
byrnHDF Oct 5, 2025
b03162d
Another Object change
byrnHDF Oct 5, 2025
f6029d3
Committing clang-format changes
github-actions[bot] Oct 5, 2025
5a5d122
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 6, 2025
74227e2
Initial work on FFM tests
byrnHDF Oct 6, 2025
26ef1cb
Committing clang-format changes
github-actions[bot] Oct 6, 2025
18c55b2
Cleanup and add H5P tests
byrnHDF Oct 6, 2025
7979601
Committing clang-format changes
github-actions[bot] Oct 6, 2025
fdc577d
Fix conflicts
byrnHDF Oct 6, 2025
534e3d2
Committing clang-format changes
github-actions[bot] Oct 6, 2025
cfe3788
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 6, 2025
f6520a7
Remove unneeded testfiles
byrnHDF Oct 6, 2025
ad092d8
Add more H5P tests
byrnHDF Oct 6, 2025
a3eb203
Committing clang-format changes
github-actions[bot] Oct 6, 2025
4746349
More H5P tests
byrnHDF Oct 6, 2025
28b9106
Committing clang-format changes
github-actions[bot] Oct 6, 2025
3274574
Add more H5P tests
byrnHDF Oct 6, 2025
621171b
Committing clang-format changes
github-actions[bot] Oct 6, 2025
8c91274
Rework depends name
byrnHDF Oct 6, 2025
63d7fe8
Add more H5A tests
byrnHDF Oct 6, 2025
f1f2178
Committing clang-format changes
github-actions[bot] Oct 6, 2025
8753db9
Implement more tests
byrnHDF Oct 6, 2025
39fd3d3
Committing clang-format changes
github-actions[bot] Oct 6, 2025
f18e0e5
Fix JNI depends usage
byrnHDF Oct 7, 2025
979f86b
Attempt to fix doxygen ref issue
byrnHDF Oct 7, 2025
c79c21a
Add more checks
byrnHDF Oct 7, 2025
85931ca
Correct ENABLE JNI usage
byrnHDF Oct 7, 2025
e0dd033
re-enable docs for fixing
byrnHDF Oct 7, 2025
a0c354e
Merge develop chnages
byrnHDF Oct 8, 2025
3235570
Committing clang-format changes
github-actions[bot] Oct 8, 2025
41ec545
Update FFM source
byrnHDF Oct 8, 2025
6cbe8a9
Committing clang-format changes
github-actions[bot] Oct 8, 2025
2b5f3c8
Try fix win CI
byrnHDF Oct 8, 2025
1b17ff5
Must be shared lib
byrnHDF Oct 9, 2025
2199178
Merge H5EX prefix change
byrnHDF Oct 9, 2025
03e2fa3
Fix usage variable to function call
byrnHDF Oct 9, 2025
2bf4a3f
Merge with develop changes
byrnHDF Oct 9, 2025
0e39b50
Updates
byrnHDF Oct 9, 2025
19a4ba4
Committing clang-format changes
github-actions[bot] Oct 9, 2025
73cd784
Corrections everywhere
byrnHDF Oct 9, 2025
33546ac
Committing clang-format changes
github-actions[bot] Oct 9, 2025
893f9b5
More FFM tests
byrnHDF Oct 9, 2025
ee1a0b2
Committing clang-format changes
github-actions[bot] Oct 9, 2025
13e29d3
Fix constants option
byrnHDF Oct 9, 2025
5015bb3
Committing clang-format changes
github-actions[bot] Oct 9, 2025
2b6f7a3
Require ros3 for ffm java
byrnHDF Oct 10, 2025
0b24486
Committing clang-format changes
github-actions[bot] Oct 10, 2025
69389eb
Merge branch 'develop'
byrnHDF Oct 10, 2025
7634eaa
Fix conflicts
byrnHDF Oct 10, 2025
6dd92b1
remove duplicates
byrnHDF Oct 10, 2025
7af8277
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 11, 2025
d50ecdc
Skip including ros3 VFD APIs
byrnHDF Oct 13, 2025
2a69cde
Committing clang-format changes
github-actions[bot] Oct 13, 2025
fab29a7
Fix workflow
byrnHDF Oct 13, 2025
03ba0e4
Remove obsolete file
byrnHDF Oct 13, 2025
b7eba50
Update java jar usage
byrnHDF Oct 13, 2025
82b8b73
Check for artifacts before creating again
byrnHDF Oct 13, 2025
4cc7123
Rework how to use FFM headers
byrnHDF Oct 13, 2025
d593a48
Correct version for action
byrnHDF Oct 13, 2025
24d9cf8
Update artifact names for binary testing
byrnHDF Oct 13, 2025
68f4cd1
Cleanup
byrnHDF Oct 13, 2025
60d3fea
Add FFM H5O tests
byrnHDF Oct 13, 2025
85fbcae
Committing clang-format changes
github-actions[bot] Oct 13, 2025
3899d3e
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 13, 2025
0a4906e
Correct typo
byrnHDF Oct 13, 2025
0373c00
More FFM tests for H5P and H5F
byrnHDF Oct 13, 2025
0407612
Committing clang-format changes
github-actions[bot] Oct 13, 2025
48b1c7a
Add some H5T ffm tests
byrnHDF Oct 14, 2025
1887a84
Committing clang-format changes
github-actions[bot] Oct 14, 2025
62f5cbb
Remove duplicate test
byrnHDF Oct 14, 2025
d179c72
Split HDF5Examples into FFM and compatibility
byrnHDF Oct 14, 2025
3ecb327
Committing clang-format changes
github-actions[bot] Oct 14, 2025
244299d
adjust ros3 file location
byrnHDF Oct 14, 2025
856d499
More FFM tests
byrnHDF Oct 14, 2025
87e356c
Committing clang-format changes
github-actions[bot] Oct 14, 2025
752ae4d
Optionally include structs file
byrnHDF Oct 14, 2025
5f99cb0
Fix FFM test issues
byrnHDF Oct 14, 2025
1590ef9
Committing clang-format changes
github-actions[bot] Oct 14, 2025
3ccb360
More tests added
byrnHDF Oct 14, 2025
855fb27
Committing clang-format changes
github-actions[bot] Oct 14, 2025
8208e55
Fix merge conflicts
byrnHDF Oct 15, 2025
d839b84
Committing clang-format changes
github-actions[bot] Oct 15, 2025
57abf99
Add H5VL ffm tests
byrnHDF Oct 15, 2025
f53608e
Committing clang-format changes
github-actions[bot] Oct 15, 2025
d0a468e
Cover more API modules.
byrnHDF Oct 15, 2025
31550ad
Committing clang-format changes
github-actions[bot] Oct 15, 2025
8e9c768
Fix install logic
byrnHDF Oct 15, 2025
ed4afa4
Update tests
byrnHDF Oct 15, 2025
65523ae
Committing clang-format changes
github-actions[bot] Oct 15, 2025
1df7388
Add presets
byrnHDF Oct 15, 2025
c2bd155
More tests implemented
byrnHDF Oct 15, 2025
5d5b013
Committing clang-format changes
github-actions[bot] Oct 15, 2025
a5486c5
Finish FFM tests
byrnHDF Oct 16, 2025
61fdfa1
Committing clang-format changes
github-actions[bot] Oct 16, 2025
4a86808
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 16, 2025
293c740
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 16, 2025
7066c5d
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 16, 2025
74e82da
Fix merge conflicts
byrnHDF Oct 16, 2025
1a69419
Committing clang-format changes
github-actions[bot] Oct 16, 2025
912bf9f
First examples for FFM
byrnHDF Oct 16, 2025
739404f
Committing clang-format changes
github-actions[bot] Oct 16, 2025
b2555f2
All examples converted
byrnHDF Oct 16, 2025
706cfff
Committing clang-format changes
github-actions[bot] Oct 16, 2025
f764403
Enable Java FFM examples
byrnHDF Oct 17, 2025
f255349
Add windows jextract files
byrnHDF Oct 17, 2025
407ae57
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 17, 2025
b741ee6
Update INSTALL docs - make presets primary
byrnHDF Oct 17, 2025
9a6fbea
Correct version check for examples
byrnHDF Oct 18, 2025
98bd481
Fix FFM examples
byrnHDF Oct 18, 2025
6f5352a
Committing clang-format changes
github-actions[bot] Oct 18, 2025
d4e771c
Update FFM examples
byrnHDF Oct 19, 2025
78ef1d6
Committing clang-format changes
github-actions[bot] Oct 19, 2025
7b634c6
Fix tutor examples
byrnHDF Oct 19, 2025
9050020
Do not build iterate/visit FFM examples
byrnHDF Oct 19, 2025
e026baf
Committing clang-format changes
github-actions[bot] Oct 19, 2025
f762db5
Fix more examples
byrnHDF Oct 19, 2025
aa66663
correct typo
byrnHDF Oct 19, 2025
bd868ac
Committing clang-format changes
github-actions[bot] Oct 19, 2025
b226552
Some more fixes
byrnHDF Oct 19, 2025
a432632
Committing clang-format changes
github-actions[bot] Oct 19, 2025
9aca060
Fix TUTR compile issues
byrnHDF Oct 19, 2025
872315e
Committing clang-format changes
github-actions[bot] Oct 19, 2025
4c412fa
Update test name
byrnHDF Oct 19, 2025
6494e68
Correct default java state
byrnHDF Oct 19, 2025
05661e3
Complete examples.
byrnHDF Oct 19, 2025
fd4d057
Committing clang-format changes
github-actions[bot] Oct 19, 2025
02381f4
Update presets
byrnHDF Oct 19, 2025
1b8b3c6
Skip example with missing file
byrnHDF Oct 19, 2025
2014531
Add tests to presets
byrnHDF Oct 20, 2025
3fc0003
Add workflow to create FFM bindings.
byrnHDF Oct 20, 2025
fc40753
Integrate FFM bindings generation into daily build workflow
byrnHDF Oct 20, 2025
5e25826
Update CLAUDE.md with daily build integration
byrnHDF Oct 20, 2025
d54d64a
Fix jextract download with fallback URLs
byrnHDF Oct 20, 2025
b4a50a9
Update jextract URLs to current builds
byrnHDF Oct 20, 2025
90f3687
Fix broken pipe error in ls output
byrnHDF Oct 20, 2025
f326036
Remove unnecessary ls commands from jextract workflow
byrnHDF Oct 20, 2025
f8128d4
Add ROS3 VFD support to FFM bindings generation workflow
byrnHDF Oct 20, 2025
7e13b4b
Fix Windows jextract extraction issue
byrnHDF Oct 20, 2025
0dd52f3
Fix Windows jextract extraction with adaptive path detection
byrnHDF Oct 21, 2025
24b1a8a
Fix Windows jextract to use .bat file instead of .exe
byrnHDF Oct 21, 2025
4d97031
Fix Windows install prefix path format for bash shell
byrnHDF Oct 21, 2025
300ca9a
Fix merge step to download only jextract artifacts
byrnHDF Oct 21, 2025
417ad46
Fix merge script to handle platform-specific FFM bindings
byrnHDF Oct 21, 2025
298b887
Correct version for examples
byrnHDF Oct 21, 2025
9aec4e3
FFM platform files.
byrnHDF Oct 21, 2025
0b9dae3
Committing clang-format changes
github-actions[bot] Oct 21, 2025
3d0c5eb
Fix script
byrnHDF Oct 21, 2025
ffabacf
Correct file list
byrnHDF Oct 21, 2025
e794f95
Correct path to files
byrnHDF Oct 21, 2025
fa8d793
Add missing folder
byrnHDF Oct 22, 2025
79bb3df
Fix windows compile issue
byrnHDF Oct 22, 2025
b3c01d8
Committing clang-format changes
github-actions[bot] Oct 22, 2025
442c691
Fix doxygen error
byrnHDF Oct 22, 2025
b4808ec
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 22, 2025
282cd85
Fix maven-staging workflow: Add missing graphviz dependency
byrnHDF Oct 22, 2025
6ac3b74
Fix HDF5Examples to properly detect JNI vs FFM implementation
byrnHDF Oct 23, 2025
274b8bb
Correct doxygen tags
byrnHDF Oct 23, 2025
ec0fd36
Skip Windows-failing FFM tests in TestH5Tffm
byrnHDF Oct 23, 2025
f14f59b
Committing clang-format changes
github-actions[bot] Oct 23, 2025
4e0efc8
Fix HDF5Examples to correctly detect JNI vs FFM using HDF5_JAVA_IMPLE…
byrnHDF Oct 23, 2025
3dcfa4c
Fix Windows FFM test failures by using platform-independent H5T_STD t…
byrnHDF Oct 23, 2025
e601e2d
Enable detailed test output for FFM Java tests
byrnHDF Oct 23, 2025
dcee9c2
Fix Maven minimal presets: Remove test step when BUILD_TESTING=OFF
byrnHDF Oct 23, 2025
f55df49
Add compilation error output to Maven staging test failures
byrnHDF Oct 25, 2025
9ae3b54
Fix Maven staging to use correct examples directory based on implemen…
byrnHDF Oct 25, 2025
a9acd55
Fix Maven staging Windows test to check all 4 example categories
byrnHDF Oct 25, 2025
52e43ea
Clarify Maven preset platform-specificity in INSTALL_CMake.txt
byrnHDF Oct 25, 2025
d1fd3e7
Skip 5 Windows-failing FFM tests - FFM memory layout limitations
byrnHDF Oct 25, 2025
355cccd
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 26, 2025
55ae3c8
Improve presets usage
byrnHDF Oct 26, 2025
5c3057d
Change NATIVE types
byrnHDF Oct 26, 2025
3a59485
Fix workflow
byrnHDF Oct 26, 2025
758f7b6
Fix maven staging workflow
byrnHDF Oct 26, 2025
edf0c12
More fixes for maven workflow
byrnHDF Oct 26, 2025
e23cbab
Fix windows LONG errors
byrnHDF Oct 26, 2025
249db7c
Committing clang-format changes
github-actions[bot] Oct 26, 2025
40048c8
Correct maven staging workflow
byrnHDF Oct 27, 2025
41e0455
Improve maven testing
byrnHDF Oct 27, 2025
8ea0e0a
Another fix to test
byrnHDF Oct 27, 2025
8b05236
Fix for implentation tests
byrnHDF Oct 27, 2025
e0c39ee
Fix test binaries
byrnHDF Oct 27, 2025
dcfa3bc
Correct option usage.
byrnHDF Oct 27, 2025
33f3721
Fix FFM binary tests
byrnHDF Oct 27, 2025
1781e36
Correct java version for bintest.yml
byrnHDF Oct 27, 2025
05a0b00
Fix relative paths in jni source
byrnHDF Oct 27, 2025
53aa605
Fix maven artifacts for release workflow
byrnHDF Oct 27, 2025
ae7a885
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 27, 2025
4098ea9
Revert Maven changes from ctest.yml
byrnHDF Oct 27, 2025
2ed7ec9
Remove maven_enabled parameter from release.yml ctest call
byrnHDF Oct 27, 2025
65fb9ad
Fix Java version mismatch in macOS binary tests
byrnHDF Oct 28, 2025
fd7518c
Fix Java build failures in release workflow standard builds
byrnHDF Oct 28, 2025
41f8226
Fix java build race condition issue
byrnHDF Oct 28, 2025
9d3605e
Clean up CLAUDE.md: remove date-specific and test-specific info
byrnHDF Oct 28, 2025
9af5b17
Cleanup doc and set default
byrnHDF Oct 28, 2025
d75b375
Refactor out aws_c_s3 workflow
byrnHDF Oct 28, 2025
924d0d5
Cleanup preset naming and usage
byrnHDF Oct 29, 2025
b2339d5
Correct preset names in script
byrnHDF Oct 29, 2025
ead097c
Merge branch 'HDFGroup:develop' into develop-jextract22
byrnHDF Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
478 changes: 478 additions & 0 deletions .github/scripts/ci-integration-test.sh

Large diffs are not rendered by default.

379 changes: 379 additions & 0 deletions .github/scripts/test-java-implementations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,379 @@
#!/bin/bash
# Test script for validating Java FFM and JNI implementations across different Java versions
# Usage: test-java-implementations.sh [java_version] [implementation] [test_mode]

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"

# Default values
JAVA_VERSION="${1:-24}"
IMPLEMENTATION="${2:-auto}" # auto, ffm, jni
TEST_MODE="${3:-build}" # build, maven, full

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}

log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}

log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}

log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}

# Test matrix configuration
declare -A JAVA_VERSIONS=(
["11"]="JNI only"
["17"]="JNI only"
["21"]="JNI only"
["24"]="JNI default, FFM optional"
["25"]="JNI default, FFM optional"
)

declare -A TEST_PRESETS_FFM=(
["build"]="ci-StdShar-GNUC-FFM"
["maven"]="ci-MinShar-GNUC-Maven-FFM"
)

declare -A TEST_PRESETS_JNI=(
["build"]="ci-StdShar-GNUC"
["maven"]="ci-MinShar-GNUC-Maven"
)

# Validate Java version support
validate_java_version() {
local version=$1
local impl=$2

if [[ ! ${JAVA_VERSIONS[$version]+_} ]]; then
log_error "Unsupported Java version: $version"
log_info "Supported versions: ${!JAVA_VERSIONS[@]}"
return 1
fi

if [[ $version -lt 24 && "$impl" == "ffm" ]]; then
log_error "FFM implementation requires Java 24+, got Java $version"
return 1
fi

log_info "Java $version validation: ${JAVA_VERSIONS[$version]}"
return 0
}

# Determine implementation based on Java version and user preference
determine_implementation() {
local version=$1
local requested=$2

case "$requested" in
"auto")
# JNI is default for HDF5 2.0, regardless of Java version
echo "jni"
;;
"ffm")
if [[ $version -ge 24 ]]; then
echo "ffm"
else
log_error "FFM not available for Java $version"
return 1
fi
;;
"jni")
echo "jni"
;;
*)
log_error "Invalid implementation: $requested (use auto, ffm, or jni)"
return 1
;;
esac
}

# Create build directory with unique name
create_build_dir() {
local impl=$1
local mode=$2

BUILD_DIR="${PROJECT_ROOT}/build-test-java${JAVA_VERSION}-${impl}-${mode}"

if [[ -d "$BUILD_DIR" ]]; then
log_warning "Removing existing build directory: $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi

mkdir -p "$BUILD_DIR"
log_info "Created build directory: $BUILD_DIR"
}

# Test basic build configuration
test_build_config() {
local impl=$1
local preset_key="build"

log_info "Testing $impl build configuration..."

if [[ "$impl" == "ffm" ]]; then
preset=${TEST_PRESETS_FFM[$preset_key]}
else
preset=${TEST_PRESETS_JNI[$preset_key]}
fi

log_info "Using preset: $preset"

cd "$PROJECT_ROOT"

# Configure with preset
if ! cmake --preset "$preset" -B "$BUILD_DIR"; then
log_error "CMake configuration failed for $impl implementation"
return 1
fi

# Verify implementation detection
# Note: CMake uses HDF5_ENABLE_JNI (not HDF5_ENABLE_FFM)
# JNI enabled (ON or not set) = JNI implementation
# JNI disabled (OFF) = FFM implementation
if [ "$impl" = "jni" ]; then
# For JNI, verify it's not explicitly disabled
if grep -q "HDF5_ENABLE_JNI:BOOL=OFF" "$BUILD_DIR/CMakeCache.txt"; then
log_error "Implementation detection failed - expected JNI but found HDF5_ENABLE_JNI=OFF"
cat "$BUILD_DIR/CMakeCache.txt" | grep "HDF5_ENABLE_JNI" || true
return 1
fi
log_info "JNI implementation verified (HDF5_ENABLE_JNI not OFF)"
elif [ "$impl" = "ffm" ]; then
# For FFM, verify JNI is explicitly disabled
if ! grep -q "HDF5_ENABLE_JNI:BOOL=OFF" "$BUILD_DIR/CMakeCache.txt"; then
log_error "Implementation detection failed - expected HDF5_ENABLE_JNI=OFF for FFM"
cat "$BUILD_DIR/CMakeCache.txt" | grep "HDF5_ENABLE_JNI" || true
return 1
fi
log_info "FFM implementation verified (HDF5_ENABLE_JNI=OFF)"
fi

log_success "Build configuration test passed for $impl"
return 0
}

# Test Maven artifact generation
test_maven_artifacts() {
local impl=$1
local preset_key="maven"

log_info "Testing $impl Maven artifact generation..."

if [[ "$impl" == "ffm" ]]; then
preset=${TEST_PRESETS_FFM[$preset_key]}
expected_artifact="hdf5-java-ffm"
else
preset=${TEST_PRESETS_JNI[$preset_key]}
expected_artifact="hdf5-java-jni"
fi

cd "$PROJECT_ROOT"

# Configure with Maven preset
if ! cmake --preset "$preset" -B "$BUILD_DIR"; then
log_error "Maven configuration failed for $impl implementation"
return 1
fi

# Build the project
if ! cmake --build "$BUILD_DIR" --parallel 4; then
log_error "Build failed for $impl implementation"
return 1
fi

# Verify artifact generation
jar_pattern="$BUILD_DIR/java/**/target/${expected_artifact}-*.jar"
if ! ls $jar_pattern 1> /dev/null 2>&1; then
log_error "Expected JAR artifact not found: $expected_artifact"
log_info "Looking for JARs in build directory:"
find "$BUILD_DIR" -name "*.jar" -type f || true
return 1
fi

# Verify JAR manifest
jar_file=$(ls $jar_pattern | head -1)
log_info "Checking JAR manifest: $jar_file"

if ! unzip -q -c "$jar_file" META-INF/MANIFEST.MF | grep -q "HDF5-Java-Implementation: ${impl^^}"; then
log_error "JAR manifest missing implementation metadata"
unzip -q -c "$jar_file" META-INF/MANIFEST.MF || true
return 1
fi

log_success "Maven artifact test passed for $impl"
return 0
}

# Test POM file generation
test_pom_generation() {
local impl=$1

log_info "Testing POM file generation for $impl..."

if [[ "$impl" == "ffm" ]]; then
expected_artifact="hdf5-java-ffm"
expected_desc="Java Foreign Function"
else
expected_artifact="hdf5-java-jni"
expected_desc="Java Native Interface"
fi

# Find generated POM file
pom_file=$(find "$BUILD_DIR" -name "pom.xml" -path "*/java/*" | head -1)

if [[ ! -f "$pom_file" ]]; then
log_error "POM file not found for $impl implementation"
return 1
fi

log_info "Checking POM file: $pom_file"

# Verify artifact ID
if ! grep -q "<artifactId>$expected_artifact</artifactId>" "$pom_file"; then
log_error "POM artifact ID incorrect - expected $expected_artifact"
grep "<artifactId>" "$pom_file" || true
return 1
fi

# Verify description
if ! grep -q "$expected_desc" "$pom_file"; then
log_error "POM description missing expected text: $expected_desc"
grep "<description>" "$pom_file" || true
return 1
fi

log_success "POM generation test passed for $impl"
return 0
}

# Run comprehensive test suite
run_test_suite() {
local impl=$1
local mode=$2

log_info "Running test suite for Java $JAVA_VERSION with $impl implementation (mode: $mode)"

case "$mode" in
"build")
create_build_dir "$impl" "build"
test_build_config "$impl"
;;
"maven")
create_build_dir "$impl" "maven"
test_maven_artifacts "$impl"
test_pom_generation "$impl"
;;
"full")
create_build_dir "$impl" "build"
test_build_config "$impl"

create_build_dir "$impl" "maven"
test_maven_artifacts "$impl"
test_pom_generation "$impl"
;;
*)
log_error "Invalid test mode: $mode (use build, maven, or full)"
return 1
;;
esac
}

# Cleanup function
cleanup() {
if [[ -n "${BUILD_DIR:-}" && -d "$BUILD_DIR" ]]; then
log_info "Cleaning up build directory: $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi
}

# Main execution
main() {
log_info "Java Implementation Test Suite"
log_info "=============================="
log_info "Java Version: $JAVA_VERSION"
log_info "Implementation: $IMPLEMENTATION"
log_info "Test Mode: $TEST_MODE"
log_info ""

# Validate inputs
if ! validate_java_version "$JAVA_VERSION" "$IMPLEMENTATION"; then
exit 1
fi

# Determine actual implementation
actual_impl=$(determine_implementation "$JAVA_VERSION" "$IMPLEMENTATION")
if [[ $? -ne 0 ]]; then
exit 1
fi

log_info "Selected implementation: $actual_impl"
log_info ""

# Set trap for cleanup
trap cleanup EXIT

# Run tests
if run_test_suite "$actual_impl" "$TEST_MODE"; then
log_success "All tests passed for Java $JAVA_VERSION with $actual_impl implementation!"
exit 0
else
log_error "Tests failed for Java $JAVA_VERSION with $actual_impl implementation"
exit 1
fi
}

# Help function
show_help() {
cat << EOF
Java Implementation Test Suite

Usage: $0 [java_version] [implementation] [test_mode]

Arguments:
java_version Java version to test (11, 17, 21, 24, 25) [default: 24]
implementation Implementation to test (auto, ffm, jni) [default: auto]
test_mode Test mode (build, maven, full) [default: build]

Examples:
$0 # Test Java 24 with auto implementation (JNI - default)
$0 24 ffm build # Test Java 24 with FFM (optional), build only
$0 11 jni maven # Test Java 11 with JNI, Maven artifacts
$0 24 auto full # Test Java 24 with auto selection (JNI), full suite

Test Modes:
build - Basic build configuration test
maven - Maven artifact generation and validation
full - Both build and Maven tests

Supported Matrix:
EOF

for version in "${!JAVA_VERSIONS[@]}"; do
echo " Java $version: ${JAVA_VERSIONS[$version]}"
done
}

# Check for help request
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
show_help
exit 0
fi

# Run main function
main
Loading
Loading