Skip to content

Commit

Permalink
syscalls/getrandom: add configure check for linux/random.h
Browse files Browse the repository at this point in the history
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>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
  • Loading branch information
jstancek committed Jul 13, 2015
1 parent 6324634 commit 17dce71
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,6 @@ LTP_CHECK_TIMERFD
LTP_CHECK_CAN_SUPPORT
LTP_CHECK_IOVEC
LTP_CHECK_KEYCTL
LTP_CHECK_LINUXRANDOM

AC_OUTPUT
6 changes: 6 additions & 0 deletions include/lapi/getrandom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand Down
21 changes: 21 additions & 0 deletions m4/ltp-linuxrandom.m4
Original file line number Diff line number Diff line change
@@ -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, [], [], [])]
)
1 change: 0 additions & 1 deletion testcases/kernel/syscalls/getrandom/getrandom01.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
*
*/

#include <linux/random.h>
#include "lapi/getrandom.h"
#include "linux_syscall_numbers.h"
#include "test.h"
Expand Down
1 change: 0 additions & 1 deletion testcases/kernel/syscalls/getrandom/getrandom02.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*
*/

#include <linux/random.h>
#include "lapi/getrandom.h"
#include "linux_syscall_numbers.h"
#include "test.h"
Expand Down
1 change: 0 additions & 1 deletion testcases/kernel/syscalls/getrandom/getrandom03.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion testcases/kernel/syscalls/getrandom/getrandom04.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 17dce71

Please sign in to comment.