From c8ada99e0324ab799cd2d9278784acf02385832c Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 9 Mar 2019 00:33:13 +0100 Subject: [PATCH] tests: update hook tests --- tests/integration/hook-average.sh | 28 +++++++++------- tests/integration/hook-cast.sh | 56 +++++++++++++------------------ tests/integration/hook-dp.sh | 19 ++++++----- tests/integration/hook-scale.sh | 45 +++++++++++++------------ 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/tests/integration/hook-average.sh b/tests/integration/hook-average.sh index 33b9d9224..aca7d593a 100755 --- a/tests/integration/hook-average.sh +++ b/tests/integration/hook-average.sh @@ -40,26 +40,30 @@ cat < ${INPUT_FILE} 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 +# seconds.nanoseconds+offset(sequence) average signal0 signal1 signal2 signal3 signal4 +1548104309.033621000(0) 0.062250 0.022245 0.590769 -1.000000 0.597649 0.100588 +1548104309.133998900(1) 0.073071 0.015339 0.952914 -1.000000 0.196137 0.200966 +1548104309.233542500(2) 0.015207 0.027500 0.950063 -1.000000 -0.202037 0.300509 +1548104309.334019400(3) -0.115976 0.040320 0.582761 -1.000000 -0.603945 0.400986 +1548104309.433952200(4) 0.104980 0.026079 -0.005774 1.000000 -0.996324 0.500919 +1548104309.533756400(5) 0.092285 0.049262 -0.591455 1.000000 -0.597107 0.600723 +1548104309.637440300(6) 0.115534 0.014883 -0.959248 1.000000 -0.182372 0.704407 +1548104309.736158700(7) 0.218811 0.023232 -0.944805 1.000000 0.212502 0.803126 +1548104309.833614900(8) 0.386663 0.015231 -0.584824 1.000000 0.602327 0.900582 +1548104309.934288200(9) 0.012994 0.060849 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} +villas-hook -o mask=5 -o offset=0 -o signals=0,1,2,3,4 average < ${INPUT_FILE} > ${OUTPUT_FILE} # Compare only the data values villas-test-cmp ${OUTPUT_FILE} ${EXPECT_FILE} - RC=$? +cat ${INPUT_FILE} +echo +cat ${OUTPUT_FILE} + rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE} exit $RC diff --git a/tests/integration/hook-cast.sh b/tests/integration/hook-cast.sh index be186e76b..dd08a522a 100755 --- a/tests/integration/hook-cast.sh +++ b/tests/integration/hook-cast.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Integration test for convert hook. +# Integration test for cast hook. # # @author Steffen Vogel # @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC @@ -22,50 +22,42 @@ # along with this program. If not, see . ################################################################################## -# We skip this test for now -echo "Test not yet supported" -exit 99 - INPUT_FILE=$(mktemp) OUTPUT_FILE=$(mktemp) EXPECT_FILE=$(mktemp) cat < ${INPUT_FILE} -1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000 -1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785 -1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057 -1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057 -1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785 -1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000 -1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785 -1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057 -1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057 -1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785 +# seconds.nanoseconds+offset(sequence) signal0 signal1 signal2 signal3 signal4 +1551015508.801653200(0) 0.022245 0.000000 -1.000000 1.000000 0.000000 +1551015508.901653200(1) 0.015339 58.778500 -1.000000 0.600000 0.100000 +1551015509.001653200(2) 0.027500 95.105700 -1.000000 0.200000 0.200000 +1551015509.101653200(3) 0.040320 95.105700 -1.000000 -0.200000 0.300000 +1551015509.201653200(4) 0.026079 58.778500 -1.000000 -0.600000 0.400000 +1551015509.301653200(5) 0.049262 0.000000 1.000000 -1.000000 0.500000 +1551015509.401653200(6) 0.014883 -58.778500 1.000000 -0.600000 0.600000 +1551015509.501653200(7) 0.023232 -95.105700 1.000000 -0.200000 0.700000 +1551015509.601653200(8) 0.015231 -95.105700 1.000000 0.200000 0.800000 +1551015509.701653200(9) 0.060849 -58.778500 1.000000 0.600000 0.900000 EOF cat < ${EXPECT_FILE} -1490500399.776379108(0) 0.000000 0 0 0.000000 -1490500399.876379108(1) 0.587785 58 58 0.587785 -1490500399.976379108(2) 0.951057 95 95 0.951057 -1490500400.076379108(3) 0.951057 95 95 0.951057 -1490500400.176379108(4) 0.587785 58 58 0.587785 -1490500400.276379108(5) 0.000000 0 0 0.000000 -1490500400.376379108(6) -0.587785 -58 -58 -0.587785 -1490500400.476379108(7) -0.951057 -95 -95 -0.951057 -1490500400.576379108(8) -0.951057 -95 -95 -0.951057 -1490500400.676379108(9) -0.587785 -58 -58 -0.587785 +# seconds.nanoseconds+offset(sequence) signal0 test[V] signal2 signal3 signal4 +1551015508.801653200(0) 0.022245 0 -1.000000 1.000000 0.000000 +1551015508.901653200(1) 0.015339 58 -1.000000 0.600000 0.100000 +1551015509.001653200(2) 0.027500 95 -1.000000 0.200000 0.200000 +1551015509.101653200(3) 0.040320 95 -1.000000 -0.200000 0.300000 +1551015509.201653200(4) 0.026079 58 -1.000000 -0.600000 0.400000 +1551015509.301653200(5) 0.049262 0 1.000000 -1.000000 0.500000 +1551015509.401653200(6) 0.014883 -58 1.000000 -0.600000 0.600000 +1551015509.501653200(7) 0.023232 -95 1.000000 -0.200000 0.700000 +1551015509.601653200(8) 0.015231 -95 1.000000 0.200000 0.800000 +1551015509.701653200(9) 0.060849 -58 1.000000 0.600000 0.900000 EOF -cat ${INPUT_FILE} | \ -villas-hook -o scale=100 scale | \ -villas-hook cast | \ -tee ${OUTPUT_FILE} - -cat ${OUTPUT_FILE} +villas-hook cast -o new_name=test -o new_unit=V -o new_type=integer -o signal=1 < ${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} diff --git a/tests/integration/hook-dp.sh b/tests/integration/hook-dp.sh index b09219163..3b3f9c417 100755 --- a/tests/integration/hook-dp.sh +++ b/tests/integration/hook-dp.sh @@ -24,27 +24,30 @@ set -x -INPUT_FILE=$(mktemp) -OUTPUT_FILE=$(mktemp) -EXPECT_FILE=$(mktemp) +#INPUT_FILE=$(mktemp) +#OUTPUT_FILE=$(mktemp) +#RECON_FILE=$(mktemp) -NUM_SAMPLES=40000 +INPUT_FILE=in +OUTPUT_FILE=out +RECON_FILE=recon + +NUM_SAMPLES=10000 RATE=5000 F0=50 -OPTS="-d debug -o f0=${F0} -o rate=${RATE} -o index=0 -o harmonics=0,1,3,5" +OPTS="-o f0=${F0} -o rate=${RATE} -o signal=0 -o harmonics=0,1,3,5,7" villas-signal sine -v1 -l ${NUM_SAMPLES} -f ${F0} -r ${RATE} -n > ${INPUT_FILE} villas-hook dp -o inverse=false ${OPTS} < ${INPUT_FILE} > ${OUTPUT_FILE} -cat ${OUTPUT_FILE} +villas-hook dp -o inverse=true ${OPTS} < ${OUTPUT_FILE} > ${RECON_FILE} -exit 1 +exit 0 # Compare only the data values villas-test-cmp ${OUTPUT_FILE} ${EXPECT_FILE} - RC=$? rm -f ${INPUT_FILE} ${OUTPUT_FILE} ${EXPECT_FILE} diff --git a/tests/integration/hook-scale.sh b/tests/integration/hook-scale.sh index 0e222dff8..0518974ce 100755 --- a/tests/integration/hook-scale.sh +++ b/tests/integration/hook-scale.sh @@ -27,36 +27,37 @@ OUTPUT_FILE=$(mktemp) EXPECT_FILE=$(mktemp) cat < ${INPUT_FILE} -1490500399.776379108(0) 0.000000 0.000000 0.000000 0.000000 -1490500399.876379108(1) 0.587785 0.587785 0.587785 0.587785 -1490500399.976379108(2) 0.951057 0.951057 0.951057 0.951057 -1490500400.076379108(3) 0.951057 0.951057 0.951057 0.951057 -1490500400.176379108(4) 0.587785 0.587785 0.587785 0.587785 -1490500400.276379108(5) 0.000000 0.000000 0.000000 0.000000 -1490500400.376379108(6) -0.587785 -0.587785 -0.587785 -0.587785 -1490500400.476379108(7) -0.951057 -0.951057 -0.951057 -0.951057 -1490500400.576379108(8) -0.951057 -0.951057 -0.951057 -0.951057 -1490500400.676379108(9) -0.587785 -0.587785 -0.587785 -0.587785 +# seconds.nanoseconds(sequence) random sine square triangle ramp +1551015508.801653200(0) 0.022245 0.000000 -1.000000 1.000000 0.000000 +1551015508.901653200(1) 0.015339 0.587785 -1.000000 0.600000 0.100000 +1551015509.001653200(2) 0.027500 0.951057 -1.000000 0.200000 0.200000 +1551015509.101653200(3) 0.040320 0.951057 -1.000000 -0.200000 0.300000 +1551015509.201653200(4) 0.026079 0.587785 -1.000000 -0.600000 0.400000 +1551015509.301653200(5) 0.049262 0.000000 1.000000 -1.000000 0.500000 +1551015509.401653200(6) 0.014883 -0.587785 1.000000 -0.600000 0.600000 +1551015509.501653200(7) 0.023232 -0.951057 1.000000 -0.200000 0.700000 +1551015509.601653200(8) 0.015231 -0.951057 1.000000 0.200000 0.800000 +1551015509.701653200(9) 0.060849 -0.587785 1.000000 0.600000 0.900000 EOF cat < ${EXPECT_FILE} -1490500399.776379108-1.490500e+09(0) -10.000000 -10.000000 -10.000000 -10.000000 -1490500399.876379108-1.490500e+09(1) -4.122150 -4.122150 -4.122150 -4.122150 -1490500399.976379108-1.490500e+09(2) -0.489430 -0.489430 -0.489430 -0.489430 -1490500400.076379108-1.490500e+09(3) -0.489430 -0.489430 -0.489430 -0.489430 -1490500400.176379108-1.490500e+09(4) -4.122150 -4.122150 -4.122150 -4.122150 -1490500400.276379108-1.490500e+09(5) -10.000000 -10.000000 -10.000000 -10.000000 -1490500400.376379108-1.490500e+09(6) -15.877850 -15.877850 -15.877850 -15.877850 -1490500400.476379108-1.490500e+09(7) -19.510570 -19.510570 -19.510570 -19.510570 -1490500400.576379108-1.490500e+09(8) -19.510570 -19.510570 -19.510570 -19.510570 -1490500400.676379108-1.490500e+09(9) -15.877850 -15.877850 -15.877850 -15.877850 +# seconds.nanoseconds+offset(sequence) signal0 signal1 signal2 signal3 signal4 +1551015508.801653200(0) 0.022245 0.000000 -1.000000 1.000000 55.000000 +1551015508.901653200(1) 0.015339 0.587785 -1.000000 0.600000 65.000000 +1551015509.001653200(2) 0.027500 0.951057 -1.000000 0.200000 75.000000 +1551015509.101653200(3) 0.040320 0.951057 -1.000000 -0.200000 85.000000 +1551015509.201653200(4) 0.026079 0.587785 -1.000000 -0.600000 95.000000 +1551015509.301653200(5) 0.049262 0.000000 1.000000 -1.000000 105.000000 +1551015509.401653200(6) 0.014883 -0.587785 1.000000 -0.600000 115.000000 +1551015509.501653200(7) 0.023232 -0.951057 1.000000 -0.200000 125.000000 +1551015509.601653200(8) 0.015231 -0.951057 1.000000 0.200000 135.000000 +1551015509.701653200(9) 0.060849 -0.587785 1.000000 0.600000 145.000000 EOF -villas-hook -o scale=10 -o offset=-10 scale < ${INPUT_FILE} > ${OUTPUT_FILE} +villas-hook scale -o scale=100 -o offset=55 -o signal=signal4 < ${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}