Skip to content
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

introduce ctest #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ jobs:
matrix:
# os: ['ubuntu-22.04']
python-version: ['3.9', '3.12']
sample: [mapper, minsearch, exchange, exchange_mesh, pamc, bayes, transform]
fail-fast: false

name: ${{ matrix.sample }} with Python ${{ matrix.python-version }}
name: Run tests with Python ${{ matrix.python-version }}
runs-on: 'ubuntu-22.04'
# runs-on: ${{ matrix.os }}
timeout-minutes: 10
Expand All @@ -38,7 +37,7 @@ jobs:
python -m pip install numpy scipy tomli mpi4py
python -m pip install physbo

- name: ${{ matrix.sample }}
- name: run
run: |
cd ${GITHUB_WORKSPACE}/tests/${{ matrix.sample }}
sh ./do.sh
mkdir build && cd build && cmake ..
ctest -V
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.5)
project(ODAT-SE)
enable_testing()
add_subdirectory(tests)
65 changes: 65 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
add_test(
NAME bayes
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/bayes
)

add_test(
NAME exchange
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/exchange
)

add_test(
NAME exchange_mesh
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/exchange_mesh
)

add_test(
NAME mapper
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/mapper
)

add_test(
NAME minsearch
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/minsearch
)

add_test(
NAME pamc
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/pamc
)

add_test(
NAME transform
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/transform
)

add_test(
NAME bayes_continue
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/bayes_continue
)

add_test(
NAME exchange_continue
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/exchange_continue
)

add_test(
NAME mapper_resume
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/mapper_resume
)

add_test(
NAME pamc_continue
COMMAND sh do.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests/pamc_continue
)
2 changes: 2 additions & 0 deletions tests/bayes/do.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Remove the output directory if it exists
rm -rf output

Expand Down
4 changes: 3 additions & 1 deletion tests/bayes_continue/do.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Command to run the main Python script
CMD="python3 -u ../../src/odatse_main.py"
CMD="python3 ../../src/odatse_main.py"

# Remove the output1 directory if it exists
rm -rf output1
Expand Down
7 changes: 5 additions & 2 deletions tests/exchange/do.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh

export PYTHONUNBUFFERED=1
export OMPI_MCA_rmaps_base_oversubscribe=1

# Remove the output directory if it exists
rm -rf output

# Run the Python script using mpiexec with 4 processes and measure the time taken
time mpiexec --oversubscribe -np 4 python3 ../../src/odatse_main.py input.toml
time mpiexec -np 4 python3 ../../src/odatse_main.py input.toml

# Define the result file path
resfile=output/best_result.txt
Expand All @@ -23,4 +26,4 @@ else
# If the files differ, print TEST FAILED with the result file path
echo TEST FAILED: $resfile and ref.txt differ
false
fi
fi
7 changes: 5 additions & 2 deletions tests/exchange_continue/do.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/bin/sh

export PYTHONUNBUFFERED=1
export OMPI_MCA_rmaps_base_oversubscribe=1

# Command to run the Python script with MPI
CMD="mpiexec --oversubscribe -np 4 python3 -u ../../src/odatse_main.py"
CMD="mpiexec -np 4 python3 ../../src/odatse_main.py"

# Remove the output1 directory if it exists
rm -rf output1
Expand Down Expand Up @@ -35,4 +38,4 @@ if [ $res -eq 0 ]; then
else
echo TEST FAILED: $resfile and $reffile differ
false
fi
fi
4 changes: 3 additions & 1 deletion tests/exchange_mesh/do.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Remove the output directory if it exists
rm -rf output

Expand Down Expand Up @@ -32,4 +34,4 @@ else
# Output TEST FAILED if files differ
echo TEST FAILED: $resfile and ref.txt differ
false
fi
fi
7 changes: 5 additions & 2 deletions tests/mapper/do.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh

export PYTHONUNBUFFERED=1
export OMPI_MCA_rmaps_base_oversubscribe=1

# Remove the output directory if it exists
rm -rf output

# Run the Python script with MPI, using 2 processes
time mpiexec --oversubscribe -np 2 python3 ../../src/odatse_main.py input.toml
time mpiexec -np 2 python3 ../../src/odatse_main.py input.toml

# Define the result file path
resfile=output/ColorMap.txt
Expand All @@ -21,4 +24,4 @@ if [ $res -eq 0 ]; then
else
echo TEST FAILED: $resfile and ref.txt differ
false
fi
fi
8 changes: 5 additions & 3 deletions tests/mapper_resume/do.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Command to run the main Python script
CMD="python3 -u ../../src/odatse_main.py"
CMD="python3 ../../src/odatse_main.py"
# Uncomment the following line to run with MPI
# CMD="mpiexec -np 2 python3 -u ../../src/odatse_main.py"
# CMD="mpiexec -np 2 python3 ../../src/odatse_main.py"

# Remove the output1 directory if it exists
rm -rf output1
Expand Down Expand Up @@ -40,4 +42,4 @@ if [ $res -eq 0 ]; then
else
echo TEST FAILED: $resfile and $reffile differ
false
fi
fi
4 changes: 3 additions & 1 deletion tests/minsearch/do.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Remove the output directory if it exists
rm -rf output

Expand Down Expand Up @@ -27,4 +29,4 @@ else
# If the files differ, print TEST FAILED with the file names
echo TEST FAILED: $resfile and ref.txt differ
false
fi
fi
7 changes: 5 additions & 2 deletions tests/pamc/do.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#!/bin/sh

export PYTHONUNBUFFERED=1
export OMPI_MCA_rmaps_base_oversubscribe=1

# Remove the output directory if it exists
rm -rf output

# Run the Python script using MPI with 2 processes
time mpiexec --oversubscribe -np 2 python3 -m mpi4py ../../src/odatse_main.py input.toml
time mpiexec -np 2 python3 -m mpi4py ../../src/odatse_main.py input.toml

# Define the result file path
resfile=output/best_result.txt
Expand All @@ -21,4 +24,4 @@ if [ $res -eq 0 ]; then
else
echo TEST FAILED: $resfile and ref.txt differ
false
fi
fi
19 changes: 11 additions & 8 deletions tests/pamc_continue/do.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
#!/bin/sh

export PYTHONUNBUFFERED=1
export OMPI_MCA_rmaps_base_oversubscribe=1

# Command to run the Python script with MPI
CMD="mpiexec --oversubscribe -np 2 python3 -u ../../src/odatse_main.py"
CMD="mpiexec -np 2 python3 ../../src/odatse_main.py"

# Remove the output1 directory if it exists
rm -rf output1

# Run the command with input1a.toml and log the output
time $CMD input1a.toml 2>&1 | tee run.log.1a
# Run the command with input1a.toml
time $CMD input1a.toml

# Run the command with input1b.toml in continuation mode and log the output
time $CMD --cont input1b.toml 2>&1 | tee run.log.1b
# Run the command with input1b.toml in continuation mode
time $CMD --cont input1b.toml

# Remove the output2 directory if it exists
rm -rf output2

# Run the command with input2.toml and log the output
time $CMD input2.toml 2>&1 | tee run.log.2
# Run the command with input2.toml
time $CMD input2.toml

# Define the result and reference files for comparison
# resfile=output1/best_result.txt
Expand All @@ -40,4 +43,4 @@ if [ $res -eq 0 ]; then
else
echo TEST FAILED: $resfile and $reffile differ
false
fi
fi
4 changes: 3 additions & 1 deletion tests/transform/do.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

export PYTHONUNBUFFERED=1

# Remove the existing ColorMap.txt file from the output_transform directory
rm -f output_transform/ColorMap.txt

Expand All @@ -25,4 +27,4 @@ if [ $res = 0 ]; then
else
echo "TEST FAILED (diff = $res)"
false
fi
fi