add test
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 29 May 2006 12:38:22 +0000 (12:38 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 29 May 2006 12:38:22 +0000 (12:38 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1863 04897980-b3bd-0310-b5e0-8ef037075253

tests/kernel/Makefile
tests/kernel/test-cmpxchg.c [new file with mode: 0644]

index 8ee754f9b275a5fe4f66fc89c579afa7208cbbc8..a2985567eb552277a504d2b4720222eccee32d8d 100644 (file)
@@ -6,6 +6,7 @@ ifneq ($(CONFIG_LTT),)
        obj-m += test-instrument-size-med.o
        obj-m += test-instrument-size-big.o
        obj-m += test-printk-effect.o
+       obj-m += test-cmpxchg.o
 endif
 
 else
diff --git a/tests/kernel/test-cmpxchg.c b/tests/kernel/test-cmpxchg.c
new file mode 100644 (file)
index 0000000..a816633
--- /dev/null
@@ -0,0 +1,68 @@
+/* test-cmpxchg.c
+ *
+ * Test time spent in a LTTng instrumentation probe.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/ltt-core.h>
+#include <asm/system.h>
+
+#define NR_LOOPS 2000
+
+static volatile int test_val = 100;
+
+static void do_test(void)
+{
+       int val;
+
+       val = test_val;
+       
+       ret = cmpxchg(&test_val, val, 101);
+}
+
+static int ltt_test_init(void)
+{
+       unsigned int i;
+       cycles_t time1, time2, time;
+       cycles_t max_time = 0, min_time = 18446744073709551615ULL; /* (2^64)-1 */
+       cycles_t tot_time = 0;
+       unsigned long flags;
+       printk(KERN_ALERT "test init\n");
+       
+       local_irq_save(flags);
+       for(i=0; i<NR_LOOPS; i++) {
+               time1 = get_cycles();
+               do_test();
+               time2 = get_cycles();
+               time = time2 - time1;
+               max_time = max(max_time, time);
+               min_time = min(min_time, time);
+               tot_time += time;
+       }
+       local_irq_restore(flags);
+
+       printk(KERN_ALERT "test results : time per probe\n");
+       printk(KERN_ALERT "number of loops : %d\n", NR_LOOPS);
+       printk(KERN_ALERT "total time : %llu\n", tot_time);
+       printk(KERN_ALERT "min : %llu\n", min_time);
+       printk(KERN_ALERT "max : %llu\n", max_time);
+
+       printk(KERN_ALERT "test end\n");
+       
+       return -EAGAIN; /* Fail will directly unload the module */
+}
+
+static void ltt_test_exit(void)
+{
+       printk(KERN_ALERT "test exit\n");
+}
+
+module_init(ltt_test_init)
+module_exit(ltt_test_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Test");
+
This page took 0.052519 seconds and 4 git commands to generate.