From e6546d94e895d26d188f967440b92e2bb451c1c9 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Thu, 24 Jun 2021 15:48:29 +0200 Subject: [PATCH] add gating test that uses acd-client.c from 'examples' Resolves: #1973511 Signed-off-by: Davide Caratti --- acd-client-nodebug.patch | 12 ++++++++ gating.yaml | 6 ++++ libell.spec | 6 +++- tests/sanity/acd-test.sh | 64 ++++++++++++++++++++++++++++++++++++++++ tests/tests.yaml | 17 +++++++++++ 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 acd-client-nodebug.patch create mode 100644 gating.yaml create mode 100755 tests/sanity/acd-test.sh create mode 100644 tests/tests.yaml diff --git a/acd-client-nodebug.patch b/acd-client-nodebug.patch new file mode 100644 index 0000000..687ff02 --- /dev/null +++ b/acd-client-nodebug.patch @@ -0,0 +1,12 @@ +diff --git a/examples/acd-client.c b/examples/acd-client.c +index e737288..71e14ef 100644 +--- a/examples/acd-client.c ++++ b/examples/acd-client.c +@@ -107,7 +107,6 @@ int main(int argc, char *argv[]) + bool no_probe = false; + + l_log_set_stderr(); +- l_debug_enable("*"); + + if (argc < 3) { + usage(); diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/libell.spec b/libell.spec index d94a57f..a1c211c 100644 --- a/libell.spec +++ b/libell.spec @@ -1,11 +1,12 @@ Name: libell Version: 0.41 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Embedded Linux library License: LGPLv2+ URL: https://01.org/ell Source0: https://www.kernel.org/pub/linux/libs/ell/ell-%{version}.tar.xz +Patch0: acd-client-nodebug.patch Patch1: 0001-examples-avoid-using-inet_ntoa.patch Patch2: 0002-ell-avoid-using-inet_ntoa.patch @@ -59,6 +60,9 @@ find %{buildroot} -type f -name "*.la" -delete %changelog +* Thu Jun 24 2021 Davide Caratti - 0.41-2 +- add gating test that uses acd-client.c. Related: rhbz#1973511 + * Mon Jun 21 2021 Davide Caratti - 0.41-1 - Avoid use of inet_ntoa(). Related: rhbz#1967524 - Update to 0.41. Related: rhbz#1967524 diff --git a/tests/sanity/acd-test.sh b/tests/sanity/acd-test.sh new file mode 100755 index 0000000..d8736cc --- /dev/null +++ b/tests/sanity/acd-test.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2015-2019 Jason A. Donenfeld . All Rights Reserved. + +# ┌─────────────────────┐ ┌─────────────────────┐ +# │ $netns0 │ │ $netns1 │ +# │ │ │ │ +# │┌────────┐ │ │ ┌────────┐│ +# ││ eth0 │───────────┼────┼───────────│ eth0 ││ +# │├────────┴──────────┐│ │┌──────────┴────────┤│ +# ││192.0.2.1/24 ││ ││192.0.2.1/24 ││ +# ││ping ││ ││ACD daemon ││ +# │└───────────────────┘│ │└───────────────────┘│ +# └─────────────────────┘ └─────────────────────┘ + + +set -e + +exec 3>&1 +export LANG=C +netns0="ell-test-$$-0" +netns1="ell-test-$$-1" +pretty() { echo -e "\x1b[32m\x1b[1m[+] ${1:+NS$1: }${2}\x1b[0m" >&3; } +pp() { pretty "" "$*"; "$@"; } +maybe_exec() { if [[ $BASHPID -eq $$ ]]; then "$@"; else exec "$@"; fi; } +n0() { pretty 0 "$*"; maybe_exec ip netns exec $netns0 "$@"; } +n1() { pretty 1 "$*"; maybe_exec ip netns exec $netns1 "$@"; } +ip0() { pretty 0 "ip $*"; ip -n $netns0 "$@"; } +ip1() { pretty 1 "ip $*"; ip -n $netns1 "$@"; } +slp() { read -t "$1" -N 1 || true; } + +do_cleanup() { + set +e + exec 2>/dev/null + pp pkill ell-acd-client + pp ip netns del $netns1 + pp ip netns del $netns0 + pp rm /tmp/tmp/acd-$$.log +} + +trap do_cleanup EXIT + +pkill ell-acd-client || true +ip netns del $netns0 2>/dev/null || true +ip netns del $netns1 2>/dev/null || true + +pp ip netns add $netns0 +pp ip netns add $netns1 + +ip0 link set dev lo up +ip0 link add name eth0 type veth peer name eth0 netns $netns1 +ip0 link set dev eth0 up +ip1 link set dev lo up +ip1 link set dev eth0 up +idx="$(ip1 -j link show dev eth0 | jq '.[0].ifindex')" +n1 ./ell-acd-client $idx 192.0.2.1 -d -D defend -n 1>/tmp/acd-$$.log 2>&1 & +slp 5 +ip0 address add dev eth0 192.0.2.1/24 +n0 ping 192.0.2.2 -I eth0 -c5 -w5 -q || true +slp 5 +pp cat /tmp/acd-$$.log +pp grep 'IP 192.0.2.1 has been lost' /tmp/acd-$$.log + diff --git a/tests/tests.yaml b/tests/tests.yaml new file mode 100644 index 0000000..231003e --- /dev/null +++ b/tests/tests.yaml @@ -0,0 +1,17 @@ +- hosts: localhost + tags: + - classic + roles: + - role: standard-test-source + - role: standard-test-basic + required_packages: + - gcc + - jq + - iproute + tests: + - build-tests: + dir: ./source/examples + run: gcc acd-client.c -lell -o ell-acd-client && cp ../../sanity/acd-test.sh . + - sanity-tests: + dir: ./source/examples + run: ./acd-test.sh