mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hook-digest: Add integration test
Signed-off-by: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
This commit is contained in:
parent
7623af56c7
commit
f9853f52c7
2 changed files with 59 additions and 2 deletions
|
@ -131,8 +131,8 @@ class DigestHook : public Hook {
|
|||
}
|
||||
|
||||
if (smp->flags & (int)SampleFlags::HAS_DATA) {
|
||||
if (signals->size() != smp->length)
|
||||
throw RuntimeError{"Sample length does not match signal list."};
|
||||
if (signals->size() < smp->length)
|
||||
throw RuntimeError{"Sample length longer than signal list."};
|
||||
|
||||
for (unsigned int i = 0; i < smp->length; ++i) {
|
||||
auto const signal = signals->getByIndex(i);
|
||||
|
|
57
tests/integration/hook-digest.sh
Executable file
57
tests/integration/hook-digest.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Integration test for digest hook.
|
||||
#
|
||||
# Author: Philipp Jungkamp <Philipp.Jungkamp@opal-rt.com>
|
||||
# SPDX-FileCopyrightText: 2023 OPAL-RT Germany GmbH
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
set -e
|
||||
|
||||
DIR=$(mktemp -d)
|
||||
pushd ${DIR}
|
||||
|
||||
function finish {
|
||||
popd
|
||||
rm -rf ${DIR}
|
||||
}
|
||||
trap finish EXIT
|
||||
|
||||
cat > input.dat <<EOF
|
||||
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.dat <<EOF
|
||||
1548104309.033621000+1.465837e+08(0)F 0.02224500000000000 0.59076899999999999 -1.00000000000000000 0.59764899999999999 0.10058800000000000
|
||||
1548104309.133998900+1.465837e+08(1) 0.01533900000000000 0.95291400000000004 -1.00000000000000000 0.19613700000000001 0.20096600000000001
|
||||
1548104309.233542500+1.465837e+08(2)F 0.02750000000000000 0.95006299999999999 -1.00000000000000000 -0.20203699999999999 0.30050900000000003
|
||||
1548104309.334019400+1.465837e+08(3) 0.04032000000000000 0.58276099999999997 -1.00000000000000000 -0.60394499999999995 0.40098600000000001
|
||||
1548104309.433952200+1.465837e+08(4)F 0.02607900000000000 -0.00577400000000000 1.00000000000000000 -0.99632399999999999 0.50091900000000000
|
||||
1548104309.533756400+1.465837e+08(5) 0.04926200000000000 -0.59145499999999995 1.00000000000000000 -0.59710700000000005 0.60072300000000001
|
||||
1548104309.637440300+1.465837e+08(6)F 0.01488300000000000 -0.95924799999999999 1.00000000000000000 -0.18237200000000001 0.70440700000000001
|
||||
1548104309.736158700+1.465837e+08(7) 0.02323200000000000 -0.94480500000000001 1.00000000000000000 0.21250200000000000 0.80312600000000001
|
||||
1548104309.833614900+1.465837e+08(8)F 0.01523100000000000 -0.58482400000000001 1.00000000000000000 0.60232699999999995 0.90058199999999999
|
||||
1548104309.934288200+1.465837e+08(9) 0.06084900000000000 0.00788500000000000 -1.00000000000000000 0.99497999999999998 0.00125500000000000
|
||||
EOF
|
||||
|
||||
cat > expect.digest <<EOF
|
||||
1548104309.033621000-0 1548104309.133998900-1 sha256 A8952855F24A39BCB3F907E4623400B91E74F22B0B748C6012B4B0176AF6F3DB
|
||||
1548104309.233542500-2 1548104309.334019400-3 sha256 7EDE5DCA0207FBABD20F4914324FA85A1BB13116EB7E84B64ACD124F81DC771B
|
||||
1548104309.433952200-4 1548104309.533756400-5 sha256 06E6FF2D102B767588E3DC2772031634CF6983D67DF49173470535CFD1DC4B9A
|
||||
1548104309.637440300-6 1548104309.736158700-7 sha256 B296F08F65FB7A2DE522BFBC5187D77D0EDDD898EB45731472999694087A063C
|
||||
EOF
|
||||
|
||||
villas hook frame -o interval=2 < input.dat > frame.dat
|
||||
villas hook digest -o algorithm=sha256 -o uri=output.digest < frame.dat > output.dat
|
||||
|
||||
villas compare output.dat expect.dat
|
||||
diff output.digest expect.digest
|
Loading…
Add table
Reference in a new issue