Re: [PATCH 2/2] perf tests: Add a test case for checking sw clock event frequency

Namhyung Kim
2013-03-19T05:10:40Z

Hi Arnaldo,

On Mon, 18 Mar 2013 11:42:43 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Mar 18, 2013 at 11:41:47AM +0900, Namhyung Kim escreveu:
>> +static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
>> +{
>> + int i, err = -1;
>> + volatile int tmp = 0;
>> + u64 total_periods = 0;
>> + int nr_samples = 0;
>> + union perf_event *event;
>> + struct perf_evsel *evsel;
>> + struct perf_evlist *evlist;
>> + struct perf_event_attr attr = {
>> + .type = PERF_TYPE_SOFTWARE,
>> + .config = clock_id,
>> + .sample_type = PERF_SAMPLE_PERIOD,
>> + .exclude_kernel = 1,
>> + .disabled = 1,
>> + .freq = 1,
>> + .sample_freq = 10000,
>> + };
>
> In some compilers we get:
>
> tests/sw-clock.c: In function ‘__test__sw_clock_freq’:
> tests/sw-clock.c:35: error: unknown field ‘sample_freq’ specified in initializer
>
> So I'm moving the initialization to outside the struct named initialization block, i.e.:
>
> @@ -32,9 +32,10 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
> .exclude_kernel = 1,
> .disabled = 1,
> .freq = 1,
> - .sample_freq = 10000,
> };
>
> + attr.sample_freq = 10000;
> +
>

Thanks for fixing this!
Namhyung