|
From: <sv...@va...> - 2009-01-13 04:25:13
|
Author: njn
Date: 2009-01-13 04:25:04 +0000 (Tue, 13 Jan 2009)
New Revision: 8944
Log:
DARWIN/memcheck/tests/linux/linux-timerfd-syscall.*
DARWIN/memcheck/tests/linux/linux-capget.*
DARWIN/memcheck/tests/linux/Makefile.am
Rename linux/linux-* as linux/*.
Added:
branches/DARWIN/memcheck/tests/linux/capget.c
branches/DARWIN/memcheck/tests/linux/capget.stderr.exp
branches/DARWIN/memcheck/tests/linux/capget.vgtest
branches/DARWIN/memcheck/tests/linux/timerfd-syscall.c
branches/DARWIN/memcheck/tests/linux/timerfd-syscall.stderr.exp
branches/DARWIN/memcheck/tests/linux/timerfd-syscall.vgtest
Removed:
branches/DARWIN/memcheck/tests/linux/linux-capget.c
branches/DARWIN/memcheck/tests/linux/linux-capget.stderr.exp
branches/DARWIN/memcheck/tests/linux/linux-capget.vgtest
branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.c
branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.stderr.exp
branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.vgtest
Modified:
branches/DARWIN/memcheck/tests/linux/Makefile.am
Modified: branches/DARWIN/memcheck/tests/linux/Makefile.am
===================================================================
--- branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,12 +1,12 @@
noinst_SCRIPTS = filter_stderr
EXTRA_DIST = $(noinst_SCRIPTS) \
- linux-capget linux-capget.stderr.exp \
- linux-timerfd-syscall linux-timerfd-syscall.stderr.exp
+ capget capget.stderr.exp \
+ timerfd-syscall timerfd-syscall.stderr.exp
check_PROGRAMS = \
- linux-capget \
- linux-timerfd-syscall
+ capget \
+ timerfd-syscall
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \
Copied: branches/DARWIN/memcheck/tests/linux/capget.c (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-capget.c)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/capget.c (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/capget.c 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,50 @@
+#if defined(linux)
+
+
+#include <stdio.h> /* printf() */
+#include <unistd.h> /* syscall() */
+#include <sys/syscall.h> /* __NR_capget */
+#include <linux/capability.h> /* _LINUX_CAPABILITY_VERSION */
+
+
+int main()
+{
+ struct __user_cap_header_struct h;
+ struct __user_cap_data_struct d;
+ int syscall_result;
+
+ h.version = _LINUX_CAPABILITY_VERSION;
+ h.pid = 0;
+ syscall_result = syscall(__NR_capget, &h, &d);
+ if (syscall_result >= 0)
+ {
+ fprintf(stderr,
+ "capget result:\n"
+ "effective %#x\n"
+ "permitted %#x\n"
+ "inheritable %#x\n",
+ d.effective,
+ d.permitted,
+ d.inheritable);
+ }
+ else
+ {
+ perror("capget");
+ }
+ return 0;
+}
+
+
+#else
+
+
+#include <stdio.h>
+
+int main()
+{
+ fprintf(stderr, "This program is Linux-specific\n");
+ return 0;
+}
+
+
+#endif
Copied: branches/DARWIN/memcheck/tests/linux/capget.stderr.exp (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-capget.stderr.exp)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/capget.stderr.exp (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/capget.stderr.exp 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,11 @@
+
+capget result:
+effective 0
+permitted 0
+inheritable 0
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: ... bytes in ... blocks.
+malloc/free: ... allocs, ... frees, ... bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
Copied: branches/DARWIN/memcheck/tests/linux/capget.vgtest (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-capget.vgtest)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/capget.vgtest (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/capget.vgtest 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,2 @@
+prog: linux-capget
+stderr_filter: ../filter_allocs
Deleted: branches/DARWIN/memcheck/tests/linux/linux-capget.c
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-capget.c 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-capget.c 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,50 +0,0 @@
-#if defined(linux)
-
-
-#include <stdio.h> /* printf() */
-#include <unistd.h> /* syscall() */
-#include <sys/syscall.h> /* __NR_capget */
-#include <linux/capability.h> /* _LINUX_CAPABILITY_VERSION */
-
-
-int main()
-{
- struct __user_cap_header_struct h;
- struct __user_cap_data_struct d;
- int syscall_result;
-
- h.version = _LINUX_CAPABILITY_VERSION;
- h.pid = 0;
- syscall_result = syscall(__NR_capget, &h, &d);
- if (syscall_result >= 0)
- {
- fprintf(stderr,
- "capget result:\n"
- "effective %#x\n"
- "permitted %#x\n"
- "inheritable %#x\n",
- d.effective,
- d.permitted,
- d.inheritable);
- }
- else
- {
- perror("capget");
- }
- return 0;
-}
-
-
-#else
-
-
-#include <stdio.h>
-
-int main()
-{
- fprintf(stderr, "This program is Linux-specific\n");
- return 0;
-}
-
-
-#endif
Deleted: branches/DARWIN/memcheck/tests/linux/linux-capget.stderr.exp
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-capget.stderr.exp 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-capget.stderr.exp 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,11 +0,0 @@
-
-capget result:
-effective 0
-permitted 0
-inheritable 0
-
-ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
-malloc/free: in use at exit: ... bytes in ... blocks.
-malloc/free: ... allocs, ... frees, ... bytes allocated.
-For a detailed leak analysis, rerun with: --leak-check=yes
-For counts of detected errors, rerun with: -v
Deleted: branches/DARWIN/memcheck/tests/linux/linux-capget.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-capget.vgtest 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-capget.vgtest 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,2 +0,0 @@
-prog: linux-capget
-stderr_filter: ../filter_allocs
Deleted: branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.c
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.c 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.c 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,310 +0,0 @@
-/** Test Valgrind's interception of the Linux syscalls timerfd_create(),
- * timerfd_gettime() and timerfd_settime().
- *
- * This is a modified version of
- * timerfd-test2 by Davide Libenzi (test app for timerfd)
- * Copyright (C) 2007 Davide Libenzi <da...@xm...>
- * Modified for inclusion in Valgrind.
- * Copyright (C) 2008 Bart Van Assche <bar...@gm...>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * See also http://www.xmailserver.org/timerfd-test2.c
- */
-
-#if defined(__linux__)
-
-#define _GNU_SOURCE
-
-#include "../../config.h"
-#include <errno.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#if defined(HAVE_SYS_SIGNAL_H)
-#include <sys/signal.h>
-#endif
-#if defined(HAVE_SYS_SYSCALL_H)
-#include <sys/syscall.h>
-#endif
-#if defined(HAVE_SYS_TIME_H)
-#include <sys/time.h>
-#endif
-#if defined(HAVE_SYS_TYPES_H)
-#include <sys/types.h>
-#endif
-
-
-/*
- * timerfd_* system call numbers introduced in 2.6.23. These constants are
- * not yet in the glibc 2.7 headers, that is why they are defined here.
- */
-#ifndef __NR_timerfd_create
-#if defined(__x86_64__)
-#define __NR_timerfd_create 283
-#define __NR_timerfd_settime 286
-#define __NR_timerfd_gettime 287
-#elif defined(__i386__)
-#define __NR_timerfd_create 322
-#define __NR_timerfd_settime 325
-#define __NR_timerfd_gettime 326
-#elif defined(__powerpc__)
-#define __NR_timerfd_create 306
-#define __NR_timerfd_settime 311
-#define __NR_timerfd_gettime 312
-#else
-#error Cannot detect your architecture!
-#endif
-#endif
-
-
-
-/* Definitions from include/linux/timerfd.h */
-#define TFD_TIMER_ABSTIME (1 << 0)
-
-
-
-struct tmr_type
-{
- int id;
- char const *name;
-};
-
-
-#if defined(HAVE_CLOCK_GETTIME)
-unsigned long long getustime(int clockid)
-{
- struct timespec tp;
-
- if (clock_gettime((clockid_t) clockid, &tp))
- {
- perror("clock_gettime");
- return 0;
- }
-
- return 1000000ULL * tp.tv_sec + tp.tv_nsec / 1000;
-}
-#else
-unsigned long long getustime(int clockid)
-{
- fprintf(stderr, "error: clock_gettime\n");
- return 0;
-}
-#endif
-
-void set_timespec(struct timespec *tmr, unsigned long long ustime)
-{
- tmr->tv_sec = (time_t) (ustime / 1000000ULL);
- tmr->tv_nsec = (long) (1000ULL * (ustime % 1000000ULL));
-}
-
-int timerfd_create(int clockid, int flags)
-{
- return syscall(__NR_timerfd_create, clockid, flags);
-}
-
-int timerfd_settime(int ufc, int flags, const struct itimerspec *utmr,
- struct itimerspec *otmr)
-{
- return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr);
-}
-
-int timerfd_gettime(int ufc, struct itimerspec *otmr)
-{
- return syscall(__NR_timerfd_gettime, ufc, otmr);
-}
-
-long waittmr(int tfd, int timeo)
-{
- u_int64_t ticks;
- struct pollfd pfd;
-
- pfd.fd = tfd;
- pfd.events = POLLIN;
- pfd.revents = 0;
- if (poll(&pfd, 1, timeo) < 0)
- {
- perror("poll");
- return -1;
- }
- if ((pfd.revents & POLLIN) == 0)
- {
- fprintf(stdout, "no ticks happened\n");
- return -1;
- }
- if (read(tfd, &ticks, sizeof(ticks)) != sizeof(ticks))
- {
- perror("timerfd read");
- return -1;
- }
-
- return ticks;
-}
-
-int main(int ac, char **av)
-{
- int i, tfd;
- long ticks;
- unsigned long long tnow, ttmr;
- u_int64_t uticks;
- struct itimerspec tmr;
- struct tmr_type clks[] =
- {
-#if defined(HAVE_CLOCK_MONOTONIC)
- { CLOCK_MONOTONIC, "CLOCK MONOTONIC" },
-#endif
- { CLOCK_REALTIME, "CLOCK REALTIME" },
- };
-
- for (i = 0; i < sizeof(clks) / sizeof(clks[0]); i++)
- {
- fprintf(stdout, "\n\n---------------------------------------\n");
- fprintf(stdout, "| testing %s\n", clks[i].name);
- fprintf(stdout, "---------------------------------------\n\n");
-
- fprintf(stdout, "relative timer test (at 500 ms) ...\n");
- set_timespec(&tmr.it_value, 500 * 1000);
- set_timespec(&tmr.it_interval, 0);
- tnow = getustime(clks[i].id);
- if ((tfd = timerfd_create(clks[i].id, 0)) == -1)
- {
- perror("timerfd_create");
- return 1;
- }
-
- if (timerfd_settime(tfd, 0, &tmr, NULL))
- {
- perror("timerfd_settime");
- return 1;
- }
-
- fprintf(stdout, "wating timer ...\n");
- ticks = waittmr(tfd, -1);
- ttmr = getustime(clks[i].id);
- if (ticks <= 0)
- fprintf(stdout, "whooops! no timer showed up!\n");
- else
- fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
- ticks, (ttmr - tnow) * 1e-6);
-
-
- fprintf(stdout, "absolute timer test (at 500 ms) ...\n");
- tnow = getustime(clks[i].id);
- set_timespec(&tmr.it_value, tnow + 500 * 1000);
- set_timespec(&tmr.it_interval, 0);
- if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &tmr, NULL))
- {
- perror("timerfd_settime");
- return 1;
- }
-
- fprintf(stdout, "wating timer ...\n");
- ticks = waittmr(tfd, -1);
- ttmr = getustime(clks[i].id);
- if (ticks <= 0)
- fprintf(stdout, "whooops! no timer showed up!\n");
- else
- fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
- ticks, (ttmr - tnow) * 1e-6);
-
- fprintf(stdout, "sequential timer test (100 ms clock) ...\n");
- tnow = getustime(clks[i].id);
- set_timespec(&tmr.it_value, tnow + 100 * 1000);
- set_timespec(&tmr.it_interval, 100 * 1000);
- if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &tmr, NULL))
- {
- perror("timerfd_settime");
- return 1;
- }
-
- fprintf(stdout, "sleeping one second ...\n");
- sleep(1);
- if (timerfd_gettime(tfd, &tmr))
- {
- perror("timerfd_gettime");
- return 1;
- }
- fprintf(stdout, "timerfd_gettime returned:\n"
- "\tit_value = %.1f it_interval = %.1f\n",
- tmr.it_value.tv_sec + 1e-9 * tmr.it_value.tv_nsec,
- tmr.it_interval.tv_sec + 1e-9 * tmr.it_interval.tv_nsec);
- fprintf(stdout, "sleeping 1 second ...\n");
- sleep(1);
-
- fprintf(stdout, "wating timer ...\n");
- ticks = waittmr(tfd, -1);
- ttmr = getustime(clks[i].id);
- if (ticks <= 0)
- fprintf(stdout, "whooops! no timer showed up!\n");
- else
- fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
- ticks, (ttmr - tnow) * 1e-6);
-
-
- fprintf(stdout, "O_NONBLOCK test ...\n");
- tnow = getustime(clks[i].id);
- set_timespec(&tmr.it_value, 100 * 1000);
- set_timespec(&tmr.it_interval, 0);
- if (timerfd_settime(tfd, 0, &tmr, NULL))
- {
- perror("timerfd_settime");
- return 1;
- }
-#if 0
- fprintf(stdout, "timerfd = %d\n", tfd);
-#endif
-
- fprintf(stdout, "wating timer (flush the single tick) ...\n");
- ticks = waittmr(tfd, -1);
- ttmr = getustime(clks[i].id);
- if (ticks <= 0)
- fprintf(stdout, "whooops! no timer showed up!\n");
- else
- fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
- ticks, (ttmr - tnow) * 1e-6);
-
- fcntl(tfd, F_SETFL, fcntl(tfd, F_GETFL, 0) | O_NONBLOCK);
-
- if (read(tfd, &uticks, sizeof(uticks)) > 0)
- fprintf(stdout, "whooops! timer ticks not zero when should have been\n");
- else if (errno != EAGAIN)
- fprintf(stdout, "whooops! bad errno value (%d = '%s')!\n",
- errno, strerror(errno));
- else
- fprintf(stdout, "success\n");
-
- fcntl(tfd, F_SETFL, fcntl(tfd, F_GETFL, 0) & ~O_NONBLOCK);
-
- close(tfd);
- }
-
- return 0;
-}
-
-#endif /* __linux__ */
-
-#if defined(_AIX)
-#include <stdio.h>
-int main(int ac, char **av)
-{
- fprintf(stderr, "This test does not work on AIX5.\n");
- return 0;
-}
-#endif /* _AIX */
Deleted: branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.stderr.exp
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.stderr.exp 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.stderr.exp 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,7 +0,0 @@
-
-
-ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
-malloc/free: in use at exit: 0 bytes in 0 blocks.
-malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
-For a detailed leak analysis, rerun with: --leak-check=yes
-For counts of detected errors, rerun with: -v
Deleted: branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.vgtest
===================================================================
--- branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.vgtest 2009-01-13 03:32:52 UTC (rev 8943)
+++ branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.vgtest 2009-01-13 04:25:04 UTC (rev 8944)
@@ -1,2 +0,0 @@
-prereq: [ "$(uname)" = "Linux" ] && awk 'END{exit("'$(uname -r)'" >= "2.6.25" ? 0 : 1)}' </dev/null
-prog: linux-timerfd-syscall
Copied: branches/DARWIN/memcheck/tests/linux/timerfd-syscall.c (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.c)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/timerfd-syscall.c (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/timerfd-syscall.c 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,310 @@
+/** Test Valgrind's interception of the Linux syscalls timerfd_create(),
+ * timerfd_gettime() and timerfd_settime().
+ *
+ * This is a modified version of
+ * timerfd-test2 by Davide Libenzi (test app for timerfd)
+ * Copyright (C) 2007 Davide Libenzi <da...@xm...>
+ * Modified for inclusion in Valgrind.
+ * Copyright (C) 2008 Bart Van Assche <bar...@gm...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * See also http://www.xmailserver.org/timerfd-test2.c
+ */
+
+#if defined(__linux__)
+
+#define _GNU_SOURCE
+
+#include "../../config.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+#if defined(HAVE_SYS_SIGNAL_H)
+#include <sys/signal.h>
+#endif
+#if defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+
+/*
+ * timerfd_* system call numbers introduced in 2.6.23. These constants are
+ * not yet in the glibc 2.7 headers, that is why they are defined here.
+ */
+#ifndef __NR_timerfd_create
+#if defined(__x86_64__)
+#define __NR_timerfd_create 283
+#define __NR_timerfd_settime 286
+#define __NR_timerfd_gettime 287
+#elif defined(__i386__)
+#define __NR_timerfd_create 322
+#define __NR_timerfd_settime 325
+#define __NR_timerfd_gettime 326
+#elif defined(__powerpc__)
+#define __NR_timerfd_create 306
+#define __NR_timerfd_settime 311
+#define __NR_timerfd_gettime 312
+#else
+#error Cannot detect your architecture!
+#endif
+#endif
+
+
+
+/* Definitions from include/linux/timerfd.h */
+#define TFD_TIMER_ABSTIME (1 << 0)
+
+
+
+struct tmr_type
+{
+ int id;
+ char const *name;
+};
+
+
+#if defined(HAVE_CLOCK_GETTIME)
+unsigned long long getustime(int clockid)
+{
+ struct timespec tp;
+
+ if (clock_gettime((clockid_t) clockid, &tp))
+ {
+ perror("clock_gettime");
+ return 0;
+ }
+
+ return 1000000ULL * tp.tv_sec + tp.tv_nsec / 1000;
+}
+#else
+unsigned long long getustime(int clockid)
+{
+ fprintf(stderr, "error: clock_gettime\n");
+ return 0;
+}
+#endif
+
+void set_timespec(struct timespec *tmr, unsigned long long ustime)
+{
+ tmr->tv_sec = (time_t) (ustime / 1000000ULL);
+ tmr->tv_nsec = (long) (1000ULL * (ustime % 1000000ULL));
+}
+
+int timerfd_create(int clockid, int flags)
+{
+ return syscall(__NR_timerfd_create, clockid, flags);
+}
+
+int timerfd_settime(int ufc, int flags, const struct itimerspec *utmr,
+ struct itimerspec *otmr)
+{
+ return syscall(__NR_timerfd_settime, ufc, flags, utmr, otmr);
+}
+
+int timerfd_gettime(int ufc, struct itimerspec *otmr)
+{
+ return syscall(__NR_timerfd_gettime, ufc, otmr);
+}
+
+long waittmr(int tfd, int timeo)
+{
+ u_int64_t ticks;
+ struct pollfd pfd;
+
+ pfd.fd = tfd;
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ if (poll(&pfd, 1, timeo) < 0)
+ {
+ perror("poll");
+ return -1;
+ }
+ if ((pfd.revents & POLLIN) == 0)
+ {
+ fprintf(stdout, "no ticks happened\n");
+ return -1;
+ }
+ if (read(tfd, &ticks, sizeof(ticks)) != sizeof(ticks))
+ {
+ perror("timerfd read");
+ return -1;
+ }
+
+ return ticks;
+}
+
+int main(int ac, char **av)
+{
+ int i, tfd;
+ long ticks;
+ unsigned long long tnow, ttmr;
+ u_int64_t uticks;
+ struct itimerspec tmr;
+ struct tmr_type clks[] =
+ {
+#if defined(HAVE_CLOCK_MONOTONIC)
+ { CLOCK_MONOTONIC, "CLOCK MONOTONIC" },
+#endif
+ { CLOCK_REALTIME, "CLOCK REALTIME" },
+ };
+
+ for (i = 0; i < sizeof(clks) / sizeof(clks[0]); i++)
+ {
+ fprintf(stdout, "\n\n---------------------------------------\n");
+ fprintf(stdout, "| testing %s\n", clks[i].name);
+ fprintf(stdout, "---------------------------------------\n\n");
+
+ fprintf(stdout, "relative timer test (at 500 ms) ...\n");
+ set_timespec(&tmr.it_value, 500 * 1000);
+ set_timespec(&tmr.it_interval, 0);
+ tnow = getustime(clks[i].id);
+ if ((tfd = timerfd_create(clks[i].id, 0)) == -1)
+ {
+ perror("timerfd_create");
+ return 1;
+ }
+
+ if (timerfd_settime(tfd, 0, &tmr, NULL))
+ {
+ perror("timerfd_settime");
+ return 1;
+ }
+
+ fprintf(stdout, "wating timer ...\n");
+ ticks = waittmr(tfd, -1);
+ ttmr = getustime(clks[i].id);
+ if (ticks <= 0)
+ fprintf(stdout, "whooops! no timer showed up!\n");
+ else
+ fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
+ ticks, (ttmr - tnow) * 1e-6);
+
+
+ fprintf(stdout, "absolute timer test (at 500 ms) ...\n");
+ tnow = getustime(clks[i].id);
+ set_timespec(&tmr.it_value, tnow + 500 * 1000);
+ set_timespec(&tmr.it_interval, 0);
+ if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &tmr, NULL))
+ {
+ perror("timerfd_settime");
+ return 1;
+ }
+
+ fprintf(stdout, "wating timer ...\n");
+ ticks = waittmr(tfd, -1);
+ ttmr = getustime(clks[i].id);
+ if (ticks <= 0)
+ fprintf(stdout, "whooops! no timer showed up!\n");
+ else
+ fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
+ ticks, (ttmr - tnow) * 1e-6);
+
+ fprintf(stdout, "sequential timer test (100 ms clock) ...\n");
+ tnow = getustime(clks[i].id);
+ set_timespec(&tmr.it_value, tnow + 100 * 1000);
+ set_timespec(&tmr.it_interval, 100 * 1000);
+ if (timerfd_settime(tfd, TFD_TIMER_ABSTIME, &tmr, NULL))
+ {
+ perror("timerfd_settime");
+ return 1;
+ }
+
+ fprintf(stdout, "sleeping one second ...\n");
+ sleep(1);
+ if (timerfd_gettime(tfd, &tmr))
+ {
+ perror("timerfd_gettime");
+ return 1;
+ }
+ fprintf(stdout, "timerfd_gettime returned:\n"
+ "\tit_value = %.1f it_interval = %.1f\n",
+ tmr.it_value.tv_sec + 1e-9 * tmr.it_value.tv_nsec,
+ tmr.it_interval.tv_sec + 1e-9 * tmr.it_interval.tv_nsec);
+ fprintf(stdout, "sleeping 1 second ...\n");
+ sleep(1);
+
+ fprintf(stdout, "wating timer ...\n");
+ ticks = waittmr(tfd, -1);
+ ttmr = getustime(clks[i].id);
+ if (ticks <= 0)
+ fprintf(stdout, "whooops! no timer showed up!\n");
+ else
+ fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
+ ticks, (ttmr - tnow) * 1e-6);
+
+
+ fprintf(stdout, "O_NONBLOCK test ...\n");
+ tnow = getustime(clks[i].id);
+ set_timespec(&tmr.it_value, 100 * 1000);
+ set_timespec(&tmr.it_interval, 0);
+ if (timerfd_settime(tfd, 0, &tmr, NULL))
+ {
+ perror("timerfd_settime");
+ return 1;
+ }
+#if 0
+ fprintf(stdout, "timerfd = %d\n", tfd);
+#endif
+
+ fprintf(stdout, "wating timer (flush the single tick) ...\n");
+ ticks = waittmr(tfd, -1);
+ ttmr = getustime(clks[i].id);
+ if (ticks <= 0)
+ fprintf(stdout, "whooops! no timer showed up!\n");
+ else
+ fprintf(stdout, "got timer ticks (%ld) after %.1f s\n",
+ ticks, (ttmr - tnow) * 1e-6);
+
+ fcntl(tfd, F_SETFL, fcntl(tfd, F_GETFL, 0) | O_NONBLOCK);
+
+ if (read(tfd, &uticks, sizeof(uticks)) > 0)
+ fprintf(stdout, "whooops! timer ticks not zero when should have been\n");
+ else if (errno != EAGAIN)
+ fprintf(stdout, "whooops! bad errno value (%d = '%s')!\n",
+ errno, strerror(errno));
+ else
+ fprintf(stdout, "success\n");
+
+ fcntl(tfd, F_SETFL, fcntl(tfd, F_GETFL, 0) & ~O_NONBLOCK);
+
+ close(tfd);
+ }
+
+ return 0;
+}
+
+#endif /* __linux__ */
+
+#if defined(_AIX)
+#include <stdio.h>
+int main(int ac, char **av)
+{
+ fprintf(stderr, "This test does not work on AIX5.\n");
+ return 0;
+}
+#endif /* _AIX */
Copied: branches/DARWIN/memcheck/tests/linux/timerfd-syscall.stderr.exp (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.stderr.exp)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/timerfd-syscall.stderr.exp (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/timerfd-syscall.stderr.exp 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,7 @@
+
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: 0 bytes in 0 blocks.
+malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
+For a detailed leak analysis, rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
Copied: branches/DARWIN/memcheck/tests/linux/timerfd-syscall.vgtest (from rev 8943, branches/DARWIN/memcheck/tests/linux/linux-timerfd-syscall.vgtest)
===================================================================
--- branches/DARWIN/memcheck/tests/linux/timerfd-syscall.vgtest (rev 0)
+++ branches/DARWIN/memcheck/tests/linux/timerfd-syscall.vgtest 2009-01-13 04:25:04 UTC (rev 8944)
@@ -0,0 +1,2 @@
+prereq: [ "$(uname)" = "Linux" ] && awk 'END{exit("'$(uname -r)'" >= "2.6.25" ? 0 : 1)}' </dev/null
+prog: linux-timerfd-syscall
|
|
From: Bart V. A. <bar...@gm...> - 2009-01-13 09:18:52
|
On Tue, Jan 13, 2009 at 5:25 AM, <sv...@va...> wrote: > Modified: branches/DARWIN/memcheck/tests/linux/Makefile.am > =================================================================== > --- branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 03:32:52 UTC (rev 8943) > +++ branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 04:25:04 UTC (rev 8944) > @@ -1,12 +1,12 @@ > noinst_SCRIPTS = filter_stderr > > EXTRA_DIST = $(noinst_SCRIPTS) \ > - linux-capget linux-capget.stderr.exp \ > - linux-timerfd-syscall linux-timerfd-syscall.stderr.exp > + capget capget.stderr.exp \ > + timerfd-syscall timerfd-syscall.stderr.exp > > check_PROGRAMS = \ > - linux-capget \ > - linux-timerfd-syscall > + capget \ > + timerfd-syscall > > AM_CPPFLAGS = -I$(top_srcdir)/include > AM_CFLAGS = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \ > > [ ... ] Hello Nicholas, Are you aware that autoconf/automake supports conditional compilation ? You can find an example in drd/tests/Makefile.am, e.g. in the following lines: if HAVE_BOOST_1_35 check_PROGRAMS += boost_thread endif Bart. |
|
From: Nicholas N. <n.n...@gm...> - 2009-01-13 22:57:56
|
On Tue, Jan 13, 2009 at 8:18 PM, Bart Van Assche <bar...@gm...> wrote: > On Tue, Jan 13, 2009 at 5:25 AM, <sv...@va...> wrote: >> Modified: branches/DARWIN/memcheck/tests/linux/Makefile.am >> =================================================================== >> --- branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 03:32:52 UTC (rev 8943) >> +++ branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 04:25:04 UTC (rev 8944) >> @@ -1,12 +1,12 @@ >> noinst_SCRIPTS = filter_stderr >> >> EXTRA_DIST = $(noinst_SCRIPTS) \ >> - linux-capget linux-capget.stderr.exp \ >> - linux-timerfd-syscall linux-timerfd-syscall.stderr.exp >> + capget capget.stderr.exp \ >> + timerfd-syscall timerfd-syscall.stderr.exp >> >> check_PROGRAMS = \ >> - linux-capget \ >> - linux-timerfd-syscall >> + capget \ >> + timerfd-syscall >> >> AM_CPPFLAGS = -I$(top_srcdir)/include >> AM_CFLAGS = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \ >> >> [ ... ] > > Hello Nicholas, > > Are you aware that autoconf/automake supports conditional compilation > ? You can find an example in drd/tests/Makefile.am, e.g. in the > following lines: > > if HAVE_BOOST_1_35 > check_PROGRAMS += boost_thread > endif Yes, it's used in lots of our Makefile.am files. But what is the relevance for this file? Nick |
|
From: Bart V. A. <bar...@gm...> - 2009-01-14 07:14:51
|
Met vriendelijke groeten, Bart Van Assche. On Tue, Jan 13, 2009 at 11:57 PM, Nicholas Nethercote <n.n...@gm...> wrote: > > On Tue, Jan 13, 2009 at 8:18 PM, Bart Van Assche > <bar...@gm...> wrote: > > On Tue, Jan 13, 2009 at 5:25 AM, <sv...@va...> wrote: > >> Modified: branches/DARWIN/memcheck/tests/linux/Makefile.am > >> =================================================================== > >> --- branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 03:32:52 UTC (rev 8943) > >> +++ branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 04:25:04 UTC (rev 8944) > >> @@ -1,12 +1,12 @@ > >> noinst_SCRIPTS = filter_stderr > >> > >> EXTRA_DIST = $(noinst_SCRIPTS) \ > >> - linux-capget linux-capget.stderr.exp \ > >> - linux-timerfd-syscall linux-timerfd-syscall.stderr.exp > >> + capget capget.stderr.exp \ > >> + timerfd-syscall timerfd-syscall.stderr.exp > >> > >> check_PROGRAMS = \ > >> - linux-capget \ > >> - linux-timerfd-syscall > >> + capget \ > >> + timerfd-syscall > >> > >> AM_CPPFLAGS = -I$(top_srcdir)/include > >> AM_CFLAGS = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \ > >> > >> [ ... ] > > > > Hello Nicholas, > > > > Are you aware that autoconf/automake supports conditional compilation > > ? You can find an example in drd/tests/Makefile.am, e.g. in the > > following lines: > > > > if HAVE_BOOST_1_35 > > check_PROGRAMS += boost_thread > > endif > > Yes, it's used in lots of our Makefile.am files. But what is the > relevance for this file? The memcheck regression tests linux-capget and linux-timerfd-syscall are relevant for the Linux kernel but not for other kernels. Conditional compilation would allow to compile these only on Linux systems and not on other systems. Bart. |
|
From: Bart V. A. <bar...@gm...> - 2009-01-14 07:20:24
|
On Tue, Jan 13, 2009 at 11:57 PM, Nicholas Nethercote <n.n...@gm...> wrote: > On Tue, Jan 13, 2009 at 8:18 PM, Bart Van Assche > <bar...@gm...> wrote: >> On Tue, Jan 13, 2009 at 5:25 AM, <sv...@va...> wrote: >>> Modified: branches/DARWIN/memcheck/tests/linux/Makefile.am >>> =================================================================== >>> --- branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 03:32:52 UTC (rev 8943) >>> +++ branches/DARWIN/memcheck/tests/linux/Makefile.am 2009-01-13 04:25:04 UTC (rev 8944) >>> @@ -1,12 +1,12 @@ >>> noinst_SCRIPTS = filter_stderr >>> >>> EXTRA_DIST = $(noinst_SCRIPTS) \ >>> - linux-capget linux-capget.stderr.exp \ >>> - linux-timerfd-syscall linux-timerfd-syscall.stderr.exp >>> + capget capget.stderr.exp \ >>> + timerfd-syscall timerfd-syscall.stderr.exp >>> >>> check_PROGRAMS = \ >>> - linux-capget \ >>> - linux-timerfd-syscall >>> + capget \ >>> + timerfd-syscall >>> >>> AM_CPPFLAGS = -I$(top_srcdir)/include >>> AM_CFLAGS = $(WERROR) @FLAG_M32@ -Winline -Wall -Wshadow -g \ >>> >>> [ ... ] >> >> Hello Nicholas, >> >> Are you aware that autoconf/automake supports conditional compilation >> ? You can find an example in drd/tests/Makefile.am, e.g. in the >> following lines: >> >> if HAVE_BOOST_1_35 >> check_PROGRAMS += boost_thread >> endif > > Yes, it's used in lots of our Makefile.am files. But what is the > relevance for this file? Sorry, I didn't look closely enough to the diff. I do not understand why linux-timerfd-syscall.* was renamed into timerfd-syscall.*. AFAIK the timerfd system call only exists in Linux and not in other kernels (FreeBSD, Darwin) ? Bart. |
|
From: Nicholas N. <n.n...@gm...> - 2009-01-14 07:23:09
|
On Wed, Jan 14, 2009 at 6:20 PM, Bart Van Assche <bar...@gm...> wrote: > Sorry, I didn't look closely enough to the diff. I do not understand > why linux-timerfd-syscall.* was renamed into timerfd-syscall.*. AFAIK > the timerfd system call only exists in Linux and not in other kernels > (FreeBSD, Darwin) ? I moved those tests into a linux/ subdirectory. Hence the original log message: Rename linux/linux-* as linux/*. Nick |
|
From: Bart V. A. <bar...@gm...> - 2009-01-14 07:26:02
|
On Wed, Jan 14, 2009 at 8:23 AM, Nicholas Nethercote <n.n...@gm...> wrote: > On Wed, Jan 14, 2009 at 6:20 PM, Bart Van Assche > <bar...@gm...> wrote: >> Sorry, I didn't look closely enough to the diff. I do not understand >> why linux-timerfd-syscall.* was renamed into timerfd-syscall.*. AFAIK >> the timerfd system call only exists in Linux and not in other kernels >> (FreeBSD, Darwin) ? > > I moved those tests into a linux/ subdirectory. Hence the original log message: > > Rename linux/linux-* as linux/*. Thanks, I looked over that message. Bart. |