On 18.03.2019 14:46, Jiri Olsa wrote:
> On Sat, Mar 16, 2019 at 05:18:24PM +0300, Alexey Budankov wrote:
>>
>> Implemented basic integration test for Zstd based trace
>> compression/decompression in record and report modes.
>>
>> Signed-off-by: Alexey Budankov <[email protected]>
>> ---
>>  .../tests/shell/record+zstd_comp_decomp.sh    | 28 +++++++++++++++++++
>>  1 file changed, 28 insertions(+)
>>  create mode 100755 tools/perf/tests/shell/record+zstd_comp_decomp.sh
>>
>> diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh 
>> b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
>> new file mode 100755
>> index 000000000000..bc195874fc27
>> --- /dev/null
>> +++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
>> @@ -0,0 +1,28 @@
>> +#!/bin/sh
>> +# record trace Zstd compression/decompression
>> +
>> +trace_file=$(mktemp /tmp/perf.data.XXX)
>> +perf_tool=perf
>> +output=/dev/null
>> +
>> +skip_if_no_z_record() {
>> +    $perf_tool record -h 2>&1 | grep '\-z, \-\-compression\-level'
>> +}
>> +
>> +collect_z_record() {
>> +    echo "Collecting compressed record trace file:"
>> +    $perf_tool record -o $trace_file -a -z -F 25000 -e cycles -- \
>> +            dd count=2000 if=/dev/random of=/dev/null > $output 2>&1
>> +}
>> +
>> +check_compressed_stats() {
>> +    echo "Checking compressed events stats:"
>> +    $perf_tool report -i $trace_file --header --stats | \
>> +            grep -E "(# compressed : Zstd,)|(COMPRESSED events:)" > $output 
>> 2>&1
>> +}
>> +
>> +skip_if_no_z_record || exit 2
>> +collect_z_record && check_compressed_stats
>> +err=$?
>> +rm -f $trace_file
>> +exit $err
>> -- 
>> 2.20.1
>>
> 
> could we also check the actualy decompression like below
> 
> plus let's disable -a so non root user can run it,
> and also it takes too long.. changing dd to count=1000
> and adding -g to record

in v10.

~Alexey

> 
> jirka
> 
> 
> ---
> diff --git a/tools/perf/tests/shell/record+zstd_comp_decomp.sh 
> b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
> index bc195874fc27..c0ff142bf66a 100755
> --- a/tools/perf/tests/shell/record+zstd_comp_decomp.sh
> +++ b/tools/perf/tests/shell/record+zstd_comp_decomp.sh
> @@ -11,8 +11,8 @@ skip_if_no_z_record() {
>  
>  collect_z_record() {
>       echo "Collecting compressed record trace file:"
> -     $perf_tool record -o $trace_file -a -z -F 25000 -e cycles -- \
> -             dd count=2000 if=/dev/random of=/dev/null > $output 2>&1
> +     $perf_tool record -o $trace_file -g -z -F 25000 -- \
> +             dd count=1000 if=/dev/random of=/dev/null > $output 2>&1
>  }
>  
>  check_compressed_stats() {
> @@ -21,8 +21,15 @@ check_compressed_stats() {
>               grep -E "(# compressed : Zstd,)|(COMPRESSED events:)" > $output 
> 2>&1
>  }
>  
> +check_compressed_output() {
> +     $perf_tool inject -i $trace_file -o $trace_file.decomp &&
> +     $perf_tool report -i $trace_file --stdio | head -n -3 > 
> $trace_file.comp.output &&
> +     $perf_tool report -i $trace_file.decomp --stdio | head -n -3 > 
> $trace_file.decomp.output &&
> +     diff $trace_file.comp.output $trace_file.decomp.output > $output 2>&1
> +}
> +
>  skip_if_no_z_record || exit 2
> -collect_z_record && check_compressed_stats
> +collect_z_record && check_compressed_stats && check_compressed_output
>  err=$?
> -rm -f $trace_file
> +rm -f $trace_file*
>  exit $err
> 

Reply via email to