From f9853f52c7baceecee4921d7703259f47861d071 Mon Sep 17 00:00:00 2001 From: Philipp Jungkamp Date: Thu, 14 Sep 2023 13:13:34 +0200 Subject: [PATCH] hook-digest: Add integration test Signed-off-by: Philipp Jungkamp --- lib/hooks/digest.cpp | 4 +-- tests/integration/hook-digest.sh | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100755 tests/integration/hook-digest.sh 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