On 11/28/2013 03:39 PM, [email protected] wrote:
> Hi!
>>>> +  while (i < TST_TOTAL) {
>>>> +
>>>> +          SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i);
>>>> +          SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res);
>>>> +
>>>> +          tst_resm(res, "Test-case '%d'", i);
>>>> +
>>>> +          /*
>>>> +           * trigger ACPI_TRAVERSE test-case while we can
>>>> +           * get valid next device description.
>>>> +           */
>>>> +          if (i == ACPI_TRAVERSE && next_acpi_str())
>>>> +                  continue;
>>> The same goes for the tst_resm() here.
>>>
>>> I would write this part so that reading the sys_str file triggers
>>> walking to next object with _STR argument, while writing to dev_tcase
>>> will reset the walk to root and wrote a code as:
>>>
>>>     SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i);
>>>     SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res);
>>>
>>>     if (i == ACPI_TRAVERSE)
>>>             res = next_acpi_str();
>>>
>>>     tst_resm(...);
>>>
>>> And the next_acpi_str() would loop on reading the dev_str while "null"
>>> is returned. Or even better make the read returns zero size at the end,
>>> (should be mapped to EOF in case of FILE*).
>> OK
>>> Also I would be more carefull and rather sanitized the result value, i.e.
>>>
>>>     tst_resm(ret ? TFAIL : TPASS, "...");
>> If I do that way, next_acpi_str could also return TCONF (kernel version
>> lower than 3.7) and then we would get TFAIL in the test-case result.
> Ah, hmm, so what about:
>
>
>       SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i);
>       SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res);
>
>       res = res ? TFAIL : TPASS;
>
>       if (i == ACPI_TRAVERSE)
>               res = next_acpi_str();
>
>       ...
>
All right, something like this is OK?

for (i = 0; i < TST_TOTAL; ++i) {

        if (i == ACPI_TRAVERSE) {
                res = tc_acpi_str();
        } else {
                SAFE_FILE_PRINTF(cleanup, dev_tcase, "%d", i);
                SAFE_FILE_SCANF(cleanup, dev_result, "%d", &res);
                res = res ? TFAIL : TPASS;
        }

        tst_resm(res, "Test-case '%d'", i);
}

And tc_acpi_str will have a loop to read the dev_str file until NULL, 
because fgets returns a pointer.

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to