This is an automated email from the git hooks/post-receive script.
jforbes pushed a commit to branch master
in repository kernel-tests.
commit c7f1d4b259584b93c706c1543088cce0ff267152
Author: Dave Jones <davej(a)redhat.com>
Date: Tue Aug 14 10:47:38 2012 -0400
Add a test for excessive timer overhead.
This is really a test that CONFIG_HZ is set to something sensible.
---
default/timer-overhead/Makefile | 11 +++++++++
default/timer-overhead/runtest.sh | 15 ++++++++++++
default/timer-overhead/timer-test.c | 47 +++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/default/timer-overhead/Makefile b/default/timer-overhead/Makefile
new file mode 100644
index 0000000..d008df7
--- /dev/null
+++ b/default/timer-overhead/Makefile
@@ -0,0 +1,11 @@
+CFLAGS = -Wall -W -g -O2 -Wimplicit -D_FORTIFY_SOURCE=2
+
+all: timer-test
+
+timer-test: timer-test.o
+
+%.o : %.c
+ @$(CC) $(CFLAGS) -c $<
+
+clean:
+ @rm -f *.o timer-test
diff --git a/default/timer-overhead/runtest.sh b/default/timer-overhead/runtest.sh
new file mode 100755
index 0000000..ac43f9c
--- /dev/null
+++ b/default/timer-overhead/runtest.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+if [ ! -f ./timer-test ]; then
+ make
+ if [ "$?" -ne "0" ]; then
+ echo "Timer-test build failed."
+ exit -1
+ fi
+fi
+
+./timer-test
+if [ "$?" -ne "0" ]; then
+ echo "Test failure."
+ exit -1
+fi
diff --git a/default/timer-overhead/timer-test.c b/default/timer-overhead/timer-test.c
new file mode 100644
index 0000000..1c08647
--- /dev/null
+++ b/default/timer-overhead/timer-test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+unsigned long do_time(unsigned long usecs)
+{
+ struct timeval after, before;
+ int secs, usec;
+ gettimeofday(&before, NULL);
+ usleep(usecs);
+ gettimeofday(&after, NULL);
+ secs = after.tv_sec - before.tv_sec;
+ usec = after.tv_usec - before.tv_usec;
+ return secs * 1000000 + usec;
+}
+
+int main(void)
+{
+ unsigned long delays = 0;
+ int i;
+ /* take the average over 100 measurements */
+ for (i = 0; i < 100; i++)
+ delays += do_time(1000);
+ delays = delays / 100;
+
+ /* we asked for a 1.000 msec delay, if this takes more than 2.5 msec that's
an unacceptable. */
+ if (delays > 2500) {
+ printf("Unacceptable long delay; asked for 1000 usec, got %li usec
\n", delays);
+ exit(EXIT_FAILURE);
+ }
+
+ delays = 0;
+ for (i = 0; i < 100; i++)
+ delays += do_time(2000);
+ delays = delays / 100;
+// printf("%li -> %li \n", 2000, delays);
+
+ /* we asked for a 2.000 msec delay, if this takes more than 3.5 msec that's
unacceptable. */
+ if (delays > 3500) {
+ printf("Unacceptable long delay; asked for 2000 usec, got %li usec
\n", delays);
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
+}
+
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.