Run tests in CI
v8 cover Run tests in CI
Hi,
* print more items in lib into stderr (Cyril, 1st commit)
* check for readonly fs instead TCONF on any error during writing to /proc/sys/vm/nr_hugepages (Cyril, 2nd commit)
NOTE: sending just these 2 patches which are different
Tested:
https://github.com/pevik/ltp/actions/runs/1097004804
Diff to v7
newlib_tests/test_zero_hugepage.sh +4 -2
@@ -7,11 +7,13 @@ echo "Testing .request_hugepages = TST_NO_HUGEPAGES" orig_value=`cat /proc/sys/vm/nr_hugepages` -if ! echo "128" > /proc/sys/vm/nr_hugepages; then - echo "TCONF: failed to open /proc/sys/vm/nr_hugepages" +if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then + echo "TCONF: /proc or /proc/sys mounted as read-only" exit 32 fi +echo "128" > /proc/sys/vm/nr_hugepages + ./test_zero_hugepage echo $orig_value > /proc/sys/vm/nr_hugepages
tst_test.c +13 -13
@@ -488,23 +488,23 @@ static void print_test_tags(void)if (!tags)return ; -printf ("\nTags\n" ); -printf ("----\n" ); +fprintf (stderr,"\nTags\n" ); +fprintf (stderr,"----\n" );for (i =0 ; tags[i].name; i++) {if (!strcmp (tags[i].name,"CVE" )) -printf (CVE_DB_URL "%s\n" , tags[i].value); +fprintf (stderr,CVE_DB_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"linux-git" )) -printf (LINUX_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,LINUX_GIT_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"linux-stable-git" )) -printf (LINUX_STABLE_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,LINUX_STABLE_GIT_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"glibc-git" )) -printf (GLIBC_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,GLIBC_GIT_URL "%s\n" , tags[i].value);else -printf ("%s: %s\n" , tags[i].name, tags[i].value); +fprintf (stderr,"%s: %s\n" , tags[i].name, tags[i].value); } -printf ("\n" ); +fprintf (stderr,"\n" ); }static void check_option_collision (void )
@@ -674,9 +674,9 @@ int tst_parse_float(const char *str, float *val, float min, float max)static void print_colored (const char *str) {if (tst_color_enabled (STDOUT_FILENO )) -printf ("%s%s%s" ,ANSI_COLOR_YELLOW , str,ANSI_COLOR_RESET ); +fprintf (stderr,"%s%s%s" ,ANSI_COLOR_YELLOW , str,ANSI_COLOR_RESET );else -printf ("%s" , str); +fprintf (stderr,"%s" , str); } static void print_failure_hint(const char *tag, const char *hint,
@@ -694,12 +694,12 @@ static void print_failure_hint(const char *tag, const char *hint,if (!strcmp (tags[i].name, tag)) {if (!hint_printed) { hint_printed =1 ; -printf ("\n" ); +fprintf (stderr,"\n" );print_colored ("HINT: " ); -printf ("You _MAY_ be %s, see:\n\n" , hint); +fprintf (stderr,"You _MAY_ be %s, see:\n\n" , hint); } -printf ("%s%s\n" , url, tags[i].value); +fprintf (stderr,"%s%s\n" , url, tags[i].value); } } }
Petr Vorel (7):
lib: Print everything to stderr test/test_zero_hugepage.sh: Skip test on read-only /proc
lib: Add script for running tests
make: Add make test{, -c, -shell} targets build.sh: Add support for make test{,-c,-shell}
CI: Run also make test-c, test-shell
ci: Install iproute2
.github/workflows/ci.yml | 10 ++ Makefile | 23 +++ build.sh | 24 +++- ci/debian.sh | 1 + ci/fedora.sh | 1 + ci/tumbleweed.sh | 1 + lib/newlib_tests/runtest.sh | 190 +++++++++++++++++++++++++ lib/newlib_tests/test_zero_hugepage.sh | 6 + lib/tst_test.c | 38 ++--- 9 files changed, 274 insertions(+), 20 deletions(-) create mode 100755 lib/newlib_tests/runtest.sh
Signature · 1 line
2.32.0
PATCH v8 1/7 lib: Print everything to stderr
ie.e hint, tags, summary to unify the behavior with tst_{brk,res}() which printed into stderr from the beginning.
Initial motivation was issue in GitHub Actions, where stdout and stderr are probably block buffered and flushed at different times. The result was mangled summary into other test output.
---
Changes v7->v8:
* print more items in lib into stderr (Cyril)
lib/tst_test.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
lib/tst_test.c +19 -19
@@ -488,23 +488,23 @@ static void print_test_tags(void)if (!tags)return ; -printf ("\nTags\n" ); -printf ("----\n" ); +fprintf (stderr,"\nTags\n" ); +fprintf (stderr,"----\n" );for (i =0 ; tags[i].name; i++) {if (!strcmp (tags[i].name,"CVE" )) -printf (CVE_DB_URL "%s\n" , tags[i].value); +fprintf (stderr,CVE_DB_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"linux-git" )) -printf (LINUX_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,LINUX_GIT_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"linux-stable-git" )) -printf (LINUX_STABLE_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,LINUX_STABLE_GIT_URL "%s\n" , tags[i].value);else if (!strcmp (tags[i].name,"glibc-git" )) -printf (GLIBC_GIT_URL "%s\n" , tags[i].value); +fprintf (stderr,GLIBC_GIT_URL "%s\n" , tags[i].value);else -printf ("%s: %s\n" , tags[i].name, tags[i].value); +fprintf (stderr,"%s: %s\n" , tags[i].name, tags[i].value); } -printf ("\n" ); +fprintf (stderr,"\n" ); }static void check_option_collision (void )
@@ -674,9 +674,9 @@ int tst_parse_float(const char *str, float *val, float min, float max)static void print_colored (const char *str) {if (tst_color_enabled (STDOUT_FILENO )) -printf ("%s%s%s" ,ANSI_COLOR_YELLOW , str,ANSI_COLOR_RESET ); +fprintf (stderr,"%s%s%s" ,ANSI_COLOR_YELLOW , str,ANSI_COLOR_RESET );else -printf ("%s" , str); +fprintf (stderr,"%s" , str); } static void print_failure_hint(const char *tag, const char *hint,
@@ -694,12 +694,12 @@ static void print_failure_hint(const char *tag, const char *hint,if (!strcmp (tags[i].name, tag)) {if (!hint_printed) { hint_printed =1 ; -printf ("\n" ); +fprintf (stderr,"\n" );print_colored ("HINT: " ); -printf ("You _MAY_ be %s, see:\n\n" , hint); +fprintf (stderr,"You _MAY_ be %s, see:\n\n" , hint); } -printf ("%s%s\n" , url, tags[i].value); +fprintf (stderr,"%s%s\n" , url, tags[i].value); } } }
@@ -734,12 +734,12 @@ static void do_exit(int ret)if (results->broken) ret |=TBROK ; -printf ("\nSummary:\n" ); -printf ("passed %d\n" , results->passed); -printf ("failed %d\n" , results->failed); -printf ("broken %d\n" , results->broken); -printf ("skipped %d\n" , results->skipped); -printf ("warnings %d\n" , results->warnings); +fprintf (stderr,"\nSummary:\n" ); +fprintf (stderr,"passed %d\n" , results->passed); +fprintf (stderr,"failed %d\n" , results->failed); +fprintf (stderr,"broken %d\n" , results->broken); +fprintf (stderr,"skipped %d\n" , results->skipped); +fprintf (stderr,"warnings %d\n" , results->warnings); }do_cleanup ();
Signature · 1 line
2.32.0
PATCH v8 1/7 lib: Print everything to stderr
PATCH v8 2/7 test/test_zero_hugepage.sh: Skip test on read-only /proc
In reply to Petr Vorelor /proc/sys. On GitHub Actions /proc/sys/vm/nr_hugepages is not allowed to be changed:
./test_zero_hugepage.sh: line 9: can't create /proc/sys/vm/nr_hugepages: Read-only file system tst_hugepage.c:57: TBROK: Failed to open FILE '/proc/sys/vm/nr_hugepages' for writing: EROFS (30) tst_sys_conf.c:102: TWARN: Failed to open FILE '/proc/sys/vm/nr_hugepages'
There are several /proc subdirectories mounted as read only:
$ grep '^proc /proc.* proc ro' /proc/mounts proc /proc/bus proc ro,nosuid,nodev,noexec,relatime 0 0 proc /proc/fs proc ro,nosuid,nodev,noexec,relatime 0 0 proc /proc/irq proc ro,nosuid,nodev,noexec,relatime 0 0 proc /proc/sys proc ro,nosuid,nodev,noexec,relatime 0 0 proc /proc/sysrq-trigger proc ro,nosuid,nodev,noexec,relatime 0 0
---
Changes v7->v8:
* check for readonly fs instead TCONF on any error during writing to /proc/sys/vm/nr_hugepages (Cyril)
lib/newlib_tests/test_zero_hugepage.sh | 6 ++++++ 1 file changed, 6 insertions(+)
lib/newlib_tests/test_zero_hugepage.sh +6 -0
@@ -1,11 +1,17 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2021 Yang Xu <[email protected]> +# Copyright (c) 2021 Petr Vorel <[email protected]> echo "Testing .request_hugepages = TST_NO_HUGEPAGES" orig_value=`cat /proc/sys/vm/nr_hugepages` +if grep -q -E '^proc /proc(/sys)? proc ro' /proc/mounts; then + echo "TCONF: /proc or /proc/sys mounted as read-only" + exit 32 +fi + echo "128" > /proc/sys/vm/nr_hugepages ./test_zero_hugepage
Signature · 1 line
2.32.0
PATCH v8 2/7 test/test_zero_hugepage.sh: Skip test on read-only /proc
PATCH v8 2/7 test/test_zero_hugepage.sh: Skip test on read-only /proc
Hi Cyril,
Thanks a lot, whole patchset merged!
Kind regards,
Petr