[PATCH 1/4] tests: add brk.test
Dmitry V. Levin
ldv at altlinux.org
Wed May 11 15:58:55 UTC 2016
On Wed, May 11, 2016 at 03:07:26PM +0800, Fei Jie wrote:
> * tests/brk.c: New file.
> * tests/brk.test: New test.
> * tests/.gitignore: Add brk.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add brk.test.
> ---
> tests/.gitignore | 1 +
> tests/Makefile.am | 2 ++
> tests/brk.c | 23 +++++++++++++++++++++++
> tests/brk.test | 14 ++++++++++++++
> 4 files changed, 40 insertions(+)
> create mode 100644 tests/brk.c
> create mode 100755 tests/brk.test
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 265ebcc..745b7a1 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -15,6 +15,7 @@ attach-f-p
> attach-p-cmd-cmd
> attach-p-cmd-p
> bpf
> +brk
> caps
> chmod
> chown
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9362cda..c836e49 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -70,6 +70,7 @@ check_PROGRAMS = \
> attach-p-cmd-cmd \
> attach-p-cmd-p \
> bpf \
> + brk \
> caps \
> chmod \
> chown \
> @@ -355,6 +356,7 @@ DECODER_TESTS = \
> aio.test \
> alarm.test \
> bpf.test \
> + brk.test \
> caps.test \
> chmod.test \
> chown.test \
> diff --git a/tests/brk.c b/tests/brk.c
> new file mode 100644
> index 0000000..4ddb78d
> --- /dev/null
> +++ b/tests/brk.c
> @@ -0,0 +1,23 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_brk
> +
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> + long rc = syscall(__NR_brk, NULL);
> + printf("brk(NULL) = %#x\n", (unsigned int) rc);
Why cast to unsigned int?
> +
> + puts("+++ exited with 0 +++");
> + return 0;
> +}
> +
> +#else
> +
> +SKIP_MAIN_UNDEFINED("__NR_brk")
> +
> +#endif
> diff --git a/tests/brk.test b/tests/brk.test
> new file mode 100755
> index 0000000..4164460
> --- /dev/null
> +++ b/tests/brk.test
> @@ -0,0 +1,14 @@
> +#!/bin/sh
> +
> +# Check brk syscall decoding.
> +
> +. "${srcdir=.}/init.sh"
> +
> +check_prog uniq
> +
> +run_prog > /dev/null
> +run_strace -ebrk -a10 $args > "$EXP"
> +uniq < "$LOG" > "$OUT"
> +
> +match_diff "$OUT" "$EXP"
> +rm -f "$OUT" "$EXP"
This doesn't help, the test fails because of unexpected output.
Probably match_diff is not appropriate method of testing brk,
try match_grep.
--
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/20160511/b5b9da6e/attachment.bin>
More information about the Strace-devel
mailing list