From e0671a336595deddaa287a1f1f4f718897d01b90 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 9 Jul 2017 07:38:29 +0000 Subject: Add test framework based on shunit2 --- test/test_suite.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 test/test_suite.sh (limited to 'test') diff --git a/test/test_suite.sh b/test/test_suite.sh new file mode 100755 index 0000000..c6aa38e --- /dev/null +++ b/test/test_suite.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +gemma=../bin/gemma + +testCenteredRelatednessMatrix() { + $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt \ + -a ../example/mouse_hs1940.anno.txt -gk -o mouse_hs1940 + assertEquals "3763600" `wc -w < output/mouse_hs1940.cXX.txt` +} + +shunit2=`which shunit2` +if [ -x "$shunit2" ]; then + . $shunit2 +else + # try to run the locally installed shunit2 + . ../shunit2-2.0.3/src/shell/shunit2 +fi -- cgit v1.2.3 From 35405450385ded8797a9a6388e6e2801381f2894 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 9 Jul 2017 08:07:46 +0000 Subject: Test: check result --- test/test_suite.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_suite.sh b/test/test_suite.sh index c6aa38e..effc056 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -2,10 +2,13 @@ gemma=../bin/gemma -testCenteredRelatednessMatrix() { +testCenteredRelatednessMatrixK() { $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt \ - -a ../example/mouse_hs1940.anno.txt -gk -o mouse_hs1940 + -a ../example/mouse_hs1940.anno.txt -gk -o mouse_hs1940 assertEquals "3763600" `wc -w < output/mouse_hs1940.cXX.txt` + # assertEquals "15f680c" `md5sum < output/mouse_hs1940.cXX.txt | head -c 7` + assertEquals "0.335" `head -c 5 output/mouse_hs1940.cXX.txt` + assertEquals "29.691" `awk '{s+=substr($1,0,6)}END{print s}' output/mouse_hs1940.cXX.txt` } shunit2=`which shunit2` -- cgit v1.2.3 From 0792aee7269e4bf1c2903267e17a12dfebd14884 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 9 Jul 2017 08:33:41 +0000 Subject: Tests: added test for univariate and multivariate LMM Also added 'make check' command in Makefile and documented in INSTALL.md --- .gitignore | 4 +++- INSTALL.md | 4 ++++ Makefile | 2 ++ test/test_suite.sh | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/.gitignore b/.gitignore index 108e607..d6c227e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,11 @@ *.tar.gz src/Eigen example/output +test/output +./output doc/manual.aux doc/manual.bbl doc/manual.blg doc/manual.log doc/manual.out -doc/manual.toc \ No newline at end of file +doc/manual.toc diff --git a/INSTALL.md b/INSTALL.md index f6eb0c0..32d37f3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,3 +48,7 @@ if you get an Eigen error you may need to override the include path. E.g. on GNU Guix with shared libs this may work make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 FORCE_DYNAMIC=1 + +to run GEMMA tests + + make check diff --git a/Makefile b/Makefile index 0f25d88..a15c043 100644 --- a/Makefile +++ b/Makefile @@ -95,6 +95,8 @@ $(OBJS) : $(HDR) $(CPP) $(CPPFLAGS) $(HEADERS) -c $*.cpp -o $*.o .SUFFIXES : .cpp .c .o $(SUFFIXES) +check: + ./run_tests.sh clean: rm -rf ${SRC_DIR}/*.o ${SRC_DIR}/*~ *~ $(OUTPUT) diff --git a/test/test_suite.sh b/test/test_suite.sh index effc056..8adc5c9 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -11,6 +11,23 @@ testCenteredRelatednessMatrixK() { assertEquals "29.691" `awk '{s+=substr($1,0,6)}END{print s}' output/mouse_hs1940.cXX.txt` } +testUnivariateLinearMixedModel() { + $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt -n 1 \ + -a ../example/mouse_hs1940.anno.txt -k ./output/mouse_hs1940.cXX.txt -lmm \ + -o mouse_hs1940_CD8_lmm + assertEquals "118459" `wc -w < output/mouse_hs1940_CD8_lmm.assoc.txt` + assertEquals "92047" `awk '{s+=substr($1,0,6)}END{print s}' output/mouse_hs1940_CD8_lmm.assoc.txt` +} + +testMultivariateLinearMixedModel() { + $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt \ + -n 1 6 -a ../example/mouse_hs1940.anno.txt -k ./output/mouse_hs1940.cXX.txt \ + -lmm -o mouse_hs1940_CD8MCH_lmm + outfn=output/mouse_hs1940_CD8MCH_lmm.assoc.txt + assertEquals "139867" `wc -w < $outfn` + assertEquals "92079" `awk '{s+=substr($1,0,6)}END{print s}' $outfn` +} + shunit2=`which shunit2` if [ -x "$shunit2" ]; then . $shunit2 -- cgit v1.2.3 From d2ea25218f28c01afcb2480960fdf090318a864b Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 9 Jul 2017 08:42:07 +0000 Subject: Tests: more tests --- test/test_suite.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/test_suite.sh b/test/test_suite.sh index 8adc5c9..763c981 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -5,6 +5,9 @@ gemma=../bin/gemma testCenteredRelatednessMatrixK() { $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt \ -a ../example/mouse_hs1940.anno.txt -gk -o mouse_hs1940 + assertEquals 0 $? + grep "total computation time" < output/mouse_hs1940.log.txt + assertEquals 0 $? assertEquals "3763600" `wc -w < output/mouse_hs1940.cXX.txt` # assertEquals "15f680c" `md5sum < output/mouse_hs1940.cXX.txt | head -c 7` assertEquals "0.335" `head -c 5 output/mouse_hs1940.cXX.txt` @@ -15,6 +18,9 @@ testUnivariateLinearMixedModel() { $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt -n 1 \ -a ../example/mouse_hs1940.anno.txt -k ./output/mouse_hs1940.cXX.txt -lmm \ -o mouse_hs1940_CD8_lmm + assertEquals 0 $? + grep "total computation time" < output/mouse_hs1940_CD8_lmm.log.txt + assertEquals 0 $? assertEquals "118459" `wc -w < output/mouse_hs1940_CD8_lmm.assoc.txt` assertEquals "92047" `awk '{s+=substr($1,0,6)}END{print s}' output/mouse_hs1940_CD8_lmm.assoc.txt` } @@ -23,6 +29,10 @@ testMultivariateLinearMixedModel() { $gemma -g ../example/mouse_hs1940.geno.txt.gz -p ../example/mouse_hs1940.pheno.txt \ -n 1 6 -a ../example/mouse_hs1940.anno.txt -k ./output/mouse_hs1940.cXX.txt \ -lmm -o mouse_hs1940_CD8MCH_lmm + assertEquals 0 $? + grep "total computation time" < output/mouse_hs1940_CD8MCH_lmm.log.txt + assertEquals 0 $? + outfn=output/mouse_hs1940_CD8MCH_lmm.assoc.txt assertEquals "139867" `wc -w < $outfn` assertEquals "92079" `awk '{s+=substr($1,0,6)}END{print s}' $outfn` -- cgit v1.2.3 From d92fc5359540d7c860140f74f9f905d83b24f82d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 9 Jul 2017 12:25:44 +0000 Subject: Makefile: force unit tests to throw a make error on less than 100% success --- Makefile | 3 +-- test/test_suite.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/Makefile b/Makefile index 8b5b113..748c4f2 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,7 @@ $(OBJS) : $(HDR) .SUFFIXES : .cpp .c .o $(SUFFIXES) check: all - cd test && ./test_suite.sh - + cd test && ./test_suite.sh | grep -q 'success rate: 100%' clean: rm -rf ${SRC_DIR}/*.o ${SRC_DIR}/*~ *~ $(OUTPUT) diff --git a/test/test_suite.sh b/test/test_suite.sh index 763c981..d65bf40 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -11,6 +11,7 @@ testCenteredRelatednessMatrixK() { assertEquals "3763600" `wc -w < output/mouse_hs1940.cXX.txt` # assertEquals "15f680c" `md5sum < output/mouse_hs1940.cXX.txt | head -c 7` assertEquals "0.335" `head -c 5 output/mouse_hs1940.cXX.txt` + # FIXME: The following test fails in the Guix build system (https://github.com/xiangzhou/GEMMA/issues/55) assertEquals "29.691" `awk '{s+=substr($1,0,6)}END{print s}' output/mouse_hs1940.cXX.txt` } -- cgit v1.2.3 From d6098a5f318543b525878c6cf45ddfe8ec923d9d Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 16 Jul 2017 11:05:39 +0000 Subject: sunit2: added instructions --- .gitignore | 1 + INSTALL.md | 17 +++++++++++++++++ run_tests.sh | 3 +-- test/test_suite.sh | 12 +++++++++--- 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/.gitignore b/.gitignore index d6c227e..5088ec4 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ doc/manual.blg doc/manual.log doc/manual.out doc/manual.toc +contrib/ diff --git a/INSTALL.md b/INSTALL.md index de6558b..e4da6ff 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -52,3 +52,20 @@ path. E.g. on GNU Guix with shared libs this may work to run GEMMA tests make check + +## Run tests + +GEMMA uses the shunit2 test framework (version 2.0) and can be found +[here](https://github.com/genenetwork/shunit2) + +In the source tree: + + git clone https://github.com/genenetwork/shunit2 contrib/shunit2 + +and run + + make check + +or + + ./run_tests.sh diff --git a/run_tests.sh b/run_tests.sh index e8b7d49..181f687 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -# download shunit2 in order to run tests: -# curl -L "https://dl.dropboxusercontent.com/u/7916095/shunit2-2.0.3.tgz" | tar zx --overwrite +# download shunit2 in order to run tests (see INSTALL.md) cd test ./test_suite.sh | tee /dev/stderr | grep -q 'success rate: 100%' diff --git a/test/test_suite.sh b/test/test_suite.sh index d65bf40..f1a1c6f 100755 --- a/test/test_suite.sh +++ b/test/test_suite.sh @@ -40,9 +40,15 @@ testMultivariateLinearMixedModel() { } shunit2=`which shunit2` -if [ -x "$shunit2" ]; then +if [ -e "../contrib/shunit2/source/2.0/src/shell/shunit2" ]; then + echo try to run the locally installed shunit2 + . ../contrib/shunit2/source/2.0/src/shell/shunit2 +elif [ -e "../shunit2-2.0.3/src/shell/shunit2" ]; then + echo try to run the older locally installed shunit2 + . ../shunit2-2.0.3/src/shell/shunit2 +elif [ -x "$shunit2" ]; then + echo run system shunit2 . $shunit2 else - # try to run the locally installed shunit2 - . ../shunit2-2.0.3/src/shell/shunit2 + echo "Can not find shunit2 - see INSTALL.md" fi -- cgit v1.2.3