[PATCH v7 3/4] tests: check decoding of netlink protocol

Dmitry V. Levin ldv at altlinux.org
Wed Jun 22 17:12:53 UTC 2016


On Wed, Jun 22, 2016 at 01:27:05PM +0000, Fabien Siron wrote:
> * tests/netlink_parsing.test: New test.
> * tests/netlink_parsing.c: New file.
> * tests/.gitignore: Add netlink_parsing.
> * tests/Makefile.am (check_PROGRAMS): Likewise.

(DECODER_TESTS): Add netlink_parsing.test.

> diff --git a/tests/netlink_parsing.c b/tests/netlink_parsing.c
> new file mode 100644
> index 0000000..3e7c983
> --- /dev/null
> +++ b/tests/netlink_parsing.c
> @@ -0,0 +1,119 @@
> +/*

It won't harm to add a comment line here too, e.g.
"Check decoding of netlink protocol."

> +#include "tests.h"
> +#include <errno.h>

errno.h seems to be unused in this file.

> diff --git a/tests/netlink_parsing.test b/tests/netlink_parsing.test
> new file mode 100755
> index 0000000..c8313d1
> --- /dev/null
> +++ b/tests/netlink_parsing.test
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +#
> +# Check decoding of Netlink parsing.

Check decoding of netlink protocol.

I wonder whether netlink_protocol would be a better name for this test.

> +#
> +# Copyright (c) 2014 Masatake YAMATO <yamato at redhat.com>
> +# Copyright (c) 2014-2016 Dmitry V. Levin <ldv at altlinux.org>
> +# Copyright (c) 2016 Fabien Siron <fabien.siron at epita.fr>
> +# All rights reserved.
> +#
> +# Redistribution and use in source and binary forms, with or without
> +# modification, are permitted provided that the following conditions
> +# are met:
> +# 1. Redistributions of source code must retain the above copyright
> +#    notice, this list of conditions and the following disclaimer.
> +# 2. Redistributions in binary form must reproduce the above copyright
> +#    notice, this list of conditions and the following disclaimer in the
> +#    documentation and/or other materials provided with the distribution.
> +# 3. The name of the author may not be used to endorse or promote products
> +#    derived from this software without specific prior written permission.
> +#
> +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
> +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
> +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
> +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
> +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
> +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
> +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> +
> +. "${srcdir=.}/init.sh"
> +
> +check_prog sed
> +
> +run_prog "./$NAME" > /dev/null
> +
> +run_strace -a22 -v -eclose,network $args > "$EXP"
> +# Filter out close() calls made by ld.so and libc.
> +sed -n '/socket/,$p' < "$LOG" > "$OUT"
> +
> +match_diff "$OUT" "$EXP"
> +rm -f "$EXP" "$OUT"

As the test doesn't check decoding of close syscall,
the test driver could be simplified further, e.g.

. "${srcdir=.}/init.sh"

# getfdproto is implemented using /proc/self/fd
[ -d /proc/self/fd/ ] ||
	framework_skip_ '/proc/self/fd/ is not available'

run_strace_match_diff -e trace=network


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160622/01c0feb8/attachment.bin>


More information about the Strace-devel mailing list