* [LTP] [PATCHv2 0/2] Fix for syscalls/utimensat01 test on Ubuntu 4.4 kernel
@ 2020-08-18 10:04 Po-Hsu Lin
2020-08-18 10:04 ` [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname Po-Hsu Lin
2020-08-18 10:04 ` [LTP] [PATCHv2 2/2] syscalls/utimensat01: add exception for Ubuntu 4.4 kernel Po-Hsu Lin
0 siblings, 2 replies; 8+ messages in thread
From: Po-Hsu Lin @ 2020-08-18 10:04 UTC (permalink / raw)
To: ltp
Ubuntu 4.4 kernel got the backported kernel patch (b3b4283) for
syscalls/utimensat01 since 4.4.0-48.69, therefore it will return
EPERM instead of EACCES.
Without this fix, the test will fail on Ubuntu 4.4 kernel with:
FAIL: 18: utimensat() failed with incorrect error, expected EACCES: EPERM (1)
FAIL: 19: utimensat() failed with incorrect error, expected EACCES: EPERM (1)
Add Ubuntu kernel version comparison to fix this.
Also add support to get the distname for different OS by parsing ID=
from /etc/os-release in tst_kvcmp_distname()
Po-Hsu Lin (2):
lib/tst_kvercmp: Add support to get distname for different OS in
tst_kvcmp_distname
syscalls/utimensat01: add exception for Ubuntu 4.4 kernel
lib/tst_kvercmp.c | 16 ++++++++++++++++
.../kernel/syscalls/utimensat/utimensat01.c | 7 ++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-18 10:04 [LTP] [PATCHv2 0/2] Fix for syscalls/utimensat01 test on Ubuntu 4.4 kernel Po-Hsu Lin
@ 2020-08-18 10:04 ` Po-Hsu Lin
2020-08-18 15:29 ` Cyril Hrubis
2020-08-18 10:04 ` [LTP] [PATCHv2 2/2] syscalls/utimensat01: add exception for Ubuntu 4.4 kernel Po-Hsu Lin
1 sibling, 1 reply; 8+ messages in thread
From: Po-Hsu Lin @ 2020-08-18 10:04 UTC (permalink / raw)
To: ltp
The kver on Ubuntu will be something like these:
* 4.4.0-187-generic
* 5.4.0-1021-kvm
* 4.15.0-1093-azure
So it's better to parse OS name from ID= in /etc/os-release, instead
of doing this from checking kver substring like what we did for RHEL
and Oracle Linux here.
From the document [1] this string will alway be in lowercase. Example:
"ID=fedora" or "ID=debian". Thus it needs to be converted to uppercase
to make it consistent with other return values in tst_kvcmp_distname().
Note that if ID was not set, it will default to "ID=linux". Thus we
can expect to get LINUX on some distros.
[1] https://www.freedesktop.org/software/systemd/man/os-release.html
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
lib/tst_kvercmp.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/tst_kvercmp.c b/lib/tst_kvercmp.c
index dc3bb669b..af6c6de69 100644
--- a/lib/tst_kvercmp.c
+++ b/lib/tst_kvercmp.c
@@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -25,6 +26,8 @@
#include <sys/utsname.h>
#include "test.h"
+#define OSRELEASE_PATH "/etc/os-release"
+
static char *parse_digit(const char *str, int *d)
{
unsigned long v;
@@ -127,6 +130,8 @@ int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
const char *tst_kvcmp_distname(const char *kver)
{
+ static char distname[64];
+ char *tok;
if (strstr(kver, ".el5uek"))
return "OL5UEK";
@@ -139,6 +144,17 @@ const char *tst_kvcmp_distname(const char *kver)
if (strstr(kver, ".el6"))
return "RHEL6";
+ // Special case for other releases with the presencse of /etc/os-release
+ if (access(OSRELEASE_PATH, F_OK) != -1) {
+ SAFE_FILE_LINES_SCANF(NULL, OSRELEASE_PATH, "ID=%s", distname);
+ tok = strtok(distname,"\0");
+ while (*tok) {
+ *tok = toupper((unsigned char) *tok);
+ tok++;
+ }
+ return distname;
+ }
+
return NULL;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 2/2] syscalls/utimensat01: add exception for Ubuntu 4.4 kernel
2020-08-18 10:04 [LTP] [PATCHv2 0/2] Fix for syscalls/utimensat01 test on Ubuntu 4.4 kernel Po-Hsu Lin
2020-08-18 10:04 ` [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname Po-Hsu Lin
@ 2020-08-18 10:04 ` Po-Hsu Lin
1 sibling, 0 replies; 8+ messages in thread
From: Po-Hsu Lin @ 2020-08-18 10:04 UTC (permalink / raw)
To: ltp
Ubuntu 4.4 kernel got this patch (b3b4283) since 4.4.0-48.69,
therefore it will return EPERM instead of EACCES.
Without this fix, the test will fail on Ubuntu 4.4 kernel with:
FAIL: 18: utimensat() failed with incorrect error, expected EACCES: EPERM (1)
FAIL: 19: utimensat() failed with incorrect error, expected EACCES: EPERM (1)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
testcases/kernel/syscalls/utimensat/utimensat01.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c
index 7dabfed6d..de4f0601b 100644
--- a/testcases/kernel/syscalls/utimensat/utimensat01.c
+++ b/testcases/kernel/syscalls/utimensat/utimensat01.c
@@ -158,6 +158,11 @@ static void tst_multi_set_time(enum tst_ts_type type, struct mytime *mytime)
static void update_error(struct test_case *tc)
{
+ // Special case for Ubuntu kernel, which has patch b3b4283 since 4.4.0-48.69
+ static struct tst_kern_exv kvers[] = {
+ { "UBUNTU", "4.4.0-48.69" },
+ };
+
if (tc->exp_err != -1)
return;
@@ -167,7 +172,7 @@ static void update_error(struct test_case *tc)
* This patch has also been merged to stable 4.4 with
* b3b4283 ("vfs: move permission checking into notify_change() for utimes(NULL)")
*/
- if (tst_kvercmp(4, 4, 27) < 0)
+ if (tst_kvercmp2(4, 4, 27, kvers) < 0)
tc->exp_err = EACCES;
else
tc->exp_err = EPERM;
--
2.25.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-18 10:04 ` [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname Po-Hsu Lin
@ 2020-08-18 15:29 ` Cyril Hrubis
2020-08-18 16:20 ` Po-Hsu Lin
0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2020-08-18 15:29 UTC (permalink / raw)
To: ltp
Hi!
> static char *parse_digit(const char *str, int *d)
> {
> unsigned long v;
> @@ -127,6 +130,8 @@ int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
>
> const char *tst_kvcmp_distname(const char *kver)
> {
> + static char distname[64];
> + char *tok;
> if (strstr(kver, ".el5uek"))
> return "OL5UEK";
>
> @@ -139,6 +144,17 @@ const char *tst_kvcmp_distname(const char *kver)
> if (strstr(kver, ".el6"))
> return "RHEL6";
>
> + // Special case for other releases with the presencse of /etc/os-release
> + if (access(OSRELEASE_PATH, F_OK) != -1) {
> + SAFE_FILE_LINES_SCANF(NULL, OSRELEASE_PATH, "ID=%s", distname);
> + tok = strtok(distname,"\0");
Isn't this strtok() useless?
Other than that the patchset looks fine.
> + while (*tok) {
> + *tok = toupper((unsigned char) *tok);
> + tok++;
> + }
> + return distname;
> + }
> +
> return NULL;
> }
>
> --
> 2.25.1
>
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-18 15:29 ` Cyril Hrubis
@ 2020-08-18 16:20 ` Po-Hsu Lin
2020-08-18 18:30 ` Cyril Hrubis
0 siblings, 1 reply; 8+ messages in thread
From: Po-Hsu Lin @ 2020-08-18 16:20 UTC (permalink / raw)
To: ltp
On Tue, Aug 18, 2020 at 11:29 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > static char *parse_digit(const char *str, int *d)
> > {
> > unsigned long v;
> > @@ -127,6 +130,8 @@ int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
> >
> > const char *tst_kvcmp_distname(const char *kver)
> > {
> > + static char distname[64];
> > + char *tok;
> > if (strstr(kver, ".el5uek"))
> > return "OL5UEK";
> >
> > @@ -139,6 +144,17 @@ const char *tst_kvcmp_distname(const char *kver)
> > if (strstr(kver, ".el6"))
> > return "RHEL6";
> >
> > + // Special case for other releases with the presencse of /etc/os-release
> > + if (access(OSRELEASE_PATH, F_OK) != -1) {
> > + SAFE_FILE_LINES_SCANF(NULL, OSRELEASE_PATH, "ID=%s", distname);
> > + tok = strtok(distname,"\0");
>
> Isn't this strtok() useless?
Hello,
oh indeed, the delimiter in strtok will become null character anyway.
I think just tok = distname can do the trick here.
I will send v3 tomorrow.
Thank you
>
>
> Other than that the patchset looks fine.
>
> > + while (*tok) {
> > + *tok = toupper((unsigned char) *tok);
> > + tok++;
> > + }
> > + return distname;
> > + }
> > +
> > return NULL;
> > }
> >
> > --
> > 2.25.1
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-18 16:20 ` Po-Hsu Lin
@ 2020-08-18 18:30 ` Cyril Hrubis
2020-08-19 1:34 ` Po-Hsu Lin
0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2020-08-18 18:30 UTC (permalink / raw)
To: ltp
Hi!
> oh indeed, the delimiter in strtok will become null character anyway.
> I think just tok = distname can do the trick here.
> I will send v3 tomorrow.
I can easily fix that before I push the patch, no need for v3.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-18 18:30 ` Cyril Hrubis
@ 2020-08-19 1:34 ` Po-Hsu Lin
2020-08-19 8:56 ` Cyril Hrubis
0 siblings, 1 reply; 8+ messages in thread
From: Po-Hsu Lin @ 2020-08-19 1:34 UTC (permalink / raw)
To: ltp
On Wed, Aug 19, 2020 at 2:29 AM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > oh indeed, the delimiter in strtok will become null character anyway.
> > I think just tok = distname can do the trick here.
> > I will send v3 tomorrow.
>
> I can easily fix that before I push the patch, no need for v3.
Hello Cyril,
that would be great, thanks for the review!
>
> --
> Cyril Hrubis
> chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname
2020-08-19 1:34 ` Po-Hsu Lin
@ 2020-08-19 8:56 ` Cyril Hrubis
0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2020-08-19 8:56 UTC (permalink / raw)
To: ltp
Hi!
Both patches pushed with a minor changes, thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-08-19 8:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 10:04 [LTP] [PATCHv2 0/2] Fix for syscalls/utimensat01 test on Ubuntu 4.4 kernel Po-Hsu Lin
2020-08-18 10:04 ` [LTP] [PATCHv2 1/2] lib/tst_kvercmp: Add support to get distname for different OS in tst_kvcmp_distname Po-Hsu Lin
2020-08-18 15:29 ` Cyril Hrubis
2020-08-18 16:20 ` Po-Hsu Lin
2020-08-18 18:30 ` Cyril Hrubis
2020-08-19 1:34 ` Po-Hsu Lin
2020-08-19 8:56 ` Cyril Hrubis
2020-08-18 10:04 ` [LTP] [PATCHv2 2/2] syscalls/utimensat01: add exception for Ubuntu 4.4 kernel Po-Hsu Lin
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.