diff --git a/lib/hooks/digest.cpp b/lib/hooks/digest.cpp index 49fa4bc93..4d26197d2 100644 --- a/lib/hooks/digest.cpp +++ b/lib/hooks/digest.cpp @@ -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); diff --git a/tests/integration/hook-digest.sh b/tests/integration/hook-digest.sh new file mode 100755 index 000000000..a2bed93cd --- /dev/null +++ b/tests/integration/hook-digest.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# Integration test for digest hook. +# +# Author: Philipp Jungkamp +# 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 < expect.dat < expect.digest < 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