Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
641d59b
Add nproc.sh as a replacement for nproc
drroe Mar 4, 2021
53f22ce
Use nproc.sh for CPPTRAJ_NPROC
drroe Mar 5, 2021
c5e07a5
Remove nproc
drroe Mar 5, 2021
d995897
Move to test directory
drroe Mar 5, 2021
cc03f0a
Only rely on CPPTRAJ_TEST_ROOT for test utilities
drroe Mar 5, 2021
ab0e62b
Remove references to CPPTRAJSRC
drroe Mar 5, 2021
a91b135
Keep CPPTRAJSRC. Useful for unit tests
drroe Mar 5, 2021
1ddf377
Start adding unit tests
drroe Mar 5, 2021
77b3393
Fix individual unit test invocation
drroe Mar 5, 2021
4811157
Start adding results for unit tests that can be tallied by summary
drroe Mar 5, 2021
7e4e97d
Add target for unit tests
drroe Mar 5, 2021
059a053
Ensure DIRECTIVES is used in compiling unit test
drroe Mar 5, 2021
8f31d47
Move the unit tests to a separate location
drroe Mar 5, 2021
9be6a9b
Start making this independent from the regular test framework
drroe Mar 5, 2021
c0d5a1e
Add summary and target variables
drroe Mar 5, 2021
985a9f2
Add Summary function
drroe Mar 5, 2021
c65e5fc
Make unit tests pass/fail
drroe Mar 5, 2021
49ac38b
Dont make unit tests rely on CPPTRAJHOME
drroe Mar 5, 2021
f07925b
Have EndTest exit with a status. Fix output.
drroe Mar 5, 2021
2456c4e
Use EndTest, not exit
drroe Mar 5, 2021
792e371
Fix test rule
drroe Mar 5, 2021
5b2ac63
Add ArgList unit test
drroe Mar 5, 2021
d431fea
Add more tests.
drroe Mar 5, 2021
e91d146
Enabled ArgList test
drroe Mar 5, 2021
da232c6
Add top-level rule for unit tests
drroe Mar 5, 2021
e14aa7e
Do not need CPPTRAJSRC
drroe Mar 5, 2021
9d81a2b
Remove now-defunct bundled unit test stuff
drroe Mar 5, 2021
8e74ff5
Remove defunct unit test target
drroe Mar 5, 2021
4bb7a88
Add unit tests to Jenkins
drroe Mar 5, 2021
4bf2aab
Hail mary - switch from openmpi to mpich to try to resolve package ti…
drroe Mar 6, 2021
e3cd41d
Another hail mary - revert to openmpi and add apt update
drroe Mar 6, 2021
f233726
Try to fix lgtm
drroe Mar 6, 2021
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
1 change: 1 addition & 0 deletions .github/workflows/merge-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
steps:
- name: Install prerequisite packages
run: |
sudo apt update
sudo apt-get install gfortran \
libbz2-dev \
libblas-dev \
Expand Down
16 changes: 16 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ pipeline {
}
}
parallel {
stage("Linux GNU Unit Tests") {
agent {
docker {
image 'ambermd/cpu-build:latest'
alwaysPull true
}
}

steps {
unstash "source"
sh "./configure --with-netcdf --with-fftw3 gnu"
sh "cd unitTests && make test.all"
}

post { cleanup { deleteDir() } }
}
stage("Linux GNU serial build") {
agent {
docker {
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ libstatic: config.h
check: config.h
cd test && $(MAKE) test.complete summary

unittest: config.h
cd unitTests && $(MAKE) test.complete summary

# Clean up
clean: config.h
cd src && $(MAKE) clean
cd test && $(MAKE) clean
cd unitTests && $(MAKE) clean

docs: src/cpptraj.Doxyfile
cd src && doxygen cpptraj.Doxyfile
Expand Down
11 changes: 2 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ EXE='' # Binary executable suffix
REBUILDOPT='' # Can be set to --rebuild and passed to get_library.sh
BUILDTESTOPT='silent' # Set to blank to avoid asking about building libraries
INSTALL_DAT='install_dat' # Target for installing data directory
CPPTRAJSRC='' # CPPTRAJ source directory
#CPPTRAJSRC='' # CPPTRAJ source directory
COMPERR='cpptrajcfg.compile.err'
COMPOUT='cpptrajcfg.compile.out'

Expand Down Expand Up @@ -2260,7 +2260,7 @@ fi
if [ "$WORKDIR" != '.' ] ; then
Err "CPPTRAJ configure must be executed from the source directory."
fi
CPPTRAJSRC=$CURRENTDIR
#CPPTRAJSRC=$CURRENTDIR

# Basic checks and directives
BasicChecks
Expand Down Expand Up @@ -2406,11 +2406,6 @@ if [ $USE_SHARED -eq 1 ] ; then
else
LIBCPPTRAJ_TARGET='nolibcpptraj'
fi
# Only build nproc for MPI
if [ $USE_MPI -ne 0 ] ; then
NPROC_TARGET=nproc
INSTALL_TARGETS=$INSTALL_TARGETS" $NPROC_TARGET"
fi
# CUDA
if [ $USE_CUDA -eq 1 ] ; then
CUDA_TARGET='cuda_kernels/libcpptraj_cuda.a'
Expand Down Expand Up @@ -2532,7 +2527,6 @@ if [ "$PERFORM_CHECKS" = 'yes' ] ; then
RFILE=$CPPTRAJHOME/cpptraj.sh
cat > $RFILE <<EOF
export CPPTRAJHOME="$CPPTRAJHOME"
export CPPTRAJSRC="$CPPTRAJSRC"
export PATH=$CPPTRAJBIN:\${PATH}
EOF
if [ "$PLATFORM" != "Darwin" ] ; then
Expand All @@ -2543,7 +2537,6 @@ EOF
RFILE=$CPPTRAJHOME/cpptraj.csh
cat > $RFILE <<EOF
setenv CPPTRAJHOME "$CPPTRAJHOME"
setenv CPPTRAJSRC "$CPPTRAJSRC"
setenv PATH "$CPPTRAJBIN:\${PATH}"
EOF
if [ "$PLATFORM" != "Darwin" ] ; then
Expand Down
1 change: 1 addition & 0 deletions lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ path_classifiers:
test:
- "src/readline/*"
- "src/tng/*"
- "unitTests/*/*"
extraction:
cpp:
prepare:
Expand Down
4 changes: 0 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ nolibcpptraj:
@echo ""
@exit 1

# nproc --------------------------------
nproc:
cd ../util && $(MAKE)

# Internal object/library targets
pub_fft.o: pub_fft.F90
$(FC) $(FPPFLAGS) -c $(FFLAGS) -o $@ pub_fft.F90
Expand Down
20 changes: 4 additions & 16 deletions test/MasterTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ SetNthreads() {
export N_THREADS=1
return 1
fi
export N_THREADS=`$DO_PARALLEL $CPPTRAJ_NPROC`
export N_THREADS=`$CPPTRAJ_NPROC`
echo " $N_THREADS MPI threads."
fi
return 0
Expand Down Expand Up @@ -835,13 +835,7 @@ SetBinaries() {
fi
# Determine location of ndiff.awk
if [ -z "$CPPTRAJ_NDIFF" ] ; then
if [ $STANDALONE -eq 0 ] ; then
CPPTRAJ_NDIFF=$DIRPREFIX/test/ndiff.awk
elif [ ! -z "$CPPTRAJSRC" ] ; then
CPPTRAJ_NDIFF=$CPPTRAJSRC/util/ndiff/ndiff.awk
else
CPPTRAJ_NDIFF=$CPPTRAJ_TEST_ROOT/../util/ndiff/ndiff.awk
fi
CPPTRAJ_NDIFF=$CPPTRAJ_TEST_ROOT/utilities/ndiff/ndiff.awk
if [ ! -f "$CPPTRAJ_NDIFF" ] ; then
ErrMsg "'ndiff.awk' not present: $CPPTRAJ_NDIFF"
exit 1
Expand All @@ -851,14 +845,8 @@ SetBinaries() {
# Determine location of nproc/numprocs
if [ -z "$CPPTRAJ_NPROC" ] ; then
if [ ! -z "$DO_PARALLEL" ] ; then
if [ $STANDALONE -eq 0 ] ; then
CPPTRAJ_NPROC=$DIRPREFIX/AmberTools/test/numprocs
elif [ ! -z "$CPPTRAJSRC" ] ; then
CPPTRAJ_NPROC=$CPPTRAJSRC/test/nproc
else
CPPTRAJ_NPROC=$CPPTRAJ_TEST_ROOT/nproc
fi
if [ -z "$CPPTRAJ_NPROC" ] ; then
CPPTRAJ_NPROC=$CPPTRAJ_TEST_ROOT/utilities/nproc.sh
if [ ! -f "$CPPTRAJ_NPROC" ] ; then
ErrMsg "Error: nproc $CPPTRAJ_NPROC not found."
exit 1
fi
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions test/utilities/nproc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Assuming DO_PARALLEL is set with the command to execute mpirun,
# determine how many processes.

if [ -z "`which grep`" ] ; then
>&2 echo "Error: nproc.sh relies on grep"
exit 1
fi
if [ -z "`which wc`" ] ; then
>&2 echo "Error: nproc.sh relies on wc"
exit 1
fi

NPROC=0

if [ ! -z "$DO_PARALLEL" ] ; then
NPROC=`$DO_PARALLEL echo "cpptraj_nproc_test" | grep "cpptraj_nproc_test" | wc -l`
fi
echo $NPROC
exit 0
13 changes: 13 additions & 0 deletions unitTests/ArgList/UnitTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

. ../UnitMaster.sh

CleanFiles Makefile main.o ArgList.o a.out CpptrajStdio.o StringRoutines.o

UNITSOURCES='ArgList.cpp CpptrajStdio.cpp StringRoutines.cpp'

CreateMakefile

RunMake "ArgList class unit test."

EndTest
50 changes: 50 additions & 0 deletions unitTests/ArgList/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <cstdio>
#include <cmath>
#include "ArgList.h"

static const int Err(const char* msg) {
fprintf(stderr, "Error: %s\n", msg);
return 1;
}

const double SMALL = 0.00000000000001;

bool f_not_equals(double d1, double d2) {
return (fabs(d1 - d2) > SMALL);
}

int main() {
// 7 6 6 4 1 1 2 3 3 5
ArgList a1("This is a test 3.14159 arglist with 4 45 darg 123.323 :12@H=");

int iarg = a1.getKeyInt("with", -1);
if (iarg != 4) return Err("getKeyInt() failed.");

iarg = a1.getNextInteger(-1);
if (iarg != 45) return Err("getNextInteger() failed.");

double darg = a1.getKeyDouble("darg", 0);
if (f_not_equals(darg, 123.323)) return Err("getKeyDouble() failed.");

darg = a1.getNextDouble(0);
if (f_not_equals(darg, 3.14159)) return Err("getNextDouble() failed.");

std::string sarg = a1.GetMaskNext();
if (sarg != ":12@H=") return Err("GetMaskNext() failed.");

sarg = a1.GetStringKey("a");
if (sarg != "test") return Err("GetStringKey() failed.");

sarg = a1.GetStringNext();
if (sarg != "This") return Err("GetStringKey() failed.");

ArgList r1 = a1.RemainingArgs();
if (a1.NremainingArgs() > 0) return Err("RemainingArgs() failed (# remaining args).");
if (r1.Nargs() != 2) return Err("RemainingArgs() failed (# new args).");

r1.MarkArg(0);
sarg = r1.GetStringNext();
if (sarg != "arglist") return Err("MarkArg() failed.");

return 0;
}
9 changes: 9 additions & 0 deletions unitTests/CpptrajTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ ! -f 'UnitMaster.sh' ] ; then
echo "Fatal Error: UnitMaster.sh not present" > /dev/stderr
exit 1
fi
CPPTRAJ_TEST_MODE='master'
. UnitMaster.sh
exit 0
36 changes: 36 additions & 0 deletions unitTests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Makefile for unit tests

test: test.all

# ----- All unit tests go below ------------------

unit.NameType:
@-cd NameType && ./UnitTest.sh $(OPT)

unit.ArgList:
@-cd ArgList && ./UnitTest.sh $(OPT)

# ----- Every unit test should go here -----------
COMPLETETESTS= \
unit.NameType \
unit.ArgList

test.cpptraj: $(COMPLETETESTS)

# ------------------------------------------------

test.complete: CpptrajTest.sh UnitMaster.sh
@./CpptrajTest.sh --target test.cpptraj $(OPT)

test.all:
$(MAKE) test.complete summary

test.showerrors:
$(MAKE) test.complete summary OPT="$(OPT) showerrors"

summary: CpptrajTest.sh UnitMaster.sh
@./CpptrajTest.sh summary $(OPT)

clean:
@echo "Cleaning unit tests."
$(MAKE) test.complete OPT=clean
13 changes: 13 additions & 0 deletions unitTests/NameType/UnitTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

. ../UnitMaster.sh

CleanFiles Makefile main.o NameType.o a.out CpptrajStdio.o

UNITSOURCES='NameType.cpp CpptrajStdio.cpp'

CreateMakefile

RunMake "NameType class unit test."

EndTest
Loading