1. Fix taskstats.m4 so it no longer punts out warnings.
2. Add ltp-swaponoff.m4 to properly detect when we're running an older kernel and need linux/swap.h (issue found by compiler team at Cisco).
3. Apply fixes according to 2. to testcases/kernel/syscalls/swap*/*.c.
4. Apply Cyril Hrubis's libcpu_set fix to the .in files and cpuset_lib Makefile and .c file.
5. Block off functionality in getdelays.c with proper preprocessor defines, as per issues after encountered after ltp-taskstats.m4 was fixed.
diff --git a/testcases/kernel/controllers/cgroup/getdelays.c b/testcases/kernel/controllers/cgroup/getdelays.c
index 474985d..29e9b71 100644
--- a/testcases/kernel/controllers/cgroup/getdelays.c
+++ b/testcases/kernel/controllers/cgroup/getdelays.c
@@ -25,17 +25,18 @@
#include <linux/types.h>
#include "config.h"
-#if HAVE_LINUX_GENETLINK_H
+#ifdef HAVE_LINUX_GENETLINK_H
#include <linux/genetlink.h>
#endif
-#if HAVE_LINUX_TASKSTATS_H
+#ifdef HAVE_LINUX_TASKSTATS_H
#include <linux/taskstats.h>
#endif
#ifdef HAVE_LINUX_CGROUPSTATS_H
#include <linux/cgroupstats.h>
#endif
-#if HAVE_LINUX_GENETLINK_H
+#if defined(HAVE_LINUX_GENETLINK_H) && defined(HAVE_LINUX_TASKSTATS_H)
+
/*
* Generic macros for dealing with netlink sockets. Might be duplicated
* elsewhere. It is recommended that commercial grade applications use
@@ -51,7 +52,6 @@
fprintf(stderr, fmt, ##arg); \
exit(code); \
} while (0)
-#endif
int done;
int rcvbufsz;
@@ -73,14 +73,6 @@
/* Maximum number of cpus expected to be specified in a cpumask */
#define MAX_CPUS 32
-#if HAVE_LINUX_GENETLINK_H
-struct msgtemplate {
- struct nlmsghdr n;
- struct genlmsghdr g;
- char buf[MAX_MSG_SIZE];
-};
-#endif
-
char cpumask[100+6*MAX_CPUS];
static void usage(void)
@@ -94,7 +86,12 @@
fprintf(stderr, " -C: container path\n");
}
-#if HAVE_LINUX_GENETLINK_H
+struct msgtemplate {
+ struct nlmsghdr n;
+ struct genlmsghdr g;
+ char buf[MAX_MSG_SIZE];
+};
+
/*
* Create a raw netlink socket and bind
*/
@@ -200,52 +197,49 @@
}
return id;
}
-#endif
-#if HAVE_LINUX_TASKSTATS_H
void print_delayacct(struct taskstats *t)
{
printf("\n\nCPU %15s%15s%15s%15s\n"
- " %15llu%15llu%15llu%15llu\n"
- "IO %15s%15s\n"
- " %15llu%15llu\n"
- "SWAP %15s%15s\n"
- " %15llu%15llu\n"
- "RECLAIM %12s%15s\n"
+ " %15llu%15llu%15llu%15llu\n"
+ "IO %15s%15s\n"
+ " %15llu%15llu\n"
+ "SWAP %15s%15s\n"
+ " %15llu%15llu\n"
+ "RECLAIM %12s%15s\n"
#ifdef HAVE_STRUCT_TASKSTATS_FREEPAGES_COUNT
- " %15llu%15llu\n"
+ " %15llu%15llu\n"
#endif
- , "count", "real total", "virtual total", "delay total",
- (unsigned long long)t->cpu_count,
- (unsigned long long)t->cpu_run_real_total,
- (unsigned long long)t->cpu_run_virtual_total,
- (unsigned long long)t->cpu_delay_total,
- "count", "delay total",
- (unsigned long long)t->blkio_count,
- (unsigned long long)t->blkio_delay_total,
- "count", "delay total",
- (unsigned long long)t->swapin_count,
- (unsigned long long)t->swapin_delay_total,
- "count", "delay total"
+ , "count", "real total", "virtual total", "delay total",
+ (unsigned long long)t->cpu_count,
+ (unsigned long long)t->cpu_run_real_total,
+ (unsigned long long)t->cpu_run_virtual_total,
+ (unsigned long long)t->cpu_delay_total,
+ "count", "delay total",
+ (unsigned long long)t->blkio_count,
+ (unsigned long long)t->blkio_delay_total,
+ "count", "delay total",
+ (unsigned long long)t->swapin_count,
+ (unsigned long long)t->swapin_delay_total,
+ "count", "delay total"
#ifdef HAVE_STRUCT_TASKSTATS_FREEPAGES_COUNT
- , (unsigned long long)t->freepages_count,
- (unsigned long long)t->freepages_delay_total
+ , (unsigned long long)t->freepages_count,
+ (unsigned long long)t->freepages_delay_total
#endif
- );
+ );
}
void task_context_switch_counts(struct taskstats *t)
{
#ifdef HAVE_STRUCT_TASKSTATS_NVCSW
printf("\n\nTask %15s%15s\n"
- " %15llu%15llu\n",
- "voluntary", "nonvoluntary",
- (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw);
+ " %15llu%15llu\n",
+ "voluntary", "nonvoluntary",
+ (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw);
#endif
}
#ifdef HAVE_LINUX_CGROUPSTATS_H
-
void print_cgroupstats(struct cgroupstats *c)
{
printf("sleeping %llu, blocked %llu, running %llu, stopped %llu, "
@@ -255,7 +249,6 @@
(unsigned long long)c->nr_stopped,
(unsigned long long)c->nr_uninterruptible);
}
-
#endif
void print_ioacct(struct taskstats *t)
@@ -268,12 +261,9 @@
(unsigned long long)t->cancelled_write_bytes);
#endif
}
-#endif
int main(int argc, char *argv[])
{
-
-#if HAVE_LINUX_GENETLINK_H
int c, rc, rep_len, aggr_len, len2, cmd_type;
__u16 id;
__u32 mypid;
@@ -408,22 +398,22 @@
}
if (containerset) {
-#ifdef HAVE_LINUX_CGROUPSTATS_H
cfd = open(containerpath, O_RDONLY);
if (cfd < 0) {
perror("error opening container file");
exit(1);
}
+#ifdef HAVE_LINUX_CGROUPSTATS_H
rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET,
CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32));
+#else
+ errno = ENOSYS;
+ rc = -1;
+#endif
if (rc < 0) {
perror("error sending cgroupstats command");
exit(1);
}
-#else
- printf("Header linux/cgroupstat.h was missing during compilation,"
- "you may have old or incomplete kernel-headers.\n");
-#endif
}
if (!maskset && !tid && !containerset) {
usage();
@@ -450,7 +440,7 @@
}
PRINTF("nlmsghdr size=%zu, nlmsg_len=%d, rep_len=%d\n",
- sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len);
+ sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len);
rep_len = GENLMSG_PAYLOAD(&msg.n);
@@ -507,7 +497,7 @@
na = (struct nlattr *) ((char *) na + len2);
}
break;
-#ifdef HAVE_LINUX_CGROUPSTATS_H
+#if HAVE_LINUX_CGROUPSTATS_H
case CGROUPSTATS_TYPE_CGROUP_STATS:
print_cgroupstats(NLA_DATA(na));
break;
@@ -536,8 +526,10 @@
if (cfd)
close(cfd);
return 0;
-#else
- printf("System doesn't have netlink support.\n");
- return 1;
-#endif
}
+#else
+int main (void) {
+ printf("System doesn't have needed netlink / taskstats support.\n");
+ return 1;
+}
+#endif
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
index dbe62e9..1cd2800 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
@@ -18,11 +18,12 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Garrett Cooper, July 2009
+# Cyril Hrubis, October 2009
#
top_srcdir ?= ../../../../..
-include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/testcases.mk
LDLIBS += -lm -lcontrollers
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c b/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
index 3ad4432..3b69cf4 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c
@@ -47,6 +47,8 @@
#include "bitmask.h"
#include "cpuset.h"
#include "common.h"
+#include "test.h"
+#include "linux_syscall_numbers.h"
/* Bump version, and update Change History, when libcpuset API changes */
#define CPUSET_VERSION 3
diff --git a/testcases/kernel/include/powerpc.in b/testcases/kernel/include/powerpc.in
index fc14765..027afcb 100644
--- a/testcases/kernel/include/powerpc.in
+++ b/testcases/kernel/include/powerpc.in
@@ -3,6 +3,8 @@
timer_delete 244
clock_settime 245
clock_gettime 246
+get_mempolicy 269
+set_mempolicy 270
splice 283
tee 284
vmsplice 285
diff --git a/testcases/kernel/include/powerpc64.in b/testcases/kernel/include/powerpc64.in
index 9e1300f..5d268e4 100644
--- a/testcases/kernel/include/powerpc64.in
+++ b/testcases/kernel/include/powerpc64.in
@@ -3,6 +3,8 @@
timer_delete 244
clock_settime 245
clock_gettime 246
+get_mempolicy 269
+set_mempolicy 270
splice 283
tee 284
vmsplice 285
diff --git a/testcases/kernel/include/s390.in b/testcases/kernel/include/s390.in
index 560563a..9850b7f 100644
--- a/testcases/kernel/include/s390.in
+++ b/testcases/kernel/include/s390.in
@@ -1,3 +1,5 @@
+get_mempolicy 269
+set_mempolicy 270
openat 288
mkdirat (__NR_openat + 1)
mknodat (__NR_openat + 2)
diff --git a/testcases/kernel/syscalls/swapoff/swapoff01.c b/testcases/kernel/syscalls/swapoff/swapoff01.c
index 71ec334..72e78ba 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff01.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff01.c
@@ -78,8 +78,14 @@
#include "test.h"
#include "usctest.h"
#include <errno.h>
-#include <sys/swap.h>
#include <stdlib.h>
+#include "config.h"
+#include <sys/swap.h>
+#if defined(HAVE_OLD_SWAPONOFF)
+#include <linux/swap.h>
+#elif ! defined(HAVE_NEW_SWAPONOFF)
+#error "Cannot determine what copy of swapon/swapoff you are using."
+#endif
static void setup();
static void cleanup();
diff --git a/testcases/kernel/syscalls/swapoff/swapoff02.c b/testcases/kernel/syscalls/swapoff/swapoff02.c
index fe6851e..db3c0ce 100644
--- a/testcases/kernel/syscalls/swapoff/swapoff02.c
+++ b/testcases/kernel/syscalls/swapoff/swapoff02.c
@@ -85,7 +85,13 @@
#include "test.h"
#include "usctest.h"
#include <stdlib.h>
+#include "config.h"
#include <sys/swap.h>
+#if defined(HAVE_OLD_SWAPONOFF)
+#include <linux/swap.h>
+#elif ! defined(HAVE_NEW_SWAPONOFF)
+#error "Cannot determine what copy of swapon/swapoff you are using."
+#endif
static void setup();
static void cleanup();
diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index e0c5719..22eef85 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -74,11 +74,17 @@
*****************************************************************************/
#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
#include "test.h"
#include "usctest.h"
-#include <errno.h>
+#include "config.h"
#include <sys/swap.h>
-#include <stdlib.h>
+#if defined(HAVE_OLD_SWAPONOFF)
+#include <linux/swap.h>
+#elif ! defined(HAVE_NEW_SWAPONOFF)
+#error "Cannot determine what copy of swapon/swapoff you are using."
+#endif
static void setup();
static void cleanup();
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index 86fe7f9..3661342 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -89,10 +89,6 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
-#include <sys/swap.h>
-#ifdef OLDER_DISTRO_RELEASE
-#include <linux/swap.h>
-#endif
#include <fcntl.h>
#include <pwd.h>
#include <string.h>
@@ -100,6 +96,13 @@
#include <signal.h>
#include "test.h"
#include "usctest.h"
+#include "config.h"
+#include <sys/swap.h>
+#if defined(HAVE_OLD_SWAPONOFF)
+#include <linux/swap.h>
+#elif ! defined(HAVE_NEW_SWAPONOFF)
+#error "Cannot determine what copy of swapon/swapoff you are using."
+#endif
#ifndef OLDER_DISTRO_RELEASE
#define MAX_SWAPFILES 32
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index 46cd7d5..5fdda2f 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -64,10 +64,6 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
-#include <sys/swap.h>
-#ifdef OLDER_DISTRO_RELEASE
-#include <linux/swap.h>
-#endif
#include <fcntl.h>
#include <pwd.h>
#include <string.h>
@@ -75,6 +71,13 @@
#include <signal.h>
#include "test.h"
#include "usctest.h"
+#include "config.h"
+#include <sys/swap.h>
+#if defined(HAVE_OLD_SWAPONOFF)
+#include <linux/swap.h>
+#elif ! defined(HAVE_NEW_SWAPONOFF)
+#error "Cannot determine what copy of swapon/swapoff you are using."
+#endif
/* This handle when we have MAX_SWAPFILES = 30 or 32 */
#define TEST_MAX_SWAPFILES 30