All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [Question] Why test C API failed in github CI
@ 2021-12-21 12:35 Li Wang
  2021-12-21 12:59 ` Petr Vorel
  2021-12-21 13:03 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Li Wang @ 2021-12-21 12:35 UTC (permalink / raw)
  To: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1258 bytes --]

Hi Petr and all,

Firstly, I'm sorry to push the patchset about oom protection cursorily.

The GitHub CI complained about the following failures, I feel confused
when I add a bit of debug code in my private branch then. It gets passed
in access(score_path, R_OK|W_OK) but failed in closing the file and
give no EACCESS errno, that's wired.

Did I miss anything?

https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true

-----error log------
runtest TINFO: * test05
14tst_memutils.c:118: TWARN: Failed to close FILE
'/proc/63046/oom_score_adj'
15tst_memutils.c:119: TBROK: Failed to close FILE
'/proc/63046/oom_score_adj': EACCES (13)
...
----------------------

--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -111,7 +111,13 @@ static void set_oom_score_adj(pid_t pid, int value)
                        tst_brk(TBROK, "%s does not exist, please check if
PID is valid", score_path);
        }

+       //debug code
+       if (access(score_path, R_OK | W_OK) == -1)
+               tst_brk(TBROK, "%s not readable/writeable", score_path);
+
        FILE_PRINTF(score_path, "%d", value);
+       SAFE_FILE_PRINTF(score_path, "%d", value);
+
        FILE_SCANF(score_path, "%d", &val);

        if (val != value) {


-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 1982 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [Question] Why test C API failed in github CI
  2021-12-21 12:35 [LTP] [Question] Why test C API failed in github CI Li Wang
@ 2021-12-21 12:59 ` Petr Vorel
  2021-12-21 13:03 ` Cyril Hrubis
  1 sibling, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2021-12-21 12:59 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi Li,

> Hi Petr and all,

> Firstly, I'm sorry to push the patchset about oom protection cursorily.

> The GitHub CI complained about the following failures, I feel confused
> when I add a bit of debug code in my private branch then. It gets passed
> in access(score_path, R_OK|W_OK) but failed in closing the file and
> give no EACCESS errno, that's wired.

> Did I miss anything?

> https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true

Well, looking at the upstream failure:
https://github.com/linux-test-project/ltp/runs/4594201240?check_suite_focus=true
tst_memutils.c:114: TWARN: Failed to close FILE '/proc/93483/oom_score_adj'
=> FILE_PRINTF(score_path, "%d", value);
tst_memutils.c:120: TWARN: '/proc/93483/oom_score_adj' cannot be set to -1000, are you root?
=> tst_res(TWARN, "'%s' cannot be set to %i, are you root?",

Summary:
passed   1
failed   0
broken   0
skipped  0
warnings 2 => non zero exit => test fail.

I meant in my comment in [1] that only when running as root you can adjust for
values < 0. Because we run it for each test in the library, including non-root.
There needs to be test for root on value < 0 at the beginning with return.

Kind regards,
Petr

[1] https://lore.kernel.org/ltp/YcGRST7vAycVk0AA@pevik/

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [Question] Why test C API failed in github CI
  2021-12-21 12:35 [LTP] [Question] Why test C API failed in github CI Li Wang
  2021-12-21 12:59 ` Petr Vorel
@ 2021-12-21 13:03 ` Cyril Hrubis
  2021-12-22  6:35   ` Li Wang
  1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2021-12-21 13:03 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi!
> Firstly, I'm sorry to push the patchset about oom protection cursorily.

No problem.

> The GitHub CI complained about the following failures, I feel confused
> when I add a bit of debug code in my private branch then. It gets passed
> in access(score_path, R_OK|W_OK) but failed in closing the file and
> give no EACCESS errno, that's wired.
> 
> Did I miss anything?
> 
> https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true

It does fail the same for me locally when I run the test05 under an
unpriviledged user. I guess that the error when we write negative number
to the file actually manifests when we attempt to close the file because
we use the FILE interface in safe_file_printf(). That way the actuall
write is buffered and deffered until the fclose() call.

So it looks like writing negative value to the file does return with
error for an unprivileged user.

I was looking at file_printf() as a potential solution, but that one
does produce warnings. But it looks like we do not actually use the
file_printf() function anywhere in the code so we may as well change it
so that it just returns if the operation was successful or not and make
it silent so that it does not produce any messages at all.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [Question] Why test C API failed in github CI
  2021-12-21 13:03 ` Cyril Hrubis
@ 2021-12-22  6:35   ` Li Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Li Wang @ 2021-12-22  6:35 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1545 bytes --]

On Tue, Dec 21, 2021 at 9:02 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Firstly, I'm sorry to push the patchset about oom protection cursorily.
>
> No problem.
>
> > The GitHub CI complained about the following failures, I feel confused
> > when I add a bit of debug code in my private branch then. It gets passed
> > in access(score_path, R_OK|W_OK) but failed in closing the file and
> > give no EACCESS errno, that's wired.
> >
> > Did I miss anything?
> >
> > https://github.com/wangli5665/ltp/runs/4594473907?check_suite_focus=true
>
> It does fail the same for me locally when I run the test05 under an
> unpriviledged user. I guess that the error when we write negative number
> to the file actually manifests when we attempt to close the file because
> we use the FILE interface in safe_file_printf(). That way the actuall
> write is buffered and deffered until the fclose() call.
>

Sounds possible.


>
> So it looks like writing negative value to the file does return with
> error for an unprivileged user.
>
> I was looking at file_printf() as a potential solution, but that one
> does produce warnings. But it looks like we do not actually use the
> file_printf() function anywhere in the code so we may as well change it
> so that it just returns if the operation was successful or not and make
> it silent so that it does not produce any messages at all.
>

+1 It makes sense to keep silent when the operation is not successful.
That needs an explicit difference between safe_file_printf() I guess.

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2620 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-22  6:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-21 12:35 [LTP] [Question] Why test C API failed in github CI Li Wang
2021-12-21 12:59 ` Petr Vorel
2021-12-21 13:03 ` Cyril Hrubis
2021-12-22  6:35   ` Li Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.