From: Xiaoguang W. <wan...@cn...> - 2014-07-02 09:40:44
|
Hi, On 07/01/2014 09:55 PM, ch...@su... wrote: >> + } else { >> + tst_brkm(TBROK, cleanup, "child process terminated " >> + "abnormally. status: %d", status); >> + } > > The child code uses exit(1) directly, which coincidentally maps to the > TFAIL but we should be consistent and better use 1 here or TFAIL in the > child code. > > Also this would be better written as a switch statement > > switch (ret) { > case TPASS: > ... > break; > case TCONF: > ... > break; > default: > tst_resm(TFAIL, "..."); > } OK. And I'd like to introduce two new function tst_reset_exitval() and tst_record_childstatus(). Here are some explanations: Some test cases need do real test work in child process and parent process deal with the test results. Usually it is not recommended to use tst_* interfaces in child process, because child process's test results are not propagated to parent process correctly. But if child process call tst_exit() to report the test results, I think it is OK. And the big problem prohibits us to call tst_brkm(cleanup, ...) in child process is that child and parent process share the directory created by tst_tmpdir(). Though child and parent process share many other kernel resources, but mostly they are based on kernel COW mechanism. So if we can remove the tst_rmdir() operation in cleanup() or put it elsewhere, I think we are free to call tst_brkm(cleanup,..) interface, thanks. If later we need do real test work in child process, the code flow would be: child: tst_reset_exitval() ... tst_resm(...) //record test resutls ... tsr_brkm(...) //terminate the test ... tst_exit() parent: wait(child) tst_record_childstatus() Regards, Xiaoguang Wang > |