public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h
@ 2015-07-13 12:11 Jan Stancek
  2015-07-13 13:03 ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2015-07-13 12:11 UTC (permalink / raw)
  To: ltp-list

Old distros (such as RHEL5.6) break, when they try to include
some kernel headers directly. Add configure check to make sure
linux/random.h kernel header can be compiled without errors.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 configure.ac                                      |  1 +
 include/lapi/getrandom.h                          |  6 ++++++
 m4/ltp-linuxrandom.m4                             | 21 +++++++++++++++++++++
 testcases/kernel/syscalls/getrandom/getrandom01.c |  1 -
 testcases/kernel/syscalls/getrandom/getrandom02.c |  1 -
 testcases/kernel/syscalls/getrandom/getrandom03.c |  1 -
 testcases/kernel/syscalls/getrandom/getrandom04.c |  1 -
 7 files changed, 28 insertions(+), 4 deletions(-)
 create mode 100644 m4/ltp-linuxrandom.m4

diff --git a/configure.ac b/configure.ac
index 0ca21a6..0198ac7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -176,5 +176,6 @@ LTP_CHECK_TIMERFD
 LTP_CHECK_CAN_SUPPORT
 LTP_CHECK_IOVEC
 LTP_CHECK_KEYCTL
+LTP_CHECK_LINUXRANDOM
 
 AC_OUTPUT
diff --git a/include/lapi/getrandom.h b/include/lapi/getrandom.h
index 6d24c5d..f5609fc 100644
--- a/include/lapi/getrandom.h
+++ b/include/lapi/getrandom.h
@@ -19,6 +19,12 @@
 #ifndef __GETRANDOM_H__
 #define __GETRANDOM_H__
 
+#include "config.h"
+
+#if HAVE_LINUX_RANDOM_H
+#include <linux/random.h>
+#endif
+
 /*
  * Flags for getrandom(2)
  *
diff --git a/m4/ltp-linuxrandom.m4 b/m4/ltp-linuxrandom.m4
new file mode 100644
index 0000000..30c099e
--- /dev/null
+++ b/m4/ltp-linuxrandom.m4
@@ -0,0 +1,21 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2015
+dnl
+dnl This program is free software;  you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY;  without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
+dnl the GNU General Public License for more details.
+dnl
+
+dnl
+dnl LTP_CHECK_LINUXRANDOM
+dnl ----------------------------
+dnl
+AC_DEFUN([LTP_CHECK_LINUXRANDOM],[
+AC_CHECK_HEADERS(linux/random.h, [], [], [])]
+)
diff --git a/testcases/kernel/syscalls/getrandom/getrandom01.c b/testcases/kernel/syscalls/getrandom/getrandom01.c
index 818372e..103748a 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom01.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom01.c
@@ -26,7 +26,6 @@
  *
  */
 
-#include <linux/random.h>
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
 #include "test.h"
diff --git a/testcases/kernel/syscalls/getrandom/getrandom02.c b/testcases/kernel/syscalls/getrandom/getrandom02.c
index 905917b..0ac8bd2 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom02.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom02.c
@@ -27,7 +27,6 @@
  *
  */
 
-#include <linux/random.h>
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
 #include "test.h"
diff --git a/testcases/kernel/syscalls/getrandom/getrandom03.c b/testcases/kernel/syscalls/getrandom/getrandom03.c
index 9c13d09..03950e0 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom03.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom03.c
@@ -30,7 +30,6 @@
  *  number of bytes required and expects success.
  */
 
-#include <linux/random.h>
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
 #include "test.h"
diff --git a/testcases/kernel/syscalls/getrandom/getrandom04.c b/testcases/kernel/syscalls/getrandom/getrandom04.c
index 4e099e1..10ab44b 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom04.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom04.c
@@ -30,7 +30,6 @@
  *  descriptors to 3 and expects success.
  */
 
-#include <linux/random.h>
 #include <sys/resource.h>
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
-- 
1.8.3.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h
  2015-07-13 12:11 Jan Stancek
@ 2015-07-13 13:03 ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2015-07-13 13:03 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

Hi!
> Old distros (such as RHEL5.6) break, when they try to include
> some kernel headers directly. Add configure check to make sure
> linux/random.h kernel header can be compiled without errors.

Looks good to me, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h
       [not found] <371268015.770228.1437399185640.JavaMail.zimbra@redhat.com>
