move_pages04: fix zero page status code for kernels >= 4.3
PATCH 1/1 move_pages04: fix zero page status code for kernels >= 4.3
d899844e9c98 "mm: fix status code which move_pages() returns for zero page" changed status code for zero pages (allocated but not written to yet) from -ENOENT to -EFAULT.
This patch mirros the change for move_pages04 testcase.
--- .../kernel/syscalls/move_pages/move_pages04.c | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-)
testcases/kernel/syscalls/move_pages/move_pages04.c +19 -8
@@ -30,9 +30,14 @@* * ALGORITHM * -* 1. Pass a page that does not exit as one of the page addresses -* to move_pages(). -* 2. Check if the corresponding status is set to -ENOENT. +* 1. Pass zero page (allocated, but not written to) as one of the +* page addresses to move_pages(). +* 2. Check if the corresponding status is set to: +* -ENOENT for kernels < 4.3 +* -EFAULT for kernels >= 4.3 [1] +* +* [1] +* d899844e9c98 "mm: fix status code which move_pages() returns for zero page" * * USAGE: <for command-line> * move_pages04 [-c n] [-i n] [-I x] [-P x] [-t]
@@ -84,7 +89,12 @@ int main(int argc, char **argv)int lc;unsigned int from_node;unsigned int to_node; -int ret; +int ret, exp_status; + +if ((tst_kvercmp (4 ,3 ,0 )) >=0 ) + exp_status = -EFAULT ; +else + exp_status = -ENOENT ; ret =get_allowed_nodes (NH_MEMS ,2 , &from_node, &to_node);if (ret <0 )
@@ -123,12 +133,13 @@ int main(int argc, char **argv) goto err_free_pages; } -if (status[UNTOUCHED_PAGE ] == -ENOENT ) -tst_resm (TPASS ,"status[%d] set to expected -ENOENT" , +if (status[UNTOUCHED_PAGE ] == exp_status) +tst_resm (TPASS ,"status[%d] has expected value" ,UNTOUCHED_PAGE );else -tst_resm (TFAIL ,"status[%d] is %d" ,UNTOUCHED_PAGE , - status[UNTOUCHED_PAGE ]); +tst_resm (TFAIL ,"status[%d] is %d, expected %d" , +UNTOUCHED_PAGE , status[UNTOUCHED_PAGE ], + exp_status); err_free_pages:/* This is capable of freeing both the touched and
Signature · 1 line
1.8.3.1
PATCH 1/1 move_pages04: fix zero page status code for kernels >= 4.3
Hi!
testcases/kernel/syscalls/move_pages/move_pages04.c int main(int argc, char **argv) · line 142
Quoted 11 lines
testcases/kernel/syscalls/move_pages/move_pages04.c +5
-4-if (status[UNTOUCHED_PAGE ] == -ENOENT ) -tst_resm (TPASS ,"status[%d] set to expected -ENOENT" , +if (status[UNTOUCHED_PAGE ] == exp_status) +tst_resm (TPASS ,"status[%d] has expected value" ,UNTOUCHED_PAGE );else -tst_resm (TFAIL ,"status[%d] is %d" ,UNTOUCHED_PAGE , - status[UNTOUCHED_PAGE ]); +tst_resm (TFAIL ,"status[%d] is %d, expected %d" , +UNTOUCHED_PAGE , status[UNTOUCHED_PAGE ], + exp_status);
It would be a bit better to print the errno with tst_strerrno() in both cases. I.e. tst_strerrno(-exp_status) and tst_strerrno(-status[UNTOUCHED_PAGE]) otherwise this looks obviously fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 move_pages04: fix zero page status code for kernels >= 4.3
----- Original Message -----
Quoted 7 lines
From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: [email protected]
Sent: Wednesday, 5 October, 2016 5:47:35 PM
Subject: Re: [LTP] [PATCH]move_pages04: fix zero page status code for kernels >= 4.3Hi!
Quoted 16 lines
testcases/kernel/syscalls/move_pages/move_pages04.c int main(int argc, char **argv) · line 142
Quoted 11 lines
testcases/kernel/syscalls/move_pages/move_pages04.c +5
-4-if (status[UNTOUCHED_PAGE ] == -ENOENT ) -tst_resm (TPASS ,"status[%d] set to expected -ENOENT" , +if (status[UNTOUCHED_PAGE ] == exp_status) +tst_resm (TPASS ,"status[%d] has expected value" ,UNTOUCHED_PAGE );else -tst_resm (TFAIL ,"status[%d] is %d" ,UNTOUCHED_PAGE , - status[UNTOUCHED_PAGE ]); +tst_resm (TFAIL ,"status[%d] is %d, expected %d" , +UNTOUCHED_PAGE , status[UNTOUCHED_PAGE ], + exp_status);It would be a bit better to print the errno with
tst_strerrno()in both cases. I.e.tst_strerrno(-exp_status)andtst_strerrno(-status[UNTOUCHED_PAGE])otherwise this looks obviously fine.
Pushed with your ack and suggested changes.
Regards,
Jan
Quoted 5 lines
--
Cyril Hrubis
[email protected]