From 2ff86fed25a7bf8380d1f9df060a26a51458c1cf Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 21 Jan 2019 22:09:21 +0100 Subject: [PATCH] tests: add integration test for averaging hook --- tests/integration/hook-average.sh | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 tests/integration/hook-average.sh diff --git a/tests/integration/hook-average.sh b/tests/integration/hook-average.sh new file mode 100755 index 000000000..33b9d9224 --- /dev/null +++ b/tests/integration/hook-average.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Integration test for average hook. +# +# @author Steffen Vogel +# @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################## + +INPUT_FILE=$(mktemp) +OUTPUT_FILE=$(mktemp) +EXPECT_FILE=$(mktemp) + +cat < ${INPUT_FILE} +1548104309.033621000(0) 0.022245 0.590769 -1.000000 0.597649 0.100588 +1548104309.133998900(1) 0.015339 0.952914 -1.000000 0.196137 0.200966 +1548104309.233542500(2) 0.027500 0.950063 -1.000000 -0.202037 0.300509 +1548104309.334019400(3) 0.040320 0.582761 -1.000000 -0.603945 0.400986 +1548104309.433952200(4) 0.026079 -0.005774 1.000000 -0.996324 0.500919 +1548104309.533756400(5) 0.049262 -0.591455 1.000000 -0.597107 0.600723 +1548104309.637440300(6) 0.014883 -0.959248 1.000000 -0.182372 0.704407 +1548104309.736158700(7) 0.023232 -0.944805 1.000000 0.212502 0.803126 +1548104309.833614900(8) 0.015231 -0.584824 1.000000 0.602327 0.900582 +1548104309.934288200(9) 0.060849 0.007885 -1.000000 0.994980 0.001255 +EOF + +cat < ${EXPECT_FILE} +1548104309.033621000(0) -0.488878 0.590769 -1.000000 0.597649 0.100588 +1548104309.133998900(1) -0.492331 0.952914 -1.000000 0.196137 0.200966 +1548104309.233542500(2) -0.486250 0.950063 -1.000000 -0.202037 0.300509 +1548104309.334019400(3) -0.479840 0.582761 -1.000000 -0.603945 0.400986 +1548104309.433952200(4) 0.513039 -0.005774 1.000000 -0.996324 0.500919 +1548104309.533756400(5) 0.524631 -0.591455 1.000000 -0.597107 0.600723 +1548104309.637440300(6) 0.507441 -0.959248 1.000000 -0.182372 0.704407 +1548104309.736158700(7) 0.511616 -0.944805 1.000000 0.212502 0.803126 +1548104309.833614900(8) 0.507615 -0.584824 1.000000 0.602327 0.900582 +1548104309.934288200(9) -0.469575 0.007885 -1.000000 0.994980 0.001255 +EOF + +# Average over first and third signal (mask = 0b101 = 5) +villas-hook -o mask=5 -o offset=0 average < ${INPUT_FILE} > ${OUTPUT_FILE} + +# Compare only the data values +villas-test-cmp ${OUTPUT_FILE} ${EXPECT_FILE} + +RC=$? + +rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE} + +exit $RC