From a97e6027870d1729434c8a816053e6db62af144d Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:28:28 -0300 Subject: [PATCH 01/16] simple test --- .github/workflows/main.yml | 2 +- tests/runff/compare_kml.py | 63 ++++++++++++++++++++++++++++++++++++ tests/runff/simple-test.bash | 38 ++++++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 tests/runff/compare_kml.py create mode 100644 tests/runff/simple-test.bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09970530..305f20eb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: push: branches: - "master" - - "dev-ci" + # - "dev-ci" pull_request: branches: [ "master" ] diff --git a/tests/runff/compare_kml.py b/tests/runff/compare_kml.py new file mode 100644 index 00000000..6dd808da --- /dev/null +++ b/tests/runff/compare_kml.py @@ -0,0 +1,63 @@ +# tests/runff/compare_kml.py +# (Use the exact script provided in the previous response - it parses KML and compares coordinates with tolerance) +# Make sure it's saved in tests/runff/ +import sys +import math +import xml.etree.ElementTree as ET +import re + +# --- Configuration --- +RELATIVE_TOLERANCE = 1e-5 +ABSOLUTE_TOLERANCE = 1e-8 +# --- + +def parse_coordinates(coord_string): + """Parses the KML coordinate string into a list of [lon, lat, alt] floats.""" + points = [] + raw_points = [p for p in re.split(r'\s+', coord_string.strip()) if p] + for point_str in raw_points: + try: + coords = [float(c) for c in point_str.split(',')] + if len(coords) == 2: coords.append(0.0) + if len(coords) == 3: points.append(coords) + else: print(f"Warning: Skipping invalid coordinate tuple: {point_str}", file=sys.stderr) + except ValueError: print(f"Warning: Skipping non-numeric coordinate data: {point_str}", file=sys.stderr) + return points + +def compare_coordinate_lists(list1, list2, rel_tol, abs_tol): + """Compares two lists of coordinates point by point with tolerance.""" + if len(list1) != len(list2): + print(f"Error: Coordinate lists have different lengths ({len(list1)} vs {len(list2)})", file=sys.stderr) + return False + for i, (p1, p2) in enumerate(zip(list1, list2)): + if not math.isclose(p1[0], p2[0], rel_tol=rel_tol, abs_tol=abs_tol) or \ + not math.isclose(p1[1], p2[1], rel_tol=rel_tol, abs_tol=abs_tol) or \ + not math.isclose(p1[2], p2[2], rel_tol=rel_tol, abs_tol=abs_tol): + print(f"Error: Mismatch at coordinate point {i+1}:\n Got: {p1}\n Expected: {p2}", file=sys.stderr) + return False + return True + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python compare_kml.py ", file=sys.stderr) + sys.exit(2) + file1_path, file2_path = sys.argv[1], sys.argv[2] + try: + tree1 = ET.parse(file1_path); root1 = tree1.getroot() + coords1_elements = root1.findall('.//{http://www.opengis.net/kml/2.2}coordinates') or root1.findall('.//coordinates') + coords1_text = "".join([c.text for c in coords1_elements if c.text]) + points1 = parse_coordinates(coords1_text) + + tree2 = ET.parse(file2_path); root2 = tree2.getroot() + coords2_elements = root2.findall('.//{http://www.opengis.net/kml/2.2}coordinates') or root2.findall('.//coordinates') + coords2_text = "".join([c.text for c in coords2_elements if c.text]) + points2 = parse_coordinates(coords2_text) + + if not points1 or not points2: print("Error: Could not extract coordinates.", file=sys.stderr); sys.exit(1) + if compare_coordinate_lists(points1, points2, RELATIVE_TOLERANCE, ABSOLUTE_TOLERANCE): + print(f"KML comparison successful: {file1_path} matches {file2_path} within tolerance.") + sys.exit(0) + else: print(f"KML comparison failed: {file1_path} differs from {file2_path}.", file=sys.stderr); sys.exit(1) + except ET.ParseError as e: print(f"Error parsing XML: {e}", file=sys.stderr); sys.exit(1) + except FileNotFoundError as e: print(f"Error: File not found - {e}", file=sys.stderr); sys.exit(1) + except Exception as e: print(f"An unexpected error occurred: {e}", file=sys.stderr); sys.exit(1) \ No newline at end of file diff --git a/tests/runff/simple-test.bash b/tests/runff/simple-test.bash new file mode 100644 index 00000000..a3aa42e4 --- /dev/null +++ b/tests/runff/simple-test.bash @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +GENERATED_KML="real_case.kml" +REFERENCE_KML="real_case.kml.ref" +# GENERATED_NC="ForeFire.0.nc" # Not checked yet +# REFERENCE_NC="ForeFire.0.nc.ref" # Not checked yet + +FOREFIRE_EXE="../../bin/forefire" + +echo "Running ForeFire simulation (real_case)..." +$FOREFIRE_EXE -i real_case.ff + +# --- Verification --- +echo "Verifying KML output..." + +if ! command -v python3 &> /dev/null +then + echo "Error: python3 command not found. Please install Python 3." + exit 1 +fi + +if [ ! -f compare_kml.py ]; then + echo "Error: compare_kml.py script not found in current directory." + exit 1 +fi + +python3 compare_kml.py "$GENERATED_KML" "$REFERENCE_KML" +echo "KML verification passed." + +# --- NetCDF Check (Commented Out) --- +# echo "Verifying NetCDF output... (SKIPPED)" +# python3 compare_nc.py "$GENERATED_NC" "$REFERENCE_NC" +# echo "NetCDF verification passed." + +echo "Minimal KML test passed for runff." +exit 0 \ No newline at end of file From fc55923756a4fced199938397a7caa3f34ac8e8f Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:33:36 -0300 Subject: [PATCH 02/16] docker in separat yml --- .github/workflows/docker.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/main.yml | 20 +------------------- 2 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..a8838972 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,30 @@ +name: Docker + +on: + push: + branches: + - "master" + - "dev-ci" + pull_request: + branches: [ "master" ] + + workflow_dispatch: + +jobs: + + docker: + runs-on: ubuntu-latest + needs: build-native + steps: + - uses: actions/checkout@v3 + + - name: Build Docker Image + run: docker build -t forefire:latest . + + - name: Test Docker Image + run: | + # Run the container and check the version output + docker run --rm forefire:latest forefire -v + + # - name: Run test inside Docker container + # run: docker run --rm forefire:latest sh ./test-forefire.sh \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 305f20eb..dcff5ccb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,22 +26,4 @@ jobs: run: ./bin/forefire -v # - name: Test - # run: cd tests && bash run.bash - - - docker: - runs-on: ubuntu-latest - needs: build-native - steps: - - uses: actions/checkout@v3 - - - name: Build Docker Image - run: docker build -t forefire:latest . - - - name: Test Docker Image - run: | - # Run the container and check the version output - docker run --rm forefire:latest forefire -v - - # - name: Run test inside Docker container - # run: docker run --rm forefire:latest sh ./test-forefire.sh \ No newline at end of file + # run: cd tests && bash run.bash \ No newline at end of file From fb1762c4cb5beec024be1da707e7dc2482cde006 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:37:40 -0300 Subject: [PATCH 03/16] of course --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a8838972..337ec0ca 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,7 +14,6 @@ jobs: docker: runs-on: ubuntu-latest - needs: build-native steps: - uses: actions/checkout@v3 From bb061aeec8ca29cc7006c9b7c369aff0c32113e5 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:40:55 -0300 Subject: [PATCH 04/16] better docker ci --- .github/workflows/docker.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 337ec0ca..7c47b67e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Docker on: push: branches: - - "master" + - "master" - "dev-ci" pull_request: branches: [ "master" ] @@ -15,15 +15,19 @@ jobs: docker: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Docker Image run: docker build -t forefire:latest . - - - name: Test Docker Image + + - name: Check ForeFire version inside Docker run: | - # Run the container and check the version output docker run --rm forefire:latest forefire -v - # - name: Run test inside Docker container - # run: docker run --rm forefire:latest sh ./test-forefire.sh \ No newline at end of file + # - name: Run KML test inside Docker container + # run: | + # docker run --rm forefire:latest bash -c 'cd /path/to/forefire/tests/runff && bash run.bash' \ No newline at end of file From 8b9542dc1ffb5dae0914485ee79cff6af25b25ec Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:45:58 -0300 Subject: [PATCH 05/16] better naming --- tests/runff/{simple-test.bash => ff-run.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/runff/{simple-test.bash => ff-run.bash} (100%) diff --git a/tests/runff/simple-test.bash b/tests/runff/ff-run.bash similarity index 100% rename from tests/runff/simple-test.bash rename to tests/runff/ff-run.bash From 676e618de39ffe22d467a8fd575cfacc2996a3c8 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:55:05 -0300 Subject: [PATCH 06/16] netcdf test passing on linux --- tests/runff/compare_nc.py | 52 +++++++++++++++++++++++++++++++++++++++ tests/runff/ff-run.bash | 32 +++++++++++------------- 2 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 tests/runff/compare_nc.py diff --git a/tests/runff/compare_nc.py b/tests/runff/compare_nc.py new file mode 100644 index 00000000..5b74273d --- /dev/null +++ b/tests/runff/compare_nc.py @@ -0,0 +1,52 @@ +# tests/runff/compare_nc.py +import sys +import xarray as xr + +# --- Configuration --- +# Adjust tolerance as needed. Start with something reasonable. +RELATIVE_TOLERANCE = 1e-5 +ABSOLUTE_TOLERANCE = 1e-8 +# --- + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python compare_nc.py ", file=sys.stderr) + sys.exit(2) # Exit code for usage error + + file1_path = sys.argv[1] + file2_path = sys.argv[2] + + ds1 = None # Initialize to None + ds2 = None # Initialize to None + try: + # Open datasets using xarray. Ensure they are closed afterwards. + ds1 = xr.open_dataset(file1_path, cache=False) + ds2 = xr.open_dataset(file2_path, cache=False) + + # Compare the datasets numerically with tolerance + # This compares all data variables by default. + # Use `equal = ds1.equals(ds2)` for exact bit-wise comparison (usually too strict) + # Use `identical = ds1.identical(ds2)` for exact comparison including attributes etc. (also often too strict) + xr.testing.assert_allclose(ds1, ds2, rtol=RELATIVE_TOLERANCE, atol=ABSOLUTE_TOLERANCE) + + print(f"NetCDF comparison successful: {file1_path} matches {file2_path} within tolerance.") + sys.exit(0) # Success + + except FileNotFoundError as e: + print(f"Error: NetCDF file not found - {e}", file=sys.stderr) + sys.exit(1) + except AssertionError as e: + # This exception is raised by xr.testing.assert_allclose on failure + print(f"NetCDF comparison failed: {file1_path} differs from {file2_path}.", file=sys.stderr) + print(f"Details from xarray: {e}", file=sys.stderr) + sys.exit(1) # Failure - Datasets are different + except Exception as e: + # Catch other potential errors (e.g., invalid NetCDF format) + print(f"An unexpected error occurred during NetCDF comparison: {e}", file=sys.stderr) + sys.exit(1) # Failure + finally: + # Ensure datasets are closed to release file handles + if ds1 is not None: + ds1.close() + if ds2 is not None: + ds2.close() \ No newline at end of file diff --git a/tests/runff/ff-run.bash b/tests/runff/ff-run.bash index a3aa42e4..1e9f35be 100644 --- a/tests/runff/ff-run.bash +++ b/tests/runff/ff-run.bash @@ -4,9 +4,10 @@ set -e GENERATED_KML="real_case.kml" REFERENCE_KML="real_case.kml.ref" -# GENERATED_NC="ForeFire.0.nc" # Not checked yet -# REFERENCE_NC="ForeFire.0.nc.ref" # Not checked yet +GENERATED_NC="ForeFire.0.nc" +REFERENCE_NC="ForeFire.0.nc.ref" +# --- Simulation --- FOREFIRE_EXE="../../bin/forefire" echo "Running ForeFire simulation (real_case)..." @@ -14,25 +15,20 @@ $FOREFIRE_EXE -i real_case.ff # --- Verification --- echo "Verifying KML output..." - -if ! command -v python3 &> /dev/null -then - echo "Error: python3 command not found. Please install Python 3." - exit 1 -fi - -if [ ! -f compare_kml.py ]; then - echo "Error: compare_kml.py script not found in current directory." - exit 1 -fi +# Make sure python3 is available and comparison script exists +if ! command -v python3 &> /dev/null; then echo "Error: python3 required."; exit 1; fi +if [ ! -f compare_kml.py ]; then echo "Error: compare_kml.py not found."; exit 1; fi python3 compare_kml.py "$GENERATED_KML" "$REFERENCE_KML" echo "KML verification passed." -# --- NetCDF Check (Commented Out) --- -# echo "Verifying NetCDF output... (SKIPPED)" -# python3 compare_nc.py "$GENERATED_NC" "$REFERENCE_NC" -# echo "NetCDF verification passed." +echo "Verifying NetCDF output..." +if [ ! -f compare_nc.py ]; then echo "Error: compare_nc.py not found."; exit 1; fi +# Check if the expected output NetCDF file was actually created +if [ ! -f "$GENERATED_NC" ]; then echo "Error: Expected NetCDF output file '$GENERATED_NC' not found."; exit 1; fi + +python3 compare_nc.py "$GENERATED_NC" "$REFERENCE_NC" +echo "NetCDF verification passed." -echo "Minimal KML test passed for runff." +echo "All KML and NetCDF verifications passed for runff test." exit 0 \ No newline at end of file From c6c52b1f8af6ab7f68088ed2e687814b199c8935 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 02:58:08 -0300 Subject: [PATCH 07/16] linux testing? --- .github/workflows/docker.yml | 10 +++------- .github/workflows/main.yml | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 7c47b67e..e0ccfa77 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,14 +4,14 @@ on: push: branches: - "master" - - "dev-ci" + # - "dev-ci" pull_request: branches: [ "master" ] workflow_dispatch: jobs: - + docker: runs-on: ubuntu-latest steps: @@ -26,8 +26,4 @@ jobs: - name: Check ForeFire version inside Docker run: | - docker run --rm forefire:latest forefire -v - - # - name: Run KML test inside Docker container - # run: | - # docker run --rm forefire:latest bash -c 'cd /path/to/forefire/tests/runff && bash run.bash' \ No newline at end of file + docker run --rm forefire:latest forefire -v \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dcff5ccb..f8efc70a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,27 +3,42 @@ name: Linux on: push: branches: - - "master" - # - "dev-ci" + - "master" + - "dev-ci" pull_request: branches: [ "master" ] workflow_dispatch: jobs: - build-native: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Dependencies (Build + Test) + run: | + sudo apt-get update -y + # Install essentials, Python, pip, and NetCDF C libs + sudo apt-get install -y --no-install-recommends \ + build-essential \ + python3 \ + python3-pip \ + libnetcdf-dev + # Install Python test libraries + pip3 install --no-cache-dir \ + lxml \ + xarray \ + netCDF4 - name: ForeFire build run: sudo bash ./install-forefire.sh -y - - name: Check version + - name: Check ForeFire version run: ./bin/forefire -v - # - name: Test - # run: cd tests && bash run.bash \ No newline at end of file + - name: Run 'runff' Test (KML and NetCDF) + run: | + cd tests/runff + bash ff-run.bash \ No newline at end of file From 95e3232401b32f0153b6d9ebed13b53fb667c2fd Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 03:11:50 -0300 Subject: [PATCH 08/16] try now --- .github/workflows/main.yml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8efc70a..8182d789 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,6 @@ on: - "dev-ci" pull_request: branches: [ "master" ] - workflow_dispatch: jobs: @@ -16,17 +15,26 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + with: + lfs: true - name: Install Dependencies (Build + Test) run: | sudo apt-get update -y - # Install essentials, Python, pip, and NetCDF C libs + # Install build tools required by install-forefire.sh and general use sudo apt-get install -y --no-install-recommends \ build-essential \ + cmake + # Install NetCDF libraries needed for BUILD (C++ legacy) and TEST (C base for Python) + sudo apt-get install -y --no-install-recommends \ + libnetcdf-dev \ + libnetcdf-c++4-dev + # Install Python and pip + sudo apt-get install -y --no-install-recommends \ python3 \ - python3-pip \ - libnetcdf-dev - # Install Python test libraries + python3-pip + + # --- Install Python TEST dependencies --- pip3 install --no-cache-dir \ lxml \ xarray \ @@ -38,7 +46,17 @@ jobs: - name: Check ForeFire version run: ./bin/forefire -v + - name: Add Build/Runtime Diagnostics (Optional but helpful) + run: | + echo "--- ForeFire Linkage ---" + # Check dynamic linkage against NetCDF libraries + ldd ./bin/forefire | grep -i 'netcdf' || echo "Warning: NetCDF library not dynamically linked?" + echo "--- data.nc Format ---" + # Install ncdump tool and check the format kind of the input NetCDF + sudo apt-get install -y --no-install-recommends netcdf-bin + ncdump -k tests/runff/data.nc || echo "Could not check data.nc format (ncdump failed)" + - name: Run 'runff' Test (KML and NetCDF) run: | cd tests/runff - bash ff-run.bash \ No newline at end of file + bash ff-run.bash # Ensure this is the correct name of your test script \ No newline at end of file From 989e1ec9e9143c47eacb69badb3b5f40d6c536b0 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 03:24:56 -0300 Subject: [PATCH 09/16] faster compilation --- install-forefire.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-forefire.sh b/install-forefire.sh index 9f847629..51844ed7 100644 --- a/install-forefire.sh +++ b/install-forefire.sh @@ -37,7 +37,7 @@ BIN_PATH="$PROJECT_ROOT/bin" mkdir -p build cd build cmake ../ -make +make -j"$(nproc)" echo -e "\n=== ForeFire has been installed to $BIN_PATH ===\n" From b32ee789c3cb2494b85e66c6960fd109099d8ffe Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 03:28:15 -0300 Subject: [PATCH 10/16] lets try --- .github/workflows/main.yml | 62 +++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8182d789..5d8c409d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,29 +16,22 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - lfs: true + lfs: true # Keep enabled as you use LFS - name: Install Dependencies (Build + Test) run: | sudo apt-get update -y - # Install build tools required by install-forefire.sh and general use - sudo apt-get install -y --no-install-recommends \ - build-essential \ - cmake - # Install NetCDF libraries needed for BUILD (C++ legacy) and TEST (C base for Python) - sudo apt-get install -y --no-install-recommends \ - libnetcdf-dev \ - libnetcdf-c++4-dev + # Install build tools + sudo apt-get install -y --no-install-recommends build-essential cmake + # Install NetCDF libraries + sudo apt-get install -y --no-install-recommends libnetcdf-dev libnetcdf-c++4-dev # Install Python and pip - sudo apt-get install -y --no-install-recommends \ - python3 \ - python3-pip - - # --- Install Python TEST dependencies --- - pip3 install --no-cache-dir \ - lxml \ - xarray \ - netCDF4 + sudo apt-get install -y --no-install-recommends python3 python3-pip + # Install strace for debugging + sudo apt-get install -y --no-install-recommends strace + # === ADD ANY OTHER ForeFire build dependencies (e.g. MPI) === + # pip install test dependencies + pip3 install --no-cache-dir lxml xarray netCDF4 - name: ForeFire build run: sudo bash ./install-forefire.sh -y @@ -46,17 +39,36 @@ jobs: - name: Check ForeFire version run: ./bin/forefire -v - - name: Add Build/Runtime Diagnostics (Optional but helpful) + - name: Add Build/Runtime Diagnostics run: | echo "--- ForeFire Linkage ---" - # Check dynamic linkage against NetCDF libraries ldd ./bin/forefire | grep -i 'netcdf' || echo "Warning: NetCDF library not dynamically linked?" - echo "--- data.nc Format ---" - # Install ncdump tool and check the format kind of the input NetCDF + echo "--- Input data.nc Info ---" + # Check file size as a basic LFS sanity check + ls -lh tests/runff/data.nc + # Install ncdump tool and check the format kind sudo apt-get install -y --no-install-recommends netcdf-bin - ncdump -k tests/runff/data.nc || echo "Could not check data.nc format (ncdump failed)" + ncdump -k tests/runff/data.nc || echo "Could not check data.nc format" - - name: Run 'runff' Test (KML and NetCDF) + - name: Run 'runff' Test (with strace Debugging) + # Use && for safer execution flow + # Check exit code explicitly + # Wrap ForeFire call in strace run: | cd tests/runff - bash ff-run.bash # Ensure this is the correct name of your test script \ No newline at end of file + echo "--- Running ForeFire with strace ---" + # Execute ForeFire under strace, logging output to strace_output.txt + strace -o strace_output.txt ../../bin/forefire -i real_case.ff + FOREFIRE_EXIT_CODE=$? + echo "--- ForeFire Exited with Code: $FOREFIRE_EXIT_CODE ---" + # Display last few lines of strace output + echo "--- Last lines of strace output ---" + tail -n 50 strace_output.txt || echo "strace output file not found or empty." + # Fail explicitly if ForeFire exited with non-zero code + if [ $FOREFIRE_EXIT_CODE -ne 0 ]; then + echo "ForeFire failed with exit code $FOREFIRE_EXIT_CODE" + exit $FOREFIRE_EXIT_CODE + fi + # Proceed with verification script only if ForeFire succeeded + echo "--- Running Verification Script ---" + bash ff-run.bash \ No newline at end of file From 4a9f032e50f6979a50e352b3dcff67776b86ff47 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 03:34:58 -0300 Subject: [PATCH 11/16] test again --- .github/workflows/main.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d8c409d..aaf877f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,21 +54,25 @@ jobs: # Use && for safer execution flow # Check exit code explicitly # Wrap ForeFire call in strace + + - name: Run 'runff' Test (Check Files, No strace) run: | cd tests/runff - echo "--- Running ForeFire with strace ---" - # Execute ForeFire under strace, logging output to strace_output.txt - strace -o strace_output.txt ../../bin/forefire -i real_case.ff + echo "--- Running ForeFire ---" + # Run ForeFire normally first + ../../bin/forefire -i real_case.ff FOREFIRE_EXIT_CODE=$? echo "--- ForeFire Exited with Code: $FOREFIRE_EXIT_CODE ---" - # Display last few lines of strace output - echo "--- Last lines of strace output ---" - tail -n 50 strace_output.txt || echo "strace output file not found or empty." - # Fail explicitly if ForeFire exited with non-zero code + + echo "--- Listing files in $(pwd) ---" + ls -la + + # Fail if ForeFire failed if [ $FOREFIRE_EXIT_CODE -ne 0 ]; then echo "ForeFire failed with exit code $FOREFIRE_EXIT_CODE" exit $FOREFIRE_EXIT_CODE fi + # Proceed with verification script only if ForeFire succeeded echo "--- Running Verification Script ---" bash ff-run.bash \ No newline at end of file From 6d951b4f762dfb0e2ac4e107ef9a5a7f9adf2d0e Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 03:35:53 -0300 Subject: [PATCH 12/16] t bete --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aaf877f1..2f91d494 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,10 +50,6 @@ jobs: sudo apt-get install -y --no-install-recommends netcdf-bin ncdump -k tests/runff/data.nc || echo "Could not check data.nc format" - - name: Run 'runff' Test (with strace Debugging) - # Use && for safer execution flow - # Check exit code explicitly - # Wrap ForeFire call in strace - name: Run 'runff' Test (Check Files, No strace) run: | From c46a52b1678f24d14648f6c3ac15fb05b06d1a16 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 04:05:12 -0300 Subject: [PATCH 13/16] arg cetait facile --- tests/runff/ff-run.bash | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/runff/ff-run.bash b/tests/runff/ff-run.bash index 1e9f35be..7d8b40ce 100644 --- a/tests/runff/ff-run.bash +++ b/tests/runff/ff-run.bash @@ -6,14 +6,28 @@ GENERATED_KML="real_case.kml" REFERENCE_KML="real_case.kml.ref" GENERATED_NC="ForeFire.0.nc" REFERENCE_NC="ForeFire.0.nc.ref" +GENERATED_RELOAD="to_reload.ff" + +# --- Cleanup previous run artifacts --- +echo "Cleaning up previous test artifacts..." +rm -f "$GENERATED_KML" "$GENERATED_NC" "$GENERATED_RELOAD" # --- Simulation --- FOREFIRE_EXE="../../bin/forefire" +echo "" echo "Running ForeFire simulation (real_case)..." $FOREFIRE_EXE -i real_case.ff +echo "Running ForeFire simulation (reload_case)..." +if [ ! -f "$GENERATED_RELOAD" ]; then + echo "Error: State file '$GENERATED_RELOAD' needed for second run was not created." + exit 1 +fi +$FOREFIRE_EXE -i reload_case.ff # <<<--- ADDED SECOND RUN + # --- Verification --- +echo "" echo "Verifying KML output..." # Make sure python3 is available and comparison script exists if ! command -v python3 &> /dev/null; then echo "Error: python3 required."; exit 1; fi @@ -24,7 +38,7 @@ echo "KML verification passed." echo "Verifying NetCDF output..." if [ ! -f compare_nc.py ]; then echo "Error: compare_nc.py not found."; exit 1; fi -# Check if the expected output NetCDF file was actually created +# Check if the NetCDF file was created (likely by the first run) if [ ! -f "$GENERATED_NC" ]; then echo "Error: Expected NetCDF output file '$GENERATED_NC' not found."; exit 1; fi python3 compare_nc.py "$GENERATED_NC" "$REFERENCE_NC" From 8b438d3cfbbd71189dca8fde157009170b458761 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 04:13:01 -0300 Subject: [PATCH 14/16] simpler ci --- .github/workflows/main.yml | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f91d494..d3dc8cd2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,14 +23,14 @@ jobs: sudo apt-get update -y # Install build tools sudo apt-get install -y --no-install-recommends build-essential cmake - # Install NetCDF libraries + # Install NetCDF libraries (C++ legacy for build, C base for Python test) sudo apt-get install -y --no-install-recommends libnetcdf-dev libnetcdf-c++4-dev # Install Python and pip sudo apt-get install -y --no-install-recommends python3 python3-pip - # Install strace for debugging + # Keep strace installed for potential future debugging sudo apt-get install -y --no-install-recommends strace # === ADD ANY OTHER ForeFire build dependencies (e.g. MPI) === - # pip install test dependencies + # pip install Python test dependencies pip3 install --no-cache-dir lxml xarray netCDF4 - name: ForeFire build @@ -39,36 +39,19 @@ jobs: - name: Check ForeFire version run: ./bin/forefire -v + # --- KEEPING DIAGNOSTIC STEPS --- - name: Add Build/Runtime Diagnostics run: | echo "--- ForeFire Linkage ---" ldd ./bin/forefire | grep -i 'netcdf' || echo "Warning: NetCDF library not dynamically linked?" echo "--- Input data.nc Info ---" - # Check file size as a basic LFS sanity check ls -lh tests/runff/data.nc # Install ncdump tool and check the format kind sudo apt-get install -y --no-install-recommends netcdf-bin ncdump -k tests/runff/data.nc || echo "Could not check data.nc format" + # --- END DIAGNOSTIC STEPS --- - - - name: Run 'runff' Test (Check Files, No strace) + - name: Run 'runff' Test Script run: | cd tests/runff - echo "--- Running ForeFire ---" - # Run ForeFire normally first - ../../bin/forefire -i real_case.ff - FOREFIRE_EXIT_CODE=$? - echo "--- ForeFire Exited with Code: $FOREFIRE_EXIT_CODE ---" - - echo "--- Listing files in $(pwd) ---" - ls -la - - # Fail if ForeFire failed - if [ $FOREFIRE_EXIT_CODE -ne 0 ]; then - echo "ForeFire failed with exit code $FOREFIRE_EXIT_CODE" - exit $FOREFIRE_EXIT_CODE - fi - - # Proceed with verification script only if ForeFire succeeded - echo "--- Running Verification Script ---" - bash ff-run.bash \ No newline at end of file + bash ff-run.bash # Execute the complete test logic script \ No newline at end of file From 1d0690599cef03890e4e54c9083a88870d6acd09 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 04:36:21 -0300 Subject: [PATCH 15/16] add testing file --- TESTING.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 TESTING.md diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 00000000..dabd6859 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,41 @@ +# Testing ForeFire + +This document describes how to run the automated tests for the ForeFire wildfire simulator. Tests are located within the `tests/` directory. + +## Test Dependencies + +Running the test verification scripts requires: + +* **Python 3** +* **Python Libraries:** `lxml`, `xarray`, `netCDF4` (and their C dependencies like `libnetcdf-dev`). + +Install Python libraries via pip: +```bash +pip3 install lxml xarray netCDF4 +``` + +## Running the Core Test (`runff`) + +The primary automated test, validated in our CI pipeline, is located in `tests/runff/`. This test verifies core simulation, save/reload functionality, and NetCDF/KML output generation against reference files. + +**To run this test manually:** + +1. Ensure ForeFire is compiled (e.g., via `install-forefire.sh`). +2. Navigate to the test directory: `cd tests/runff` +3. Execute the test script: `bash ff-run.bash` + +**Test Logic:** + +The `ff-run.bash` script: +1. Runs an initial simulation (`real_case.ff`) generating NetCDF output (`ForeFire.0.nc`) and a reload file (`to_reload.ff`). +2. Runs a second simulation (`reload_case.ff`) using the reload file, which generates KML output (`real_case.kml`). +3. Uses Python scripts (`compare_kml.py`, `compare_nc.py`) to compare the generated KML and NetCDF files against reference files (`*.ref`) with numerical tolerance, accounting for minor floating-point variations. +4. Exits with status 0 on success, non-zero on failure. + +## Other Tests + +The `tests/` directory contains other subdirectories (`mnh_*`, `python`, `runANN`) for potentially testing specific features like coupled simulations or Python bindings. A main `tests/run.bash` script exists but is not currently fully validated in CI. Refer to specific subdirectories for details if needed. + +## Contributing + +Please see `CONTRIBUTING.md` for guidelines on contributing to ForeFire, including adding new tests. Report any issues via the repository's issue tracker. \ No newline at end of file From cfbe4a63118dd6df8d872c3ed07499bf08eaa583 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 04:39:08 -0300 Subject: [PATCH 16/16] uncomment --- tests/runff/compare_kml.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/runff/compare_kml.py b/tests/runff/compare_kml.py index 6dd808da..ff69011c 100644 --- a/tests/runff/compare_kml.py +++ b/tests/runff/compare_kml.py @@ -1,6 +1,3 @@ -# tests/runff/compare_kml.py -# (Use the exact script provided in the previous response - it parses KML and compares coordinates with tolerance) -# Make sure it's saved in tests/runff/ import sys import math import xml.etree.ElementTree as ET