@ 2015-07-22  2:40 ` Xiaoguang Wang
  2015-07-22  8:16   ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Xiaoguang Wang @ 2015-07-22  2:40 UTC (permalink / raw)
  To: ltp-list

For simplicity, I think we should just verify whether 'linux/random.h'
is valid, here if it's valid, that means such codes will be compiled correctly.

  #include <linux/random.h>
  int main(void)
  {
  	getrandom(NULL, 100, 0);
  	return 0;
  }
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
 m4/ltp-linuxrandom.m4 | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/m4/ltp-linuxrandom.m4 b/m4/ltp-linuxrandom.m4
index 30c099e..4b7e585 100644
--- a/m4/ltp-linuxrandom.m4
+++ b/m4/ltp-linuxrandom.m4
@@ -16,6 +16,20 @@ dnl
 dnl LTP_CHECK_LINUXRANDOM
 dnl ----------------------------
 dnl
-AC_DEFUN([LTP_CHECK_LINUXRANDOM],[
-AC_CHECK_HEADERS(linux/random.h, [], [], [])]
-)
+
+AC_DEFUN([LTP_CHECK_LINUXRANDOM],[dnl
+	AC_MSG_CHECKING([for linux/random.h])
+	AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+
+#include <linux/random.h>
+int main(void) {
+	return 0;
+}])],[has_linux_random_h="yes"])
+
+if test "x$has_linux_random_h" = xyes; then
+	AC_DEFINE(HAVE_LINUX_RANDOM_H,1,[Define to 1 if having a valid linux/random.h])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+])
-- 
1.8.2.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h
  2015-07-22  8:16   ` Jan Stancek
@ 2015-07-22  8:14     ` Xiaoguang Wang
  0 siblings, 0 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2015-07-22  8:14 UTC (permalink / raw)
  To: Jan Stancek; +Cc: ltp-list

hi,

On 07/22/2015 04:16 PM, Jan Stancek wrote:
> 
> 
> 
> 
> ----- Original Message -----
>> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
>> To: ltp-list@lists.sourceforge.net
>> Sent: Wednesday, 22 July, 2015 4:40:23 AM
>> Subject: [LTP] [PATCH] syscalls/getrandom: add configure check for	linux/random.h
>>
>> For simplicity, I think we should just verify whether 'linux/random.h'
>> is valid, here if it's valid, that means such codes will be compiled
>> correctly.
>>
>>   #include <linux/random.h>
>>   int main(void)
>>   {
>>   	getrandom(NULL, 100, 0);
>>   	return 0;
>>   }
>> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> 
> I added paragraph about autoconf behaviour before 2.64, removed
> getrandom() call from commit message and pushed.
OK, that would be better, thanks!

Regards,
Xiaoguang Wang

> 
> Thank you,
> Jan
> .
> 


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h
  2015-07-22  2:40 ` [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h Xiaoguang Wang
@ 2015-07-22  8:16   ` Jan Stancek
  2015-07-22  8:14     ` Xiaoguang Wang
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2015-07-22  8:16 UTC (permalink / raw)
  To: Xiaoguang Wang; +Cc: ltp-list





----- Original Message -----
> From: "Xiaoguang Wang" <wangxg.fnst@cn.fujitsu.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Wednesday, 22 July, 2015 4:40:23 AM
> Subject: [LTP] [PATCH] syscalls/getrandom: add configure check for	linux/random.h
> 
> For simplicity, I think we should just verify whether 'linux/random.h'
> is valid, here if it's valid, that means such codes will be compiled
> correctly.
> 
>   #include <linux/random.h>
>   int main(void)
>   {
>   	getrandom(NULL, 100, 0);
>   	return 0;
>   }
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>

I added paragraph about autoconf behaviour before 2.64, removed
getrandom() call from commit message and pushed.

Thank you,
Jan

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2015-07-22  8:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <371268015.770228.1437399185640.JavaMail.zimbra@redhat.com>
2015-07-22  2:40 ` [LTP] [PATCH] syscalls/getrandom: add configure check for linux/random.h Xiaoguang Wang
2015-07-22  8:16   ` Jan Stancek
2015-07-22  8:14     ` Xiaoguang Wang
2015-07-13 12:11 Jan Stancek
2015-07-13 13:03 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox