Extremely basic platform integration tests.

These are mostly usable as examples.  We don't yet attempt to install a
software image before starting, nor do we run any tests in parallel, or
attempt to use multiple devices, or connect to ssh.  We just always use the
serial port on /dev/ttyS0 (but 'make PORT=/dev/ttyUSB0 test' if you want to
override the port).

We use wvtest, a test framework that uses a text-based protocol to send
results, and portsh.py to send those results back from the test device to
the local machine for parsing.

Change-Id: I05c4e148f864fb0f42441db0cefbece14c0f29c4
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2f836aa
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*~
+*.pyc
diff --git a/001-shtest.sh b/001-shtest.sh
new file mode 100755
index 0000000..466102f
--- /dev/null
+++ b/001-shtest.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+. ./wvtest/wvtest.sh
+
+WVSTART "basic sh functionality"
+WVPASS true
+WVFAIL false
+WVPASSEQ "yes" "yes"
+WVPASSNE "yes" "no"
diff --git a/002-pytest.py b/002-pytest.py
new file mode 100644
index 0000000..dc18fd9
--- /dev/null
+++ b/002-pytest.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+# Copyright 2012 Google Inc. All Rights Reserved.
+#
+# Disable some checks that aren't important for tests:
+#gpylint: disable-msg=E0602,C6409,C6111,C0111
+
+__author__ = 'Avery Pennarun (apenwarr@google.com)'
+
+from wvtest import *
+
+
+@wvtest
+def TestBasicPython():
+  WVPASS(True)
+  WVPASSEQ(1, 1)
+  WVPASSNE(1, 2)
diff --git a/101-sysmgr.sh b/101-sysmgr.sh
new file mode 100755
index 0000000..52eee48
--- /dev/null
+++ b/101-sysmgr.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+. ./wvtest/wvtest.sh
+
+running() {
+  [ -n "$(pgrep -x "$1")" ]
+}
+
+WVSTART "sysmgr"
+WVPASS running sysmgr
+WVFAIL running this-does-not-exist
+
+WVPASS [ -n "$(dmesg | grep sysmgr: | head)" ]
diff --git a/102-cwmpd.sh b/102-cwmpd.sh
new file mode 100755
index 0000000..b2b9bc9
--- /dev/null
+++ b/102-cwmpd.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+. ./wvtest/wvtest.sh
+
+running() {
+  [ -n "$(pgrep -x "$1")" ]
+}
+
+WVSTART "cwmpd"
+WVPASS running cwmpd
+
+echo ls | cwmp | WVPASS grep X_CATAWAMPUS-ORG_CATAWAMPUS
+echo ls | cwmp | WVFAIL grep NON_EXISTENT_NAME
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4922c26
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
+PORT=/dev/ttyS0
+PASSWORD=google
+PORTSH=./portsh/portsh $(PORT) -p'$(PASSWORD)'
+.NOTPARALLEL:
+
+default: all
+
+all:
+	@echo "Nothing to do."
+
+test: install-wvtest
+	wvtest/wvtestrun $(MAKE) runtests
+
+runtests: $(addsuffix .run,$(wildcard [0-9]*.sh [0-9]*.py))
+
+install-wvtest:
+	tar -cf - *.py *.sh wvtest/ | \
+	$(PORTSH) \
+		'mkdir -p /tmp/tests && cd /tmp/tests && tar -xf -'
+
+%.sh.run: %.sh install-wvtest
+	echo "Testing $<"
+	$(PORTSH) \
+		'cd /tmp/tests && sh ./$<' </dev/null
+
+%.py.run: %.py install-wvtest
+	echo "Testing $<"
+	$(PORTSH) \
+		'cd /tmp/tests && python ./wvtest/wvtest.py $<' </dev/null
+
+clean:
+	rm -f *~ .*~ */*~ */.*~ *.pyc */*.pyc