Skip to content

Commit b9988df

Browse files
committed
smoke test for NFsim runs with bash and python3 on all platforms
1 parent 8b020bb commit b9988df

File tree

12 files changed

+227
-45
lines changed

12 files changed

+227
-45
lines changed

.github/workflows/cd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
brew install llvm
6565
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/runner/.bash_profile
6666
source /Users/runner/.bash_profile
67+
ln -s $(which gfortran-14) /usr/local/bin/gfortran
6768
6869
gcc --version
6970
gfortran --version
@@ -218,7 +219,7 @@ jobs:
218219
mkdir build
219220
cd build
220221
221-
PATH="/c/Program\ Files/LLVM/bin:$PATH"
222+
export PATH="/c/Program\ Files/LLVM/bin:$PATH"
222223
223224
cmake \
224225
-G Ninja \
@@ -248,6 +249,9 @@ jobs:
248249
echo "working dir is $PWD"
249250
250251
cd build
252+
253+
export PATH="/d/a/_temp/msys64/clang64/bin:$PATH"
254+
pacman -Sy --noconfirm diffutils
251255
252256
ctest -VV
253257

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@
1919
/all_solvers/*
2020

2121
.DS_Store
22+
23+
NFsim_v1.11/tests/smoke/SimID_273069657_0_.gdat
24+
NFsim_v1.11/tests/smoke/SimID_273069657_0_.species

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ if (${OPTION_TARGET_DOCS})
127127
endif()
128128

129129
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
130-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
130+
if (APPLE)
131+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
132+
elseif (MINGW)
133+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
134+
else ()
135+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
136+
endif()
131137
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7" CACHE STRING "Choose minimum deploy target for Macos machines")
132138
endif()
133139

Dockerfile

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
FROM ubuntu:20.04 as build
1+
FROM ubuntu:22.04 as build
22

33
RUN apt-get -y update && apt-get install -y apt-utils && \
44
apt-get install -y -qq -o=Dpkg::Use-Pty=0 build-essential gfortran zlib1g-dev \
5-
libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python
6-
7-
#
8-
# build PETSc with mpich for static linking
9-
#
10-
RUN mkdir /usr/local/petsc && \
11-
cd /usr/local/petsc && \
12-
wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.7.tar.gz && \
13-
tar xzf petsc-3.7.7.tar.gz && \
14-
cd petsc-3.7.7 && \
15-
./configure --with-shared-libraries=0 --download-fblaslapack=1 --with-debugging=1 --download-mpich && \
16-
make PETSC_DIR=/usr/local/petsc/petsc-3.7.7 PETSC_ARCH=arch-linux2-c-debug all
17-
18-
ENV PETSC_DIR=/usr/local/petsc/petsc-3.7.7 \
19-
PETSC_ARCH=arch-linux2-c-debug
5+
libhdf5-dev libcurl4-openssl-dev libboost-dev cmake wget python3
6+
7+
##
8+
## build PETSc with mpich for static linking
9+
##
10+
#RUN mkdir /usr/local/petsc && \
11+
# cd /usr/local/petsc && \
12+
# wget http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.7.7.tar.gz && \
13+
# tar xzf petsc-3.7.7.tar.gz && \
14+
# cd petsc-3.7.7 && \
15+
# ./configure --with-shared-libraries=0 --download-fblaslapack=1 --with-debugging=1 --download-mpich && \
16+
# make PETSC_DIR=/usr/local/petsc/petsc-3.7.7 PETSC_ARCH=arch-linux2-c-debug all
17+
18+
#ENV PETSC_DIR=/usr/local/petsc/petsc-3.7.7 \
19+
# PETSC_ARCH=arch-linux2-c-debug
2020

2121
COPY . /vcellroot
2222

@@ -41,30 +41,30 @@ RUN /usr/bin/cmake \
4141
-DOPTION_TARGET_HY3S_SOLVERS=OFF \
4242
.. && \
4343
make && \
44-
ctest
44+
ctest -VV
4545

46+
##
47+
## build FiniteVolume with PETSc (FiniteVolume_PETSc_x64)
48+
##
49+
#RUN mkdir -p /vcellroot/build_PETSc/bin
50+
#WORKDIR /vcellroot/build_PETSc
4651
#
47-
# build FiniteVolume with PETSc (FiniteVolume_PETSc_x64)
48-
#
49-
RUN mkdir -p /vcellroot/build_PETSc/bin
50-
WORKDIR /vcellroot/build_PETSc
51-
52-
RUN /usr/bin/cmake \
53-
-DOPTION_TARGET_MESSAGING=ON \
54-
-DOPTION_TARGET_PARALLEL=OFF \
55-
-DOPTION_TARGET_PETSC=ON \
56-
-DOPTION_TARGET_CHOMBO2D_SOLVER=OFF \
57-
-DOPTION_TARGET_CHOMBO3D_SOLVER=OFF \
58-
-DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
59-
-DOPTION_TARGET_FV_SOLVER=ON \
60-
-DOPTION_TARGET_STOCHASTIC_SOLVER=OFF \
61-
-DOPTION_TARGET_NFSIM_SOLVER=OFF \
62-
-DOPTION_TARGET_MOVINGBOUNDARY_SOLVER=OFF \
63-
-DOPTION_TARGET_SUNDIALS_SOLVER=OFF \
64-
-DOPTION_TARGET_HY3S_SOLVERS=OFF \
65-
.. && \
66-
make && \
67-
ctest
52+
#RUN /usr/bin/cmake \
53+
# -DOPTION_TARGET_MESSAGING=ON \
54+
# -DOPTION_TARGET_PARALLEL=OFF \
55+
# -DOPTION_TARGET_PETSC=ON \
56+
# -DOPTION_TARGET_CHOMBO2D_SOLVER=OFF \
57+
# -DOPTION_TARGET_CHOMBO3D_SOLVER=OFF \
58+
# -DOPTION_TARGET_SMOLDYN_SOLVER=OFF \
59+
# -DOPTION_TARGET_FV_SOLVER=ON \
60+
# -DOPTION_TARGET_STOCHASTIC_SOLVER=OFF \
61+
# -DOPTION_TARGET_NFSIM_SOLVER=OFF \
62+
# -DOPTION_TARGET_MOVINGBOUNDARY_SOLVER=OFF \
63+
# -DOPTION_TARGET_SUNDIALS_SOLVER=OFF \
64+
# -DOPTION_TARGET_HY3S_SOLVERS=OFF \
65+
# .. && \
66+
# make && \
67+
# ctest
6868

6969

7070
FROM eclipse-temurin:17 as jre-build
@@ -96,7 +96,7 @@ RUN apt-get install -qq -y -o=Dpkg::Use-Pty=0 gcc gfortran zlib1g \
9696
libhdf5-103 libhdf5-cpp-103 libcurl4-openssl-dev zip
9797

9898
COPY --from=build /vcellroot/build/bin /vcellbin
99-
COPY --from=build /vcellroot/build_PETSc/bin/FiniteVolume_PETSc_x64 /vcellbin/
99+
#COPY --from=build /vcellroot/build_PETSc/bin/FiniteVolume_PETSc_x64 /vcellbin/
100100
WORKDIR /vcellbin
101101
ENV PATH=/vcellbin:$PATH
102102

NFsim_v1.11/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,27 @@ endif (UNIX)
8787
set(exe_target NFsim)
8888
if (ARCH_64bit)
8989
set(exe_target ${exe_target}_x64)
90-
endif (ARCH_64bit)
90+
endif (ARCH_64bit)
91+
92+
enable_testing()
9193

9294
add_executable(${exe_target} ${SRC_FILES})
9395
target_link_libraries(${exe_target} vcommons vcellmessaging)
9496

97+
if (MINGW)
98+
set(test_nfsim_exe ${CMAKE_BINARY_DIR}/bin/${exe_target}.exe)
99+
set(python_cmd py)
100+
else (MINGW)
101+
set(test_nfsim_exe ${CMAKE_BINARY_DIR}/bin/${exe_target})
102+
set(python_cmd python3)
103+
endif (MINGW)
104+
set(test_dir ${CMAKE_CURRENT_SOURCE_DIR}/tests/smoke)
105+
106+
# smoke test as a python script
107+
add_test(NAME ${exe_target}_smoke_python COMMAND ${python_cmd} ${test_dir}/smoke.py ${test_nfsim_exe} WORKING_DIRECTORY ${test_dir})
108+
109+
# smoke test as a bash script
110+
add_test(NAME ${exe_target}_smoke_bash COMMAND bash -c "${test_dir}/smoke.sh ${test_nfsim_exe}" WORKING_DIRECTORY ${test_dir})
111+
95112
install(TARGETS ${exe_target} RUNTIME DESTINATION ${OPTION_EXE_DIRECTORY})
96113

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# time O0_MT0_tot_Count O0_MT1_tot_Count O0_MT2_tot_Count O0_MT3_tot_Count O0_MT4_tot_Count s0_Count s1_Count s2_Count s3_Count s4_Count
2+
0.00000000e+00 6.02000000e+02 9.03000000e+02 1.20400000e+03 0.00000000e+00 0.00000000e+00 6.02000000e+02 9.03000000e+02 1.20400000e+03 0.00000000e+00 0.00000000e+00
3+
1.00000000e-01 5.37000000e+02 9.68000000e+02 1.13900000e+03 0.00000000e+00 0.00000000e+00 5.37000000e+02 9.68000000e+02 1.13900000e+03 0.00000000e+00 0.00000000e+00
4+
2.00000000e-01 5.24000000e+02 9.81000000e+02 1.12600000e+03 0.00000000e+00 0.00000000e+00 5.24000000e+02 9.81000000e+02 1.12600000e+03 0.00000000e+00 0.00000000e+00
5+
3.00000000e-01 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00
6+
4.00000000e-01 5.30000000e+02 9.75000000e+02 1.13200000e+03 0.00000000e+00 0.00000000e+00 5.30000000e+02 9.75000000e+02 1.13200000e+03 0.00000000e+00 0.00000000e+00
7+
5.00000000e-01 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00 5.23000000e+02 9.82000000e+02 1.12500000e+03 0.00000000e+00 0.00000000e+00
8+
6.00000000e-01 5.21000000e+02 9.84000000e+02 1.12300000e+03 0.00000000e+00 0.00000000e+00 5.21000000e+02 9.84000000e+02 1.12300000e+03 0.00000000e+00 0.00000000e+00
9+
7.00000000e-01 5.20000000e+02 9.85000000e+02 1.12200000e+03 0.00000000e+00 0.00000000e+00 5.20000000e+02 9.85000000e+02 1.12200000e+03 0.00000000e+00 0.00000000e+00
10+
8.00000000e-01 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00
11+
9.00000000e-01 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00 5.13000000e+02 9.92000000e+02 1.11500000e+03 0.00000000e+00 0.00000000e+00
12+
1.00000000e+00 5.33000000e+02 9.72000000e+02 1.13500000e+03 0.00000000e+00 0.00000000e+00 5.33000000e+02 9.72000000e+02 1.13500000e+03 0.00000000e+00 0.00000000e+00

NFsim_v1.11/tests/smoke/SimID_273069657_0_.nfsimInput

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# nfsim generated species list for system: 'nameless'
2+
# warning! this feature is not yet fully tested!
3+
MT0(AAA~c0,AAB~0) 532
4+
MT1(AAA~c0,AAB~0) 973
5+
MT2(AAA~c0,AAB~0) 1134

NFsim_v1.11/tests/smoke/smoke.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import posixpath
5+
import subprocess
6+
import sys
7+
8+
# get the directory of this script
9+
test_dir = os.path.dirname(os.path.realpath(__file__))
10+
# in the path replace \ with /, D:\ with /d/
11+
test_dir = test_dir.replace("\\", "/")
12+
# tell os.path.join to use / as the path separator
13+
os.path.sep = "/"
14+
exe = sys.argv[1]
15+
16+
print(f"test_dir: {test_dir}")
17+
print(f"exe: {exe}")
18+
19+
input_file = posixpath.join(test_dir, "SimID_273069657_0_.nfsimInput")
20+
output = posixpath.join(test_dir, "SimID_273069657_0_.gdat")
21+
expected_output = posixpath.join(test_dir, "SimID_273069657_0_.gdat.expected")
22+
species = posixpath.join(test_dir, "SimID_273069657_0_.species")
23+
expected_species = posixpath.join(test_dir, "SimID_273069657_0_.species.expected")
24+
25+
if not posixpath.exists(exe):
26+
print(f"NFsim executable {exe} not found. Exiting...")
27+
sys.exit(1)
28+
29+
if not posixpath.exists(input_file):
30+
print(f"Input file {input_file} not found. Exiting...")
31+
sys.exit(1)
32+
33+
if not posixpath.exists(expected_output):
34+
print(f"Expected output file {expected_output} not found. Exiting...")
35+
sys.exit(1)
36+
37+
if not posixpath.exists(expected_species):
38+
print(f"Expected species file {expected_species} not found. Exiting...")
39+
sys.exit(1)
40+
41+
command = [exe, "-seed", "505790288", "-vcell", "-xml", input_file, "-o", output, "-sim", "1.0", "-ss", species, "-oStep", "20", "-notf", "-utl", "1000", "-cb", "-pcmatch", "-tid", "0"]
42+
print(" ".join(command))
43+
44+
try:
45+
subprocess.check_call(command)
46+
except subprocess.CalledProcessError:
47+
print("NFsim failed to run. Exiting...")
48+
sys.exit(1)
49+
50+
# verify that the output files exist
51+
if not os.path.isfile(output):
52+
print(f"Output file {output} not found. Exiting...")
53+
sys.exit(1)
54+
55+
if not os.path.isfile(species):
56+
print(f"Species file {species} not found. Exiting...")
57+
sys.exit(1)
58+
59+
# verify that the output files match the expected output files
60+
if open(output).read() != open(expected_output).read():
61+
print(f"Output file {output} does not match expected output {expected_output}. Exiting...")
62+
sys.exit(1)
63+
64+
if open(species).read() != open(expected_species).read():
65+
print(f"Species file {species} does not match expected species {expected_species}. Exiting...")
66+
sys.exit(1)
67+
68+
print("NFsim solver completed and solution matched expected output. Exiting...")
69+
sys.exit(0)

NFsim_v1.11/tests/smoke/smoke.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -e
3+
EXE=$1
4+
5+
echo "Running NFsim solver with test2.sh $EXE"
6+
7+
# get the directory of this script
8+
TEST_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
9+
10+
INPUT="${TEST_DIR}/SimID_273069657_0_.nfsimInput"
11+
OUTPUT="${TEST_DIR}/SimID_273069657_0_.gdat"
12+
EXPECTED_OUTPUT="${TEST_DIR}/SimID_273069657_0_.gdat.expected"
13+
SPECIES="${TEST_DIR}/SimID_273069657_0_.species"
14+
EXPECTED_SPECIES="${TEST_DIR}/SimID_273069657_0_.species.expected"
15+
16+
if [ ! -f $EXE ]; then
17+
echo "NFsim executable $EXE not found. Exiting..."
18+
exit 1
19+
fi
20+
if [ ! -f $INPUT ]; then
21+
echo "Input file $INPUT not found. Exiting..."
22+
exit 1
23+
fi
24+
if [ ! -f $EXPECTED_OUTPUT ]; then
25+
echo "Expected output file $EXPECTED_OUTPUT not found. Exiting..."
26+
exit 1
27+
fi
28+
if [ ! -f $EXPECTED_SPECIES ]; then
29+
echo "Expected species file $EXPECTED_SPECIES not found. Exiting..."
30+
exit 1
31+
fi
32+
33+
34+
command="$EXE -seed 505790288 -vcell -xml $INPUT -o $OUTPUT -sim 1.0 -ss $SPECIES -oStep 20 -notf -utl 1000 -cb -pcmatch -tid 0"
35+
echo $command
36+
if ! $command; then
37+
echo "NFsim failed to run. Exiting..."
38+
exit 1
39+
fi
40+
41+
# verify that the output files exist
42+
if [ ! -f $OUTPUT ]; then
43+
echo "Output file $OUTPUT not found. Exiting..."
44+
exit 1
45+
fi
46+
if [ ! -f $SPECIES ]; then
47+
echo "Species file $SPECIES not found. Exiting..."
48+
exit 1
49+
fi
50+
51+
# verify that the output files match the expected output files
52+
if ! diff $OUTPUT $EXPECTED_OUTPUT; then
53+
echo "Output file $OUTPUT does not match expected output $EXPECTED_OUTPUT. Exiting..."
54+
exit 1
55+
fi
56+
if ! diff $SPECIES $EXPECTED_SPECIES; then
57+
echo "Species file $SPECIES does not match expected species $EXPECTED_SPECIES. Exiting..."
58+
exit 1
59+
fi
60+
61+
echo "NFsim solver complted and solution matched expected output. Exiting..."
62+
exit 0

0 commit comments

Comments
 (0)