<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Petr, Xu,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 23, 2020 at 7:37 PM Petr Vorel <<a href="mailto:pvorel@suse.cz">pvorel@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Li, Xu,<br>
<br>
> >       testcases/kernel/syscalls/add_key/add_key05.c   | 15 ++-------------<br>
> >       testcases/kernel/syscalls/quotactl/quotactl01.c | 14 ++------------<br>
> >       testcases/kernel/syscalls/quotactl/quotactl06.c | 12 +-----------<br>
<br>
> > Apart from the three, do you consider converting to SAFE_RUNCMD for the<br>
> > rest testcases?<br>
> > (it seems not too much work remaining since only a few test case uses<br>
> > tst_run_cmd)<br>
> At the beginning, I have the same idea. But after seeing code, I think we<br>
> should not because these cases have many sub tests(only few test deponds on<br>
> the result of the cmd execution.<br>
<br>
> > kernel/syscalls/setpriority/setpriority01.c<br>
> One year ago has a commit db82b596(setpriority01: Skip only PRIO_USER when<br>
> unable to add test user). It only affects PRIO_USER sub test.<br>
+ 1. I didn't want to break the case when useradd is not available (android or<br>
some custom embedded linux) or there is no password file (root mounted as ro -<br>
custom embedded linux).<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">That's right. Thanks for the clarification.</div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
BTW I also avoid handling adding user as I want to implement better handling<br>
user and group in LTP (adding a flag), see:<br>
<a href="https://github.com/linux-test-project/ltp/issues/468" rel="noreferrer" target="_blank">https://github.com/linux-test-project/ltp/issues/468</a></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good plan.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
Feel free to commend this plan.<br>
This patchset is kind of preparation for it.<br>
<br>
> > kernel/syscalls/copy_file_range/copy_file_range02.c<br>
> only affect test6 and test7<br>
>  6) Try to copy contents to a file chattred with +i<br>
>  *    flag -> EPERM<br>
>  * 7) Try to copy contents to a swapfile ->ETXTBSY<br>
Yes, it'd be bad to break all tests due it.<br>
<br>
Here is also problem with swapoff (or maybe chattr, mkswap, swapon; I don't<br>
remember), which returns exit code 255 on error, so it's not possible to<br>
distinguish this from the case whether command is not available (any idea, how<br>
to fix it?).<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Maybe we could achieve a tst_cmd_available(char *cmd) in the C version?</div><div class="gmail_default" style="font-size:small">which uses popen() to open a process like: "whereis/which command" and do string parse in the result to see the path(/usr/bin/cmd, /usr/sbin/cmd) of the bin if it has been found.</div></div><div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">A draft version to show the idea:</div><div class="gmail_default" style="font-size:small"><br></div>int tst_cmd_available(char *cmd)<br>{<br>  <span class="gmail_default" style="font-size:small">    </span>int ret = 0;<br> <span class="gmail_default" style="font-size:small">    </span>char path[PATH_MAX];<br> <span class="gmail_default" style="font-size:small">    </span>char result[PATH_MAX];<br>       <span class="gmail_default" style="font-size:small">    </span>char command[PATH_MAX];<br><br>    <span class="gmail_default" style="font-size:small">    </span>snprintf(path, PATH_MAX, "/usr/bin/%s", cmd);<br>      <span class="gmail_default" style="font-size:small">    </span>snprintf(command, PATH_MAX, "whereis %s", cmd);<br>    <span class="gmail_default" style="font-size:small">    </span>FILE *fp = popen(command, "r");<br>    <span class="gmail_default" style="font-size:small">    </span>fgets(result, sizeof(result), fp);</div><div><br>    <span class="gmail_default" style="font-size:small">    </span>if (strstr(result, path) != NULL)<br>            <span class="gmail_default" style="font-size:small">        </span>ret = 1;<br>       <span class="gmail_default" style="font-size:small">    </span>pclose(fp);<br><br>        <span class="gmail_default" style="font-size:small">    </span>return ret;<br>}<br><div class="gmail_default" style="font-size:small"></div></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>