[PATCH v2] Add some tests for -f option
Fei, Jie/费 杰
feij.fnst at cn.fujitsu.com
Tue Dec 29 09:31:19 UTC 2015
Hi all,
Do you have some any comments on these patches? Do you think that
they're necessary or not?
On 12/17/2015 10:45 AM, Fei Jie wrote:
> tests: add tests from option-f_001.test to option-f_003.test
>
> *tests/option-f_001.c: New file.
> *tests/option-f_001.test: Likewise.
> *tests/option-f_001.expected: Likewise.
> *tests/option-f_002.c: Likewise.
> *tests/option-f_002.test: Likewise.
> *tests/option-f_002.expected: Likewise.
> *tests/option-f_003.test: Likewise.
> *tests/option-f_003.expected: Likewise.
> * tests/Makefile.am (check_PROGRAMS): Add option-f_001 and option-f_002.
> (TESTS): Add from option-f_001.test to option-f_003.test.
> * tests/.gitignore: Add option-f_001 and option-f_002.
> ---
> tests/.gitignore | 2 ++
> tests/Makefile.am | 7 ++++++-
> tests/option-f_001.c | 21 +++++++++++++++++++++
> tests/option-f_001.expected | 2 ++
> tests/option-f_001.test | 9 +++++++++
> tests/option-f_002.c | 21 +++++++++++++++++++++
> tests/option-f_002.expected | 2 ++
> tests/option-f_002.test | 9 +++++++++
> tests/option-f_003.expected | 1 +
> tests/option-f_003.test | 10 ++++++++++
> 10 files changed, 83 insertions(+), 1 deletion(-)
> create mode 100644 tests/option-f_001.c
> create mode 100644 tests/option-f_001.expected
> create mode 100755 tests/option-f_001.test
> create mode 100644 tests/option-f_002.c
> create mode 100644 tests/option-f_002.expected
> create mode 100755 tests/option-f_002.test
> create mode 100644 tests/option-f_003.expected
> create mode 100755 tests/option-f_003.test
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 5c5c572..0317ed9 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -89,6 +89,8 @@ xattr
> xet_robust_list
> xetitimer
> xettimeofday
> +option-f_001
> +option-f_002
> *.log
> *.log.*
> *.o
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9ccd395..c84f390 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -102,6 +102,8 @@ check_PROGRAMS = \
> xet_robust_list \
> xetitimer \
> xettimeofday \
> + option-f_001 \
> + option-f_002 \
> # end of check_PROGRAMS
>
> clock_xettime_LDADD = -lrt
> @@ -219,7 +221,10 @@ TESTS = \
> detach-stopped.test \
> detach-running.test \
> restart_syscall.test \
> - strace-k.test
> + strace-k.test \
> + option-f_001.test \
> + option-f_002.test \
> + option-f_003.test
>
> net-fd.log: net.log
>
> diff --git a/tests/option-f_001.c b/tests/option-f_001.c
> new file mode 100644
> index 0000000..ef0c295
> --- /dev/null
> +++ b/tests/option-f_001.c
> @@ -0,0 +1,21 @@
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <stdio.h>
> +
> +#define MAGIC_STRING "CT&^%@"
> +
> +main()
> +{
> + int pid = fork();
> + if (pid == -1) {
> + printf("fork failed\n");
> + exit(1);
> + }
> +
> + if(pid){
> + printf("father" MAGIC_STRING "\n");
> + }else{
> + printf("child" MAGIC_STRING "\n" );
> + }
> + return 0;
> +}
> diff --git a/tests/option-f_001.expected b/tests/option-f_001.expected
> new file mode 100644
> index 0000000..002d33c
> --- /dev/null
> +++ b/tests/option-f_001.expected
> @@ -0,0 +1,2 @@
> +[0-9]* +write\(1, \"fatherCT&\^%@\\n\",.*
> +[0-9]* +write\(1, \"childCT&\^%@\\n\",.*
> diff --git a/tests/option-f_001.test b/tests/option-f_001.test
> new file mode 100755
> index 0000000..c10856d
> --- /dev/null
> +++ b/tests/option-f_001.test
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +
> +. "${srcdir=.}/init.sh"
> +
> +run_prog
> +run_strace -f $args
> +match_grep
> +
> +exit 0
> diff --git a/tests/option-f_002.c b/tests/option-f_002.c
> new file mode 100644
> index 0000000..343c102
> --- /dev/null
> +++ b/tests/option-f_002.c
> @@ -0,0 +1,21 @@
> +#include <stdlib.h>
> +#include <unistd.h>
> +#include <stdio.h>
> +
> +#define MAGIC_STRING "CT&^%@"
> +
> +main()
> +{
> + int pid = vfork();
> + if (pid == -1) {
> + printf("fork failed\n");
> + exit(1);
> + }
> +
> + if(pid){
> + printf("father" MAGIC_STRING "\n");
> + }else{
> + execlp("/bin/echo", "echo", "child" MAGIC_STRING, NULL);
> + }
> + return 0;
> +}
> diff --git a/tests/option-f_002.expected b/tests/option-f_002.expected
> new file mode 100644
> index 0000000..002d33c
> --- /dev/null
> +++ b/tests/option-f_002.expected
> @@ -0,0 +1,2 @@
> +[0-9]* +write\(1, \"fatherCT&\^%@\\n\",.*
> +[0-9]* +write\(1, \"childCT&\^%@\\n\",.*
> diff --git a/tests/option-f_002.test b/tests/option-f_002.test
> new file mode 100755
> index 0000000..c10856d
> --- /dev/null
> +++ b/tests/option-f_002.test
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +
> +. "${srcdir=.}/init.sh"
> +
> +run_prog
> +run_strace -f $args
> +match_grep
> +
> +exit 0
> diff --git a/tests/option-f_003.expected b/tests/option-f_003.expected
> new file mode 100644
> index 0000000..5022237
> --- /dev/null
> +++ b/tests/option-f_003.expected
> @@ -0,0 +1 @@
> +[0-9]* +write\(1, \"CT&\^%@\\n\",.*
> diff --git a/tests/option-f_003.test b/tests/option-f_003.test
> new file mode 100755
> index 0000000..1ccc3ba
> --- /dev/null
> +++ b/tests/option-f_003.test
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +
> +. "${srcdir=.}/init.sh"
> +
> +MAGIC_STRING="CT&^%@"
> +
> +run_strace -f echo "$MAGIC_STRING"
> +match_grep
> +
> +exit 0
--
Thanks!
Fei Jie
More information about the Strace-devel
mailing list