From f6e76b8f246215598fd82b35d8ced3d28983043d Mon Sep 17 00:00:00 2001
From: Stephan Zeisberg <stephan@ramssys.(none)>
Date: Tue, 26 Oct 2010 17:06:07 +0200
Subject: [PATCH] python expect hwtimer test included

---
 projects/test_hwtimer_basic/Jamfile           |  5 ++++
 projects/test_hwtimer_basic/main.c            | 29 +++++++++++++++++++
 .../test_hwtimer_basic/tests/test_hwtimer.py  | 17 +++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 projects/test_hwtimer_basic/Jamfile
 create mode 100644 projects/test_hwtimer_basic/main.c
 create mode 100755 projects/test_hwtimer_basic/tests/test_hwtimer.py

diff --git a/projects/test_hwtimer_basic/Jamfile b/projects/test_hwtimer_basic/Jamfile
new file mode 100644
index 0000000000..e9f9af9ec8
--- /dev/null
+++ b/projects/test_hwtimer_basic/Jamfile
@@ -0,0 +1,5 @@
+SubDir TOP projects test_hwtimer ;
+
+Module test_hwtimer : main.c : hwtimer ;
+
+UseModule test_hwtimer ;
diff --git a/projects/test_hwtimer_basic/main.c b/projects/test_hwtimer_basic/main.c
new file mode 100644
index 0000000000..8e215d1056
--- /dev/null
+++ b/projects/test_hwtimer_basic/main.c
@@ -0,0 +1,29 @@
+#include <stdio.h>
+#include <hwtimer.h>
+#include <kernel.h>
+#include <board.h>
+
+void callback(void* ptr) {
+    puts((char*)ptr);       
+}
+
+extern uint32_t hwtimer_now();
+
+int main(void)
+{
+    puts("hwtimer test project.");
+
+    puts("Initializing hwtimer...");
+    hwtimer_init();
+
+    puts("Initializing hwtimer [OK].");
+   
+
+//    while (TA0R < 20000);
+
+    hwtimer_set(20000LU, callback, (void*)"callback1");
+    hwtimer_set(50000LU, callback, (void*)"callback2");
+    hwtimer_set(30000LU, callback, (void*)"callback3");
+    
+    puts("hwtimer set.");
+}
diff --git a/projects/test_hwtimer_basic/tests/test_hwtimer.py b/projects/test_hwtimer_basic/tests/test_hwtimer.py
new file mode 100755
index 0000000000..261c511bb1
--- /dev/null
+++ b/projects/test_hwtimer_basic/tests/test_hwtimer.py
@@ -0,0 +1,17 @@
+#!/usr/bin/python
+
+import pexpect
+import os
+import subprocess
+
+child = pexpect.spawn ("board/msba2/tools/bin/pseudoterm %s" % os.environ["PORT"])
+
+null = open('/dev/null', 'wb')
+subprocess.call(['jam', 'reset'], stdout=null)
+
+child.expect ('OK\r\n');
+child.expect ('callback1\r\n');
+child.expect ('callback3\r\n');
+child.expect ('callback2\r\n');
+print("Test successful!")
+
-- 
GitLab