aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2016-07-15 18:31:48 +0800
committerChase Qi <chase.qi@linaro.org>2016-07-15 18:38:42 +0800
commit19b730ecaff1fad6b2cff121cce6cb1804a54956 (patch)
tree1e056d88f58f4082bc2f8bb71beafd4b257095bb
Initial commit
-rw-r--r--lava-local-test.py122
-rw-r--r--lava_test_shell/README11
-rwxr-xr-xlava_test_shell/distro/android/lava-test-runner113
-rw-r--r--lava_test_shell/distro/centos/lava-install-packages17
-rw-r--r--lava_test_shell/distro/centos/lava-installed-packages3
-rw-r--r--lava_test_shell/distro/centos/lava-os-build32
-rw-r--r--lava_test_shell/distro/debian/lava-add-keys9
-rw-r--r--lava_test_shell/distro/debian/lava-add-sources20
-rw-r--r--lava_test_shell/distro/debian/lava-install-packages19
-rw-r--r--lava_test_shell/distro/debian/lava-installed-packages3
-rw-r--r--lava_test_shell/distro/debian/lava-os-build20
-rw-r--r--lava_test_shell/distro/fedora/lava-install-packages17
-rw-r--r--lava_test_shell/distro/fedora/lava-installed-packages3
-rw-r--r--lava_test_shell/distro/fedora/lava-os-build32
-rw-r--r--lava_test_shell/distro/oe/lava-install-packages30
-rw-r--r--lava_test_shell/distro/oe/lava-installed-packages11
-rw-r--r--lava_test_shell/distro/ubuntu/lava-add-keys9
-rw-r--r--lava_test_shell/distro/ubuntu/lava-add-sources20
-rw-r--r--lava_test_shell/distro/ubuntu/lava-install-packages19
-rw-r--r--lava_test_shell/distro/ubuntu/lava-installed-packages3
-rw-r--r--lava_test_shell/distro/ubuntu/lava-os-build20
-rwxr-xr-xlava_test_shell/lava-add-keys9
-rwxr-xr-xlava_test_shell/lava-add-sources20
-rwxr-xr-xlava_test_shell/lava-background-process-start45
-rwxr-xr-xlava_test_shell/lava-background-process-stop52
-rwxr-xr-xlava_test_shell/lava-echo-ipv420
-rwxr-xr-xlava_test_shell/lava-install-packages19
-rwxr-xr-xlava_test_shell/lava-installed-packages3
-rwxr-xr-xlava_test_shell/lava-os-build20
-rwxr-xr-xlava_test_shell/lava-test-case88
-rwxr-xr-xlava_test_shell/lava-test-case-attach51
-rwxr-xr-xlava_test_shell/lava-test-case-metadata25
-rwxr-xr-xlava_test_shell/lava-test-run-attach40
-rwxr-xr-xlava_test_shell/lava-test-runner117
-rwxr-xr-xlava_test_shell/lava-test-set33
-rwxr-xr-xlava_test_shell/lava-test-shell15
-rwxr-xr-xlava_test_shell/lava-vm-groups-setup-host13
-rw-r--r--lava_test_shell/lmp/lava-lmp-audio-jack22
-rw-r--r--lava_test_shell/lmp/lava-lmp-eth22
-rw-r--r--lava_test_shell/lmp/lava-lmp-hdmi36
-rw-r--r--lava_test_shell/lmp/lava-lmp-lsgpio22
-rw-r--r--lava_test_shell/lmp/lava-lmp-sata22
-rw-r--r--lava_test_shell/lmp/lava-lmp-usb22
-rw-r--r--lava_test_shell/lmp/lava-lmp.lib159
-rw-r--r--lava_test_shell/multi_node/lava-echo-config30
-rw-r--r--lava_test_shell/multi_node/lava-group40
-rw-r--r--lava_test_shell/multi_node/lava-multi-node.lib252
-rw-r--r--lava_test_shell/multi_node/lava-network110
-rw-r--r--lava_test_shell/multi_node/lava-role23
-rw-r--r--lava_test_shell/multi_node/lava-self9
-rw-r--r--lava_test_shell/multi_node/lava-send17
-rw-r--r--lava_test_shell/multi_node/lava-start-vms6
-rw-r--r--lava_test_shell/multi_node/lava-sync20
-rw-r--r--lava_test_shell/multi_node/lava-wait21
-rw-r--r--lava_test_shell/multi_node/lava-wait-all23
-rw-r--r--lava_test_shell/multi_node/lava-wait-for-vms6
-rw-r--r--lava_test_shell/vland/lava-vland-self9
-rw-r--r--lava_test_shell/vland/lava-vland-tags9
-rw-r--r--pi.yaml44
-rw-r--r--smoke.yaml27
60 files changed, 2054 insertions, 0 deletions
diff --git a/lava-local-test.py b/lava-local-test.py
new file mode 100644
index 0000000..99203ca
--- /dev/null
+++ b/lava-local-test.py
@@ -0,0 +1,122 @@
+import sys
+import os
+import shutil
+import time
+import re
+import yaml
+import subprocess
+import pexpect
+from uuid import uuid4
+
+
+HOME = os.environ['HOME']
+LAVA_PATH = HOME + '/lava_test_output'
+test_definition = 'smoke.yaml'
+
+
+class TestDefinition(object):
+ """
+ Analysis and convert test definition.
+ """
+
+ def __init__(self, test_definition, test_path):
+ self.test_definition = test_definition
+ self.test_path = test_path
+ # Read the YAML to create a testdef dict
+ with open(self.test_definition, 'r') as test_file:
+ self.testdef = yaml.safe_load(test_file)
+
+ def definition(self):
+ with open('%s/testdef.yaml' % self.test_path, 'w') as f:
+ f.write(yaml.dump(self.testdef, encoding='utf-8', allow_unicode=True))
+
+ def metadata(self):
+ with open('%s/testdef_metadata' % self.test_path, 'w') as f:
+ f.write(yaml.dump(self.testdef['metadata'], encoding='utf-8', allow_unicode=True))
+
+ def install(self):
+ pass
+
+ def run(self):
+ with open('%s/run.sh' % self.test_path, 'a') as runsh:
+ runsh.write('set -e\n')
+ runsh.write('export TESTRUN_ID=%s\n' % self.testdef['metadata']['name'])
+ runsh.write('cd %s\n' % self.test_path)
+ runsh.write('UUID=`cat uuid`\n')
+ runsh.write('echo "<LAVA_SIGNAL_STARTRUN $TESTRUN_ID $UUID>"\n')
+ steps = self.testdef['run'].get('steps', [])
+ if steps:
+ for cmd in steps:
+ if '--cmd' in cmd or '--shell' in cmd:
+ cmd = re.sub(r'\$(\d+)\b', r'\\$\1', cmd)
+ runsh.write('%s\n' % cmd)
+ runsh.write('echo "<LAVA_SIGNAL_ENDRUN $TESTRUN_ID $UUID>"\n')
+
+ def parameters(self):
+ pass
+
+
+class TestSetup(object):
+ def __init__(self, lava_path, test_definition):
+ self.lava_path = lava_path
+ self.test_name = os.path.splitext(test_definition)[0]
+ self.uuid = str(uuid4())
+ self.test_uuid = self.test_name + '_' + self.uuid
+ self.bin_path = lava_path + '/bin'
+ self.test_path = lava_path + '/tests/' + self.test_uuid
+ self.result_path = lava_path + '/results/' + self.test_uuid
+
+ def create_dir(self):
+ if not os.path.exists(self.test_path):
+ os.makedirs(self.test_path)
+
+ def create_test_runner_conf(self):
+ with open('%s/lava-test-runner.conf' % self.lava_path, 'w') as f:
+ f.write(self.test_path)
+
+ def copy_bin_files(self):
+ shutil.rmtree(self.bin_path, ignore_errors=True)
+ shutil.copytree('lava_test_shell', self.bin_path, symlinks=True)
+
+ def create_uuid_file(self):
+ with open('%s/uuid' % self.test_path, 'w') as f:
+ f.write(self.uuid)
+
+ def get_test_path(self):
+ return self.test_path
+
+ def get_result_path(self):
+ return self.result_path
+
+
+class TestRunner(object):
+ def __init__(self, lava_path):
+ self.lava_path = lava_path
+ self.child = pexpect.spawn('%s/bin/lava-test-runner %s' % (self.lava_path, self.lava_path))
+
+ def check_output(self):
+ while True:
+ try:
+ self.child.expect('\n')
+ print(self.child.before)
+ except pexpect.EOF:
+ break
+
+# Create a hierarchy of directories and files needed.
+test_setup = TestSetup(LAVA_PATH, test_definition)
+test_setup.create_dir()
+test_setup.create_test_runner_conf()
+test_setup.copy_bin_files()
+test_setup.create_uuid_file()
+test_path = test_setup.get_test_path()
+
+# Convert test definition to the files needed by lava-test-runner.
+test_def = TestDefinition(test_definition, test_path)
+test_def.definition()
+test_def.metadata()
+test_def.install()
+test_def.run()
+
+# Test run.
+test_run = TestRunner(LAVA_PATH)
+test_run.check_output()
diff --git a/lava_test_shell/README b/lava_test_shell/README
new file mode 100644
index 0000000..4868b21
--- /dev/null
+++ b/lava_test_shell/README
@@ -0,0 +1,11 @@
+This directory contains support scripts for lava-test-shell.
+
+The scripts in this directory will be copied into the target device and will be
+in $PATH during the lava-test-shell execution.
+
+Distribution-specific scripts can be placed in distro/$distroname, and will
+override the ones in the top level directory. For example,
+distro/android/lava-test-runner will be used on Android instead of the
+lava-test-runner script present at the same directory as this README file.
+
+All scripts have to be named using a "lava-" suffix.
diff --git a/lava_test_shell/distro/android/lava-test-runner b/lava_test_shell/distro/android/lava-test-runner
new file mode 100755
index 0000000..fda69d5
--- /dev/null
+++ b/lava_test_shell/distro/android/lava-test-runner
@@ -0,0 +1,113 @@
+
+LCK=${LCK-"/lava-test-runner.lck"}
+
+#make sure we are only run once
+if [ ! -f ${LCK} ] ; then
+ ( flock -n 9 || exit 1 ; true ) 9>${LCK}
+else
+ exit 0
+fi
+
+if [ "$1" = "" ]
+then
+ LAVA_PATH="/data/lava"
+else
+ LAVA_PATH=$1
+fi
+
+echo $LAVA_PATH
+PREFIX="<LAVA_TEST_RUNNER>:"
+WORKFILE="$LAVA_PATH/lava-test-runner.conf"
+RESULTSDIR="$LAVA_PATH/results"
+BINDIR="$LAVA_PATH/bin"
+
+hwcontext()
+{
+ ODIR=$1
+ mkdir -p ${ODIR}/hwcontext
+ cpuinfo=${ODIR}/hwcontext/cpuinfo.txt
+ meminfo=${ODIR}/hwcontext/meminfo.txt
+
+ [ -f ${cpuinfo} ] || cat /proc/cpuinfo > ${cpuinfo}
+ [ -f ${meminfo} ] || cat /proc/meminfo > ${meminfo}
+}
+
+swcontext()
+{
+ ODIR=$1
+ mkdir -p ${ODIR}/swcontext
+ build=${ODIR}/swcontext/build.txt
+ pkgs=${ODIR}/swcontext/pkgs.txt
+
+ [ -f ${build} ] || getprop ro.build.display.id > ${build}
+ [ -f ${pkgs} ] || pm list packages > ${pkgs}
+}
+
+cleanup()
+{
+ # just adds a little handy debugging
+ ls ${RESULTSDIR}
+ echo "${PREFIX} calling sync on device"
+ sync
+ echo "${PREFIX} exiting lava-test-runner"
+}
+
+{
+ trap cleanup INT TERM EXIT
+
+ export PATH=${BINDIR}:${PATH}
+ echo "${PREFIX} started"
+ mkdir -p ${RESULTSDIR}
+
+ echo "${PREFIX} disabling suspend and waiting for home screen ..."
+ disablesuspend.sh
+
+ # move the workfile to something timestamped and run that. This
+ # prevents us from running the same thing again after a reboot
+ TS=`date +%s`
+ mv ${WORKFILE} ${WORKFILE}-${TS}
+ WORKFILE=${WORKFILE}-${TS}
+
+ echo "${PREFIX} looking for work in ${WORKFILE}"
+ for line in $(cat ${WORKFILE}); do
+ # we don't have "basename" on android, but this does the
+ # equivalent under mksh
+ testdir=${line%/} # trim off trailing slash iff it exists
+ test=${testdir/*\//}
+ echo "${PREFIX} running ${test} under lava-test-shell..."
+ odir=${RESULTSDIR}/${test}-`date +%s`
+ mkdir ${odir}
+ mkdir ${odir}/attachments/
+
+ touch ${odir}/stdout.log
+
+ cp ${line}/testdef.yaml ${odir}/
+ cp ${line}/testdef_metadata ${odir}/
+ cp ${line}/uuid ${odir}/analyzer_assigned_uuid
+
+ cp ${line}/run.sh ${odir}/attachments/
+ echo 'text/plain' > ${odir}/attachments/run.sh.mimetype
+ if [ -f ${line}/install.sh ]; then
+ cp ${line}/install.sh ${odir}/attachments/
+ echo 'text/plain' > ${odir}/attachments/install.sh.mimetype
+ echo "${PREFIX} running ${test} installer ..."
+ /system/bin/sh ${line}/install.sh
+ R=$?
+ echo ${R} > ${odir}/install_return_code
+ if [ ${R} -ne 0 ] ; then
+ echo "${PREFIX} ${test} installer failed, skippig"
+ hwcontext ${odir}
+ swcontext ${odir}
+ continue
+ fi
+ fi
+
+ echo "${PREFIX} save hardware/software context info..."
+ hwcontext ${odir}
+ swcontext ${odir}
+
+ lava-test-shell --output_dir ${odir} /system/bin/sh -e "${line}/run.sh"
+ echo "${PREFIX} ${test} exited with: `cat ${odir}/return_code`"
+ done
+}
+
diff --git a/lava_test_shell/distro/centos/lava-install-packages b/lava_test_shell/distro/centos/lava-install-packages
new file mode 100644
index 0000000..57fdfce
--- /dev/null
+++ b/lava_test_shell/distro/centos/lava-install-packages
@@ -0,0 +1,17 @@
+#!/bin/sh
+retry=0
+max_retry=4
+
+while [ 1 ]
+do
+ yum -e 0 -y -q install "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/distro/centos/lava-installed-packages b/lava_test_shell/distro/centos/lava-installed-packages
new file mode 100644
index 0000000..40556ad
--- /dev/null
+++ b/lava_test_shell/distro/centos/lava-installed-packages
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rpm -qa --qf "package: %{NAME} : %{VERSION}-%{RELEASE} \n"
diff --git a/lava_test_shell/distro/centos/lava-os-build b/lava_test_shell/distro/centos/lava-os-build
new file mode 100644
index 0000000..635723d
--- /dev/null
+++ b/lava_test_shell/distro/centos/lava-os-build
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+if [ -x /usr/bin/lsb_release ]
+then
+ /usr/bin/lsb_release -d | sed -e 's/^Description:\s*//'
+ exit 0
+fi
+
+if [ -f /etc/redhat-release ]
+then
+ head -n 1 /etc/redhat-release
+ exit 0
+fi
+
+if [ -f /etc/fedora-release ]
+then
+ head -n 1 /etc/centos-release
+ exit 0
+fi
+
+if [ -f /etc/system-release ]
+then
+ head -n 1 /etc/system-release
+ exit 0
+fi
+
+if [ -f /etc/os-release ]
+then
+ . /etc/os-release
+ echo ${PRETTY_NAME}
+ exit 0
+fi
diff --git a/lava_test_shell/distro/debian/lava-add-keys b/lava_test_shell/distro/debian/lava-add-keys
new file mode 100644
index 0000000..4885126
--- /dev/null
+++ b/lava_test_shell/distro/debian/lava-add-keys
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if gpg --keyserver pgp.mit.edu --recv-keys "$@" >/dev/null; then
+ gpg --armor --export "$@" | sudo apt-key add -
+ exit 0
+else
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ exit 0
+fi
diff --git a/lava_test_shell/distro/debian/lava-add-sources b/lava_test_shell/distro/debian/lava-add-sources
new file mode 100644
index 0000000..9ad0a77
--- /dev/null
+++ b/lava_test_shell/distro/debian/lava-add-sources
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+which add-apt-repository >/dev/null
+ret=$?
+if [ $ret -ne 0 ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "software-properties-common"
+fi
+
+DEBIAN_FRONTEND=noninteractive add-apt-repository -y "$@"
+# Ideally we should run 'apt-get update' after adding a new source, but this
+# is redundant here, since 'lava-install-packages' script which will follow
+# this will once again run 'apt-get update', which is going to waste time.
+#
+# CAUTION: When a new source is added and there are no 'deps' in the 'install'
+# of 'lava-test-shell' YAML test definition file, then it is the users
+# responsibility to run 'apt-get update' before attempting an
+# 'apt-get *' operation, elsewhere in the test definition.
+
+exit 0
diff --git a/lava_test_shell/distro/debian/lava-install-packages b/lava_test_shell/distro/debian/lava-install-packages
new file mode 100644
index 0000000..16eb562
--- /dev/null
+++ b/lava_test_shell/distro/debian/lava-install-packages
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+retry=0
+max_retry=4
+
+while [ 1 ]
+do
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/distro/debian/lava-installed-packages b/lava_test_shell/distro/debian/lava-installed-packages
new file mode 100644
index 0000000..125c316
--- /dev/null
+++ b/lava_test_shell/distro/debian/lava-installed-packages
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+dpkg-query -W -f '${status} ${package} : ${version}\n' | sed -n 's/^install ok installed/package:/p'
diff --git a/lava_test_shell/distro/debian/lava-os-build b/lava_test_shell/distro/debian/lava-os-build
new file mode 100644
index 0000000..e19bda5
--- /dev/null
+++ b/lava_test_shell/distro/debian/lava-os-build
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -x /usr/bin/lsb_release ]
+then
+ /usr/bin/lsb_release -d | sed -e 's/^Description:\s*//'
+ exit 0
+fi
+
+if [ -f /etc/lsb-release ]
+then
+ . /etc/lsb-release
+ echo $DISTRIB_DESCRIPTION
+ exit 0
+fi
+
+if [ -f /etc/debian_version ]
+then
+ cat /etc/debian_version
+ exit 0
+fi
diff --git a/lava_test_shell/distro/fedora/lava-install-packages b/lava_test_shell/distro/fedora/lava-install-packages
new file mode 100644
index 0000000..57fdfce
--- /dev/null
+++ b/lava_test_shell/distro/fedora/lava-install-packages
@@ -0,0 +1,17 @@
+#!/bin/sh
+retry=0
+max_retry=4
+
+while [ 1 ]
+do
+ yum -e 0 -y -q install "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/distro/fedora/lava-installed-packages b/lava_test_shell/distro/fedora/lava-installed-packages
new file mode 100644
index 0000000..40556ad
--- /dev/null
+++ b/lava_test_shell/distro/fedora/lava-installed-packages
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+rpm -qa --qf "package: %{NAME} : %{VERSION}-%{RELEASE} \n"
diff --git a/lava_test_shell/distro/fedora/lava-os-build b/lava_test_shell/distro/fedora/lava-os-build
new file mode 100644
index 0000000..30d4648
--- /dev/null
+++ b/lava_test_shell/distro/fedora/lava-os-build
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+if [ -x /usr/bin/lsb_release ]
+then
+ /usr/bin/lsb_release -d | sed -e 's/^Description:\s*//'
+ exit 0
+fi
+
+if [ -f /etc/redhat-release ]
+then
+ head -n 1 /etc/redhat-release
+ exit 0
+fi
+
+if [ -f /etc/fedora-release ]
+then
+ head -n 1 /etc/fedora-release
+ exit 0
+fi
+
+if [ -f /etc/system-release ]
+then
+ head -n 1 /etc/system-release
+ exit 0
+fi
+
+if [ -f /etc/os-release ]
+then
+ . /etc/os-release
+ echo ${PRETTY_NAME}
+ exit 0
+fi
diff --git a/lava_test_shell/distro/oe/lava-install-packages b/lava_test_shell/distro/oe/lava-install-packages
new file mode 100644
index 0000000..626cdc8
--- /dev/null
+++ b/lava_test_shell/distro/oe/lava-install-packages
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+#set proxy in /etc/opkg/opkg.conf if required
+unset http_proxy
+
+retry=0
+max_retry=4
+
+which opkg
+rc=$?
+
+if [ "$rc" != 0 ]; then
+ echo "Error: OPKG package manager not found in the path."
+ exit $rc
+fi
+
+while [ 1 ]
+do
+ opkg update
+ opkg install "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/distro/oe/lava-installed-packages b/lava_test_shell/distro/oe/lava-installed-packages
new file mode 100644
index 0000000..238374d
--- /dev/null
+++ b/lava_test_shell/distro/oe/lava-installed-packages
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+which opkg
+rc=$?
+
+if [ "$rc" != 0 ]; then
+ echo "Error: OPKG package manager not found, cannot obtain list of installed packages."
+ exit $rc
+fi
+
+opkg list-installed | sed -n 's/^/package: /p' | sed -n 's/ - / : /p'
diff --git a/lava_test_shell/distro/ubuntu/lava-add-keys b/lava_test_shell/distro/ubuntu/lava-add-keys
new file mode 100644
index 0000000..4885126
--- /dev/null
+++ b/lava_test_shell/distro/ubuntu/lava-add-keys
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if gpg --keyserver pgp.mit.edu --recv-keys "$@" >/dev/null; then
+ gpg --armor --export "$@" | sudo apt-key add -
+ exit 0
+else
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ exit 0
+fi
diff --git a/lava_test_shell/distro/ubuntu/lava-add-sources b/lava_test_shell/distro/ubuntu/lava-add-sources
new file mode 100644
index 0000000..9ad0a77
--- /dev/null
+++ b/lava_test_shell/distro/ubuntu/lava-add-sources
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+which add-apt-repository >/dev/null
+ret=$?
+if [ $ret -ne 0 ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "software-properties-common"
+fi
+
+DEBIAN_FRONTEND=noninteractive add-apt-repository -y "$@"
+# Ideally we should run 'apt-get update' after adding a new source, but this
+# is redundant here, since 'lava-install-packages' script which will follow
+# this will once again run 'apt-get update', which is going to waste time.
+#
+# CAUTION: When a new source is added and there are no 'deps' in the 'install'
+# of 'lava-test-shell' YAML test definition file, then it is the users
+# responsibility to run 'apt-get update' before attempting an
+# 'apt-get *' operation, elsewhere in the test definition.
+
+exit 0
diff --git a/lava_test_shell/distro/ubuntu/lava-install-packages b/lava_test_shell/distro/ubuntu/lava-install-packages
new file mode 100644
index 0000000..16eb562
--- /dev/null
+++ b/lava_test_shell/distro/ubuntu/lava-install-packages
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+retry=0
+max_retry=4
+
+while [ 1 ]
+do
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/distro/ubuntu/lava-installed-packages b/lava_test_shell/distro/ubuntu/lava-installed-packages
new file mode 100644
index 0000000..125c316
--- /dev/null
+++ b/lava_test_shell/distro/ubuntu/lava-installed-packages
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+dpkg-query -W -f '${status} ${package} : ${version}\n' | sed -n 's/^install ok installed/package:/p'
diff --git a/lava_test_shell/distro/ubuntu/lava-os-build b/lava_test_shell/distro/ubuntu/lava-os-build
new file mode 100644
index 0000000..e19bda5
--- /dev/null
+++ b/lava_test_shell/distro/ubuntu/lava-os-build
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -x /usr/bin/lsb_release ]
+then
+ /usr/bin/lsb_release -d | sed -e 's/^Description:\s*//'
+ exit 0
+fi
+
+if [ -f /etc/lsb-release ]
+then
+ . /etc/lsb-release
+ echo $DISTRIB_DESCRIPTION
+ exit 0
+fi
+
+if [ -f /etc/debian_version ]
+then
+ cat /etc/debian_version
+ exit 0
+fi
diff --git a/lava_test_shell/lava-add-keys b/lava_test_shell/lava-add-keys
new file mode 100755
index 0000000..4885126
--- /dev/null
+++ b/lava_test_shell/lava-add-keys
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if gpg --keyserver pgp.mit.edu --recv-keys "$@" >/dev/null; then
+ gpg --armor --export "$@" | sudo apt-key add -
+ exit 0
+else
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ exit 0
+fi
diff --git a/lava_test_shell/lava-add-sources b/lava_test_shell/lava-add-sources
new file mode 100755
index 0000000..9ad0a77
--- /dev/null
+++ b/lava_test_shell/lava-add-sources
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+which add-apt-repository >/dev/null
+ret=$?
+if [ $ret -ne 0 ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "software-properties-common"
+fi
+
+DEBIAN_FRONTEND=noninteractive add-apt-repository -y "$@"
+# Ideally we should run 'apt-get update' after adding a new source, but this
+# is redundant here, since 'lava-install-packages' script which will follow
+# this will once again run 'apt-get update', which is going to waste time.
+#
+# CAUTION: When a new source is added and there are no 'deps' in the 'install'
+# of 'lava-test-shell' YAML test definition file, then it is the users
+# responsibility to run 'apt-get update' before attempting an
+# 'apt-get *' operation, elsewhere in the test definition.
+
+exit 0
diff --git a/lava_test_shell/lava-background-process-start b/lava_test_shell/lava-background-process-start
new file mode 100755
index 0000000..fa6340b
--- /dev/null
+++ b/lava_test_shell/lava-background-process-start
@@ -0,0 +1,45 @@
+usage () {
+ echo "Usage: lava-background-process-start NAME --cmd PROCESS"
+ echo ""
+ echo "Start PROCESS in background."
+ echo "NAME is used to identify the process in the lava-background-process-stop"
+}
+
+NAME="$1"
+shift
+if [ -z "$NAME" ]; then
+ usage
+ exit 1
+fi
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ --cmd)
+ shift
+ PROCESS="$*"
+ shift
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+result_dir="$LAVA_RESULT_DIR/results/$NAME"
+mkdir -p "$result_dir"
+
+cat <<EOF > $result_dir/bg_run.sh
+set -e
+trap "exit" SIGHUP SIGINT SIGTERM
+while true; do
+ $PROCESS &
+ sleep 1
+done
+EOF
+
+/bin/bash $result_dir/bg_run.sh &
+echo $! > $result_dir/pid
+
+exit 0
diff --git a/lava_test_shell/lava-background-process-stop b/lava_test_shell/lava-background-process-stop
new file mode 100755
index 0000000..1ff4559
--- /dev/null
+++ b/lava_test_shell/lava-background-process-stop
@@ -0,0 +1,52 @@
+usage () {
+ echo "Usage: lava-background-process-stop NAME [--attach file mime]"
+ echo ""
+ echo "Stop background process NAME."
+ echo ""
+ echo "--attach file mime If specified, the 'file' will be attached"
+ echo " to the test run with corresponding mime type."
+ echo " Can be specified multiple times."
+}
+
+NAME="$1"
+shift
+if [ -z "$NAME" ]; then
+ usage
+ exit 1
+fi
+
+i=0
+while [ $# -gt 0 ]; do
+ case $1 in
+ --attach)
+ shift
+ ATTACH[i]="$1"
+ MIME[i]="$2"
+ i=$((i + 1))
+ shift
+ shift
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+result_dir="$LAVA_RESULT_DIR/results/$NAME"
+
+PID=`cat $result_dir/pid`
+
+if ps -p $PID > /dev/null;
+then
+ kill $PID 2>&1 > /dev/null\n
+fi
+
+while [ $i -gt 0 ]
+do
+ i=$(( $i - 1 ))
+ lava-test-run-attach ${ATTACH[i]} ${MIME[i]}
+done
+
+exit 0
diff --git a/lava_test_shell/lava-echo-ipv4 b/lava_test_shell/lava-echo-ipv4
new file mode 100755
index 0000000..2f5a39d
--- /dev/null
+++ b/lava_test_shell/lava-echo-ipv4
@@ -0,0 +1,20 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+usage () {
+ echo "Usage: lava-echo-ipv4 INTERFACE"
+ echo ""
+ echo "Runs ifconfig for the specified interface and outputs the ipv4 IP address, if any."
+}
+
+_NETWORK_INTERFACE=$1
+
+if [ -z "$_NETWORK_INTERFACE" ]; then
+ echo "Specify the interface to query"
+ exit
+fi
+
+if [ -x /sbin/ifconfig ]; then
+ _RAW_STREAM_V4=`/sbin/ifconfig $_NETWORK_INTERFACE |grep -o -E '([[:xdigit:]]{1,3}\.){3}[[:xdigit:]]{1,3}'`
+ echo $_RAW_STREAM_V4 | awk '{print$1}'
+fi
diff --git a/lava_test_shell/lava-install-packages b/lava_test_shell/lava-install-packages
new file mode 100755
index 0000000..16eb562
--- /dev/null
+++ b/lava_test_shell/lava-install-packages
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+retry=0
+max_retry=4
+
+while [ 1 ]
+do
+ DEBIAN_FRONTEND=noninteractive apt-get update -q
+ DEBIAN_FRONTEND=noninteractive apt-get install -y -q "$@"
+ return_value=$?
+ [ "$return_value" = 0 ] && break
+ [ "$retry" = "$max_retry" ] && exit $return_value
+
+ echo "================================================="
+ echo "($retry) Install failed... Retrying after some seconds"
+ echo "================================================="
+ sleep 60
+ retry=$((retry+1))
+done
diff --git a/lava_test_shell/lava-installed-packages b/lava_test_shell/lava-installed-packages
new file mode 100755
index 0000000..125c316
--- /dev/null
+++ b/lava_test_shell/lava-installed-packages
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+dpkg-query -W -f '${status} ${package} : ${version}\n' | sed -n 's/^install ok installed/package:/p'
diff --git a/lava_test_shell/lava-os-build b/lava_test_shell/lava-os-build
new file mode 100755
index 0000000..e19bda5
--- /dev/null
+++ b/lava_test_shell/lava-os-build
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if [ -x /usr/bin/lsb_release ]
+then
+ /usr/bin/lsb_release -d | sed -e 's/^Description:\s*//'
+ exit 0
+fi
+
+if [ -f /etc/lsb-release ]
+then
+ . /etc/lsb-release
+ echo $DISTRIB_DESCRIPTION
+ exit 0
+fi
+
+if [ -f /etc/debian_version ]
+then
+ cat /etc/debian_version
+ exit 0
+fi
diff --git a/lava_test_shell/lava-test-case b/lava_test_shell/lava-test-case
new file mode 100755
index 0000000..8405c37
--- /dev/null
+++ b/lava_test_shell/lava-test-case
@@ -0,0 +1,88 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+usage () {
+ echo "Usage: lava-test-case TEST_CASE_ID --shell cmds ..."
+ echo " or: lava-test-case TEST_CASE_ID --result RESULT [--units UNITS] "
+ echo " [--measurement MEASUREMENT]"
+ echo ""
+ echo "Either run or record the results of a particular test case"
+}
+
+rc=0
+
+TEST_CASE_ID="$1"
+shift
+if [ -z "$TEST_CASE_ID" ]; then
+ usage
+ exit 1
+fi
+if [ "$1" = "--shell" ]; then
+ shift
+ echo "<LAVA_SIGNAL_STARTTC $TEST_CASE_ID>"
+ eval "$*"
+ rc=$?
+ echo "<LAVA_SIGNAL_ENDTC $TEST_CASE_ID>"
+ if [ $rc -eq 0 ]; then
+ RESULT=pass
+ else
+ RESULT=fail
+ fi
+else
+ while [ $# -gt 0 ]; do
+ case $1 in
+ --result)
+ shift
+ RESULT=$1
+ shift
+ ;;
+ --units)
+ shift
+ UNITS=$1
+ shift
+ ;;
+ --measurement)
+ shift
+ MEASUREMENT=$1
+ shift
+ ;;
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+ done
+fi
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+result_dir="$LAVA_RESULT_DIR/results/$TEST_CASE_ID"
+mkdir -p "$result_dir"
+
+# signal the test case results
+TCDATA=""
+
+if [ -z "${RESULT+x}" ]; then
+ echo "--result must be specified"
+ exit 1
+else
+ echo $RESULT > "$result_dir/result"
+ TCDATA="$TCDATA RESULT=$RESULT"
+fi
+
+if [ -n "${UNITS+x}" ]; then
+ echo $UNITS > "$result_dir/units"
+ TCDATA="$TCDATA UNITS=$UNITS"
+fi
+
+if [ -n "${MEASUREMENT+x}" ]; then
+ echo $MEASUREMENT > "$result_dir/measurement"
+ TCDATA="$TCDATA MEASUREMENT=$MEASUREMENT"
+fi
+
+# signal the test case results
+echo "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=$TEST_CASE_ID$TCDATA>"
+
+# lava-test-case testname --shell false should report a fail as test result
+# but not fail itself; hence don't honor 'rc' if we reach this, but exit 0
+exit 0
+
diff --git a/lava_test_shell/lava-test-case-attach b/lava_test_shell/lava-test-case-attach
new file mode 100755
index 0000000..5e3ef4d
--- /dev/null
+++ b/lava_test_shell/lava-test-case-attach
@@ -0,0 +1,51 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+# basename is not present on AOSP builds, but the /*\// thing does not
+# work with dash (Ubuntu builds) or busybox (OpenEmbedded). Both of
+# those have basename though.
+type basename > /dev/null || basename () { echo ${1/*\//}; }
+type dirname > /dev/null || dirname () { dn=${1%\/*}; bn=$(basename $1); [ "${dn}" = "${bn}" ] && echo "." || echo $dn; }
+
+usage () {
+ echo "Usage: lava-test-case-attach TEST_CASE_ID FILE [MIME_TYPE]"
+ echo ""
+ echo "Attach FILE to the test case TEST_CASE_ID."
+}
+
+if [ $# -ne 2 -a $# -ne 3 ]; then
+ usage
+ exit 1
+fi
+
+TEST_CASE_ID="$1"
+shift
+FILE="$1"
+shift
+MIMETYPE="$1"
+
+if [ -z "$FILE" ]; then
+ usage
+ exit 1
+fi
+if [ ! -f "$FILE" ]; then
+ echo "File $FILE not found"
+ exit 1
+fi
+if [ -z "$TEST_CASE_ID" ]; then
+ usage
+ exit 1
+fi
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+case_attachment_dir="$LAVA_RESULT_DIR/results/$TEST_CASE_ID/attachments/$(dirname $FILE)"
+mkdir -p "$case_attachment_dir"
+SIZE=`stat --format="%s" $FILE`
+if [ $SIZE -gt 26214400 ]; then
+ echo "$FILE is too large, skipping"
+else
+ cp "$FILE" "$case_attachment_dir"
+ if [ ! -z "$MIMETYPE" ]; then
+ echo "$MIMETYPE" > "$case_attachment_dir/$(basename $FILE).mimetype"
+ fi
+fi
diff --git a/lava_test_shell/lava-test-case-metadata b/lava_test_shell/lava-test-case-metadata
new file mode 100755
index 0000000..84d984d
--- /dev/null
+++ b/lava_test_shell/lava-test-case-metadata
@@ -0,0 +1,25 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+usage () {
+ echo "Usage: lava-test-case-metadata METADATA_NAME --shell cmds ..."
+ echo ""
+ echo "Run the command specified and capture the metadata "
+}
+
+METADATA_NAME="$1"
+shift
+if [ -z "$METADATA_NAME" ]; then
+ usage
+ exit 1
+fi
+if [ "$1" = "--shell" ]; then
+ shift
+ echo "<LAVA_SIGNAL_START_METADATA_CAPTURE $METADATA_NAME>"
+ read
+ echo $METADATA_NAME: \"`$*`\" >> $LAVA_RESULT_DIR/extra_metadata
+ echo "<LAVA_SIGNAL_END_METADATA_CAPTURE $METADATA_NAME>"
+ read
+fi
+
+exit 0
diff --git a/lava_test_shell/lava-test-run-attach b/lava_test_shell/lava-test-run-attach
new file mode 100755
index 0000000..d6c3f98
--- /dev/null
+++ b/lava_test_shell/lava-test-run-attach
@@ -0,0 +1,40 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+# basename is not present on AOSP builds, but the /*\// thing does not
+# work with dash (Ubuntu builds) or busybox (OpenEmbedded). Both of
+# those have basename though.
+type basename > /dev/null || basename () { echo ${1/*\//}; }
+type dirname > /dev/null || dirname () { dn=${1%\/*}; bn=$(basename $1); [ "${dn}" = "${bn}" ] && echo "." || echo $dn; }
+
+usage () {
+ echo "Usage: lava-test-run-attach FILE [MIME_TYPE]"
+ echo ""
+ echo "Attach FILE to the current test run."
+}
+
+if [ $# -ne 1 -a $# -ne 2 ]; then
+ usage
+ exit 1
+fi
+
+FILE="$1"
+shift
+MIMETYPE="$1"
+
+if [ -z "$FILE" ]; then
+ usage
+ exit 1
+fi
+if [ ! -f "$FILE" ]; then
+ echo "File $FILE not found"
+ exit 1
+fi
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+attachment_dir="$LAVA_RESULT_DIR/attachments/$(dirname $FILE)"
+mkdir -p "$attachment_dir"
+cp "$FILE" "$attachment_dir"
+if [ ! -z "$MIMETYPE" ]; then
+ echo "$MIMETYPE" > "$attachment_dir/$(basename $FILE).mimetype"
+fi
diff --git a/lava_test_shell/lava-test-runner b/lava_test_shell/lava-test-runner
new file mode 100755
index 0000000..bca3036
--- /dev/null
+++ b/lava_test_shell/lava-test-runner
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+if [ "$1" = "" ]
+then
+ LAVA_PATH="/lava"
+else
+ LAVA_PATH=$1
+fi
+
+echo $LAVA_PATH
+PREFIX="<LAVA_TEST_RUNNER>:"
+WORKFILE="$LAVA_PATH/lava-test-runner.conf"
+RESULTSDIR="$LAVA_PATH/results"
+BINDIR="$LAVA_PATH/bin"
+
+hwcontext()
+{
+ ODIR=$1
+ mkdir -p ${ODIR}/hwcontext
+ cpuinfo=${ODIR}/hwcontext/cpuinfo.txt
+ meminfo=${ODIR}/hwcontext/meminfo.txt
+
+ [ -f ${cpuinfo} ] || cat /proc/cpuinfo > ${cpuinfo}
+ [ -f ${meminfo} ] || cat /proc/meminfo > ${meminfo}
+}
+
+swcontext()
+{
+ ODIR=$1
+ mkdir -p ${ODIR}/swcontext
+ build=${ODIR}/swcontext/build.txt
+ pkgs=${ODIR}/swcontext/pkgs.txt
+
+ lava-os-build > ${build}
+
+ # this has to print a list of installed packages that will look similar to
+ # what android's package list does
+ lava-installed-packages > ${pkgs}
+}
+
+cleanup()
+{
+ # just adds a little handy debugging
+ ls ${RESULTSDIR}
+ echo "${PREFIX} calling sync on device"
+ sync
+ echo "${PREFIX} exiting lava-test-runner"
+}
+trap cleanup INT TERM EXIT
+
+export PATH=${BINDIR}:${PATH}
+echo "${PREFIX} started"
+mkdir -p ${RESULTSDIR}
+
+# move the workfile to something timestamped and run that. This
+# prevents us from running the same thing again after a reboot
+TS=`date +%s`
+mv ${WORKFILE} ${WORKFILE}-${TS}
+WORKFILE=${WORKFILE}-${TS}
+
+echo "${PREFIX} looking for work in ${WORKFILE}"
+for line in $(cat ${WORKFILE}); do
+ test=`basename $line`
+ echo "${PREFIX} running ${test} under lava-test-shell..."
+ odir=${RESULTSDIR}/${test}-`date +%s`
+ mkdir ${odir}
+ mkdir ${odir}/attachments/
+ touch ${odir}/stdout.log
+ mkdir ${odir}/attributes/
+ cp ${line}/uuid ${odir}/analyzer_assigned_uuid
+ cp ${line}/testdef.yaml ${odir}/
+ cp ${line}/testdef_metadata ${odir}/
+
+ cp ${line}/run.sh ${odir}/attachments/
+ echo 'text/plain' > ${odir}/attachments/run.sh.mimetype
+ if [ -f ${line}/install.sh ]; then
+ cp ${line}/install.sh ${odir}/attachments/
+ echo 'text/plain' > ${odir}/attachments/install.sh.mimetype
+ echo "${PREFIX} running ${test} installer ..."
+ /bin/sh ${line}/install.sh
+ R=$?
+ echo ${R} > ${odir}/install_return_code
+ if [ ${R} -ne 0 ] ; then
+ echo "${PREFIX} ${test} installer failed, skipping"
+ hwcontext ${odir}
+ swcontext ${odir}
+ continue
+ fi
+ fi
+
+ echo "${PREFIX} save hardware/software context info for ${test}..."
+ hwcontext ${odir}
+ swcontext ${odir}
+
+ # run.sh includes a "read -t <timeout>" which isn't supported by dash
+ # so be sure to use bash (ash also works).
+
+ shell="none"
+ if [ -f /bin/bash ]; then
+ shell="/bin/bash"
+ else
+ if [ -f /bin/ash ]; then
+ shell="/bin/ash"
+ fi
+ fi
+
+ if [ $shell = "none" ]; then
+ echo "-----------------------------------------------"
+ echo "ERROR: Unable to find a usable shell. Aborting."
+ echo "-----------------------------------------------"
+ exit 1
+ fi
+
+ lava-test-shell --output_dir ${odir} ${shell} -e "${line}/run.sh"
+ echo "${PREFIX} ${test} exited with: `cat ${odir}/return_code`"
+done
+
diff --git a/lava_test_shell/lava-test-set b/lava_test_shell/lava-test-set
new file mode 100755
index 0000000..5088858
--- /dev/null
+++ b/lava_test_shell/lava-test-set
@@ -0,0 +1,33 @@
+set_usage () {
+ echo "Usage:"
+ echo " lava-test-set start NAME"
+ echo " lava-test-set stop"
+ echo ""
+ echo "Start a test set with the given NAME, or stop the test set section."
+}
+
+set_start () {
+ echo "<LAVA_SIGNAL_TESTSET START $1>"
+ exit 0
+}
+
+set_stop () {
+ echo "<LAVA_SIGNAL_TESTSET STOP>"
+ exit 0
+}
+
+COMMAND="$1"
+shift
+if [ "$COMMAND" = "start" ]; then
+ SETNAME="$1"
+ if [ -z "$SETNAME" ]; then
+ set_usage
+ exit 1
+ fi
+ set_start "$SETNAME"
+elif [ "$COMMAND" = "stop" ]; then
+ set_stop
+else
+ set_usage
+ exit 1
+fi
diff --git a/lava_test_shell/lava-test-shell b/lava_test_shell/lava-test-shell
new file mode 100755
index 0000000..03ac76b
--- /dev/null
+++ b/lava_test_shell/lava-test-shell
@@ -0,0 +1,15 @@
+#NOTE the lava_test_shell_action fills in the proper interpreter path
+# above during target deployment
+
+shift
+ODIR=$1
+shift
+TEST=$*
+export LAVA_RESULT_DIR=${ODIR}
+{
+ $TEST
+ echo $? > ${ODIR}/return_code
+} 2>&1 | while read line; do
+ echo "$line"
+ echo "$line" >> ${ODIR}/stdout.log
+done
diff --git a/lava_test_shell/lava-vm-groups-setup-host b/lava_test_shell/lava-vm-groups-setup-host
new file mode 100755
index 0000000..9beda3b
--- /dev/null
+++ b/lava_test_shell/lava-vm-groups-setup-host
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+lava-install-packages openssh-server
+
+if grep -q 'lava insecure public key' /root/.ssh/authorized_keys; then
+ exit 0
+fi
+
+cat >> /root/.ssh/authorized_keys <<EOF
+ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLsQXteu02Mvs8Srs8TI/XJqTnfoNDjT5zJVQNI6BqUvvaHSna0iZpcPln9lbmRwAkf84rZAP3eAn051l+GYcRAVAH3bu9HDA8XXIbA4EkCZJ9aCPX7jqtSTBLaIUH28JRPhvP6iZWvqSQck4OmoyrBaMJByBm5CaPR4IhpcAyORF88AGmRW/qFIZTxNm/z1JN/WO+4+C/uM07T+KuInAPBQCTY9pYk4Vd2tZ4msWMYuWs3uVKRdN8aTgyqeyOE3zmXN8Tr2r5uFU0SAe1ZmVnex3s9ZF4YhgmX9SUBuxQw/FjNUajx2D18x/+RQuWXxZOpPQ5ecAysDKROTFWl6QB lava insecure public key
+EOF
diff --git a/lava_test_shell/lmp/lava-lmp-audio-jack b/lava_test_shell/lmp/lava-lmp-audio-jack
new file mode 100644
index 0000000..75ab5e9
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-audio-jack
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp lsgpio module. This allows you to passthrough ro
+# disconnect the audio jack.
+#
+# Usage: ``lava-lmp-audio-jack {passthru, disconnect, id_on, id_off, reset} [module_name]``
+LAVA_LMP_API="LAVA_LSGPIO"
+LAVA_LMP_COMMAND_SET="passthru disconnect id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+lava_lmp_simple_send $1 $2
+
diff --git a/lava_test_shell/lmp/lava-lmp-eth b/lava_test_shell/lmp/lava-lmp-eth
new file mode 100644
index 0000000..edfd8b5
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-eth
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp ETH-SATA module. This allows you to passthrough ro
+# disconnect.
+#
+# Usage: ``lava-lmp-eth {passthru, disconnect, id_on, id_off, reset} [module_name]``
+LAVA_LMP_API="LAVA_ETH"
+LAVA_LMP_COMMAND_SET="passthru disconnect id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+lava_lmp_simple_send $1 $2
+
diff --git a/lava_test_shell/lmp/lava-lmp-hdmi b/lava_test_shell/lmp/lava-lmp-hdmi
new file mode 100644
index 0000000..e35c4d8
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-hdmi
@@ -0,0 +1,36 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp hdmi module. This allows you to passthrough, disconnect
+# or fake edid. Fake edid takes an additional parameter of the edid schema to be
+# written to the lmp hdmi module.
+#
+# Usage: ``lava-lmp-hdmi {passthru, disconnect, id_on, id_off, reset} [module_name]``
+# ``lava-lmp-hdmi fakeedid <edid_file> [module_name]``
+LAVA_LMP_API="LAVA_HDMI"
+LAVA_LMP_COMMAND_SET="passthru disconnect id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+if [ "$1" = "fakeedid" ] ; then
+ if [ -f $2 ] ; then
+ #FIXME: any better idea for passing the fake edid?
+ _EDID_STREAM=`xxd -p -c 256 $2`
+ lava_lmp_send "fakeedid" $3 "$_EDID_STREAM"
+ lava_lmp_wait_for_message
+ else
+ echo "$LAVA_LMP_API : missing edid file $2"
+ exit $LAVA_LMP_EXIT_ERROR
+ fi
+else
+ lava_lmp_simple_send $1 $2
+fi
+
diff --git a/lava_test_shell/lmp/lava-lmp-lsgpio b/lava_test_shell/lmp/lava-lmp-lsgpio
new file mode 100644
index 0000000..92bab9f
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-lsgpio
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp lsgpio module. This allows you to change
+# the direction of the gpio set(a,b).
+#
+# Usage: ``lava-lmp-lsgpio {a_in a_out b_in b_out a_set_?? a_get b_set_?? b_get, id_on, id_off, reset} [module_name]``
+LAVA_LMP_API="LAVA_LSGPIO"
+LAVA_LMP_COMMAND_SET="a_in a_out b_in b_out a_set_ a_get b_set_ b_get id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+lava_lmp_simple_send $1 $2
+
diff --git a/lava_test_shell/lmp/lava-lmp-sata b/lava_test_shell/lmp/lava-lmp-sata
new file mode 100644
index 0000000..946d1f2
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-sata
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp ETH-SATA module. This allows you to passthrough ro
+# disconnect.
+#
+# Usage: ``lava-lmp-sata {passthru, disconnect, id_on, id_off, reset} [module_name]``
+LAVA_LMP_API="LAVA_SATA"
+LAVA_LMP_COMMAND_SET="passthru disconnect id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+lava_lmp_simple_send $1 $2
+
diff --git a/lava_test_shell/lmp/lava-lmp-usb b/lava_test_shell/lmp/lava-lmp-usb
new file mode 100644
index 0000000..0339aad
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp-usb
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+# Operates the Lava Lmp usb module. This allows you to make usb port as
+# device, host or disconnect.
+#
+# Usage: ``lava-lmp-usb {device, host, disconnect, id_on, id_off, reset} [module_name]``
+LAVA_LMP_API="LAVA_USB"
+LAVA_LMP_COMMAND_SET="device host disconnect id_ reset"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-lmp.lib
+
+lava_lmp_simple_send $1 $2
+
diff --git a/lava_test_shell/lmp/lava-lmp.lib b/lava_test_shell/lmp/lava-lmp.lib
new file mode 100644
index 0000000..78f57c1
--- /dev/null
+++ b/lava_test_shell/lmp/lava-lmp.lib
@@ -0,0 +1,159 @@
+#!/bin/sh
+#
+# Copyright (C) 2013 Linaro Limited
+#
+# Author: Dave Pigott <dave.pigott@linaro.org>
+# Fu Wei <fu.wei@linaro.org>
+#
+# This file is for lava lmp test
+#
+
+MESSAGE_PREFIX="<LAVA_LMP>"
+MESSAGE_COMMAND="<${LAVA_LMP_API}"
+MESSAGE_HEAD="$MESSAGE_PREFIX $MESSAGE_COMMAND"
+#MESSAGE_ID="<$1>"
+MESSAGE_ACK="<${LAVA_LMP_API}_ACK>"
+
+MESSAGE_REPLY="<${LAVA_LMP_API}_COMPLETE"
+MESSAGE_REPLY_ACK="<${LAVA_LMP_API}_COMPLETE_ACK>"
+
+LAVA_LMP_EXIT_ERROR=1
+
+_get_key_value_pattern () {
+ echo $@|\
+ tr ' ' '\n' |\
+ sed -n '/\b\w\w*[=]\w\w*\b/p'|\
+ tr '\n' ' '
+}
+
+_lava_lmp_debug () {
+ if [ -n "$LAVA_LMP_DEBUG" ] ; then
+ echo "${MESSAGE_COMMAND}_DEBUG $@ $(date)>"
+ fi
+}
+
+_lava_lmp_send () {
+ _lava_lmp_debug "$FUNCNAME started"
+
+ result=$(echo $1 | grep "..*=..*")
+
+ if [ -n "$1" -a "${result}x" = "x" ] ; then
+ echo ${MESSAGE_HEAD} $@">"
+ else
+ _lava_lmp_debug "$FUNCNAME error command : " "$result"
+ exit $LAVA_LMP_EXIT_ERROR
+ fi
+
+ _lava_lmp_debug "$FUNCNAME finished"
+}
+
+_lava_lmp_process_message () {
+ _lava_lmp_debug "$FUNCNAME save message to $LAVA_LMP_CACHE"
+#clean old cache file
+ rm $LAVA_LMP_CACHE 2>/dev/null
+
+ until [ -z "$1" ] ; do
+ result=$(echo $1 | grep "..*=..*")
+ if [ "${result}x" != "x" ] ; then
+ echo $1 >> $LAVA_LMP_CACHE
+ _lava_lmp_debug "$FUNCNAME save $1 to $LAVA_LMP_CACHE"
+ elif [ "${1}x" = "nackx" ] ; then
+ echo "Error:no-response $1, Exit from $LAVA_LMP_API!"
+ exit $LAVA_LMP_EXIT_ERROR
+ elif [ "${1}x" = "invalid_idx" ] ; then
+ echo "Error:invalid serial ID, Exit from $LAVA_LMP_API!"
+ exit $LAVA_LMP_EXIT_ERROR
+ else
+ echo "Warning:unrecognized message $1"
+ fi
+ shift
+ done
+}
+
+lava_lmp_send () {
+ _lava_lmp_debug "$FUNCNAME preparing"
+
+ _lava_lmp_send $@
+
+ while [ -n "$MESSAGE_NEED_ACK" -a "${SHELL}x" = "/bin/bashx" ] ; do
+ _lava_lmp_debug "$FUNCNAME waiting for ack"
+ read -t $MESSAGE_TIMEOUT line
+ result=$(echo $line | grep "${MESSAGE_ACK}")
+ if [ "${result}x" != "x" ] ; then
+# echo ${MESSAGE_ACK}
+ break
+ fi
+ _lava_lmp_send $@
+ done
+
+ _lava_lmp_debug "$FUNCNAME finished"
+}
+
+lava_lmp_wait_for_signal () {
+ _lava_lmp_debug "$FUNCNAME starting to wait"
+
+ while read line; do
+ result=$(echo $line | grep "${MESSAGE_REPLY}>")
+ if [ "${result}x" != "x" ] ; then
+ if [ -n "$MESSAGE_NEED_ACK" ] ; then
+ echo ${MESSAGE_REPLY_ACK}
+ fi
+ break
+ fi
+ done
+
+ _lava_lmp_debug "$FUNCNAME waiting over"
+}
+
+lava_lmp_wait_for_message () {
+ _lava_lmp_debug "$FUNCNAME starting to wait"
+
+ if [ -n "$1" ] ; then
+ export LAVA_LMP_CACHE=$1
+ fi
+
+ while read line; do
+ result=$(echo $line | grep "${MESSAGE_REPLY}")
+ if [ "${result}x" != "x" ] ; then
+ line=$(echo ${line}|sed -e "s/^${MESSAGE_REPLY}//"|sed -e 's/>$//')
+ _lava_lmp_process_message ${line}
+ if [ -n "$MESSAGE_NEED_ACK" ] ; then
+ echo ${MESSAGE_REPLY_ACK}
+ fi
+ break
+ fi
+ done
+
+ _lava_lmp_debug "$FUNCNAME waiting over"
+}
+
+lava_lmp_check_cache () {
+ if [ -n "$1" ] ; then
+ export LAVA_LMP_CACHE=$1
+ fi
+
+ if [ ! -f $LAVA_LMP_CACHE ] ; then
+ _lava_lmp_debug "$FUNCNAME not cache file $LAVA_LMP_CACHE !"
+ exit $LAVA_LMP_EXIT_ERROR
+ fi
+}
+
+lava_lmp_check_command () {
+ for command in $LAVA_LMP_COMMAND_SET ; do
+ result=$(echo ${1} | grep "${command}")
+ if [ "${result}x" != "x" ] ; then
+ return 0
+ fi
+ done
+
+ echo "$FUNCNAME : wrong command $1"
+ exit $LAVA_LMP_EXIT_ERROR
+}
+
+lava_lmp_simple_send () {
+ lava_lmp_check_command $1
+ lava_lmp_send $@
+ lava_lmp_wait_for_message
+}
+
+
diff --git a/lava_test_shell/multi_node/lava-echo-config b/lava_test_shell/multi_node/lava-echo-config
new file mode 100644
index 0000000..effac64
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-echo-config
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#This command will print to stdout any extra device information contained in
+# /etc/lava-server/shared-device-config.yaml
+#
+#Usage: ``lava-echo-config``
+#
+
+if [ -z "${LAVA_SHARED_CONFIG}" ]
+then
+ printf "no shared config\n"
+ exit 1
+fi
+
+FILTER=$1
+if [ -z "$FILTER" ]; then
+ printf "${LAVA_SHARED_CONFIG}\n"
+ exit 0
+fi
+
+MATCH=$(printf "${LAVA_SHARED_CONFIG}" | sed "/^${FILTER} /!D" | sed "s/^${FILTER} //")
+if [ "$MATCH" = "" ] || [ -z "$MATCH" ]; then
+ # failed to find the filter in the group
+ printf "no matching devices\n"
+ exit 1
+fi
+printf "${MATCH}"
+exit 0
diff --git a/lava_test_shell/multi_node/lava-group b/lava_test_shell/multi_node/lava-group
new file mode 100644
index 0000000..1dabc2a
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-group
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#This command will produce in its standard output a representation of the
+#device group that is participating in the multi-node test job.
+#
+#Usage: ``lava-group``
+#
+#The output format contains one line per device, and each line contains
+#the hostname and the role that device is playing in the test, separated
+#by a TAB character::
+#
+# panda01 client
+# highbank01 loadbalancer
+# highbank02 backend
+# highbank03 backend
+#
+#Usage: ``lava-group role``
+#
+#The output format contains one line per device assigned to the specified
+#role, with no whitespace. The matched role is not output.::
+#
+# panda01
+#
+#If there is no matching role, exit non-zero and output nothing.
+#
+
+FILTER=$1
+if [ -z "$FILTER" ]; then
+ printf ${LAVA_GROUP}
+ exit 0
+fi
+MATCH=$(printf ${LAVA_GROUP} | awk "/\t$FILTER$/" | sed -e "s/\t$FILTER$//")
+if [ "$MATCH" = "${LAVA_GROUP}" ] || [ -z "$MATCH" ]; then
+ # failed to find the filter in the group
+ exit 1
+fi
+printf "${MATCH}"
+exit 0
diff --git a/lava_test_shell/multi_node/lava-multi-node.lib b/lava_test_shell/multi_node/lava-multi-node.lib
new file mode 100644
index 0000000..2dd6700
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-multi-node.lib
@@ -0,0 +1,252 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+
+MESSAGE_PREFIX="<LAVA_MULTI_NODE>"
+MESSAGE_COMMAND="<${LAVA_MULTI_NODE_API}"
+MESSAGE_HEAD="$MESSAGE_PREFIX $MESSAGE_COMMAND"
+#MESSAGE_ID="<$1>"
+MESSAGE_ACK="<${LAVA_MULTI_NODE_API}_ACK>"
+
+MESSAGE_REPLY="<${LAVA_MULTI_NODE_API}_COMPLETE"
+MESSAGE_REPLY_ACK="<${LAVA_MULTI_NODE_API}_COMPLETE_ACK>"
+
+LAVA_MULTI_NODE_EXIT_ERROR=1
+
+_get_key_value_pattern () {
+ echo $@ | tr ' ' '\n' | grep "..*=..*" | tr '\n' ' '
+}
+
+_lava_multi_node_debug () {
+
+if [ -n "$LAVA_MULTI_NODE_DEBUG" ] ; then
+ echo "${MESSAGE_COMMAND}_DEBUG $@ $(date)>"
+fi
+
+}
+
+_lava_multi_node_send () {
+
+_lava_multi_node_debug "$FUNCNAME started"
+
+result=$(echo $1 | grep "..*=..*")
+
+if [ -n "$1" -a "${result}x" = "x" ] ; then
+ echo ${MESSAGE_HEAD} $@">"
+else
+ _lava_multi_node_debug "$FUNCNAME error messageID : " "$result"
+ exit $LAVA_MULTI_NODE_EXIT_ERROR
+fi
+
+_lava_multi_node_debug "$FUNCNAME finished"
+
+}
+
+_lava_multi_node_process_message () {
+
+_lava_multi_node_debug "$FUNCNAME save message to $LAVA_MULTI_NODE_CACHE"
+CACHE_DIR=$(dirname $LAVA_MULTI_NODE_CACHE)
+if [ ! -d $CACHE_DIR ]
+then
+ mkdir -p $CACHE_DIR
+fi
+#clean old cache file
+rm $LAVA_MULTI_NODE_CACHE 2>/dev/null
+
+for line in ${1} ; do
+ result=$(echo "${line}" | grep "..*=..*")
+ if [ "${result}x" != "x" ] ; then
+ echo $line >> $LAVA_MULTI_NODE_CACHE
+ elif [ "${line}x" = "nackx" ] ; then
+ echo "Error:no-response $1, Exit from $LAVA_MULTI_NODE_API!"
+ exit $LAVA_MULTI_NODE_EXIT_ERROR
+ else
+ echo "Warning:unrecognized message $line"
+ fi
+done
+}
+
+lava_multi_node_send () {
+
+_lava_multi_node_debug "$FUNCNAME preparing"
+
+_lava_multi_node_send $@
+
+while [ -n "$MESSAGE_NEED_ACK" -a "${SHELL}x" = "/bin/bashx" ] ; do
+_lava_multi_node_debug "$FUNCNAME waiting for ack"
+ read -t $MESSAGE_TIMEOUT line
+ result=$(echo $line | grep "${MESSAGE_ACK}")
+ if [ "${result}x" != "x" ] ; then
+# echo ${MESSAGE_ACK}
+ break
+ fi
+ _lava_multi_node_send $@
+done
+
+_lava_multi_node_debug "$FUNCNAME finished"
+
+}
+
+lava_multi_node_wait_for_signal () {
+
+_lava_multi_node_debug "$FUNCNAME starting to wait"
+
+while read line; do
+ result=$(echo $line | grep "${MESSAGE_REPLY}>")
+ if [ "${result}x" != "x" ] ; then
+ if [ -n "$MESSAGE_NEED_ACK" ] ; then
+ echo ${MESSAGE_REPLY_ACK}
+ fi
+ break
+ fi
+done
+
+_lava_multi_node_debug "$FUNCNAME waiting over"
+
+}
+
+lava_multi_node_wait_for_message () {
+
+_lava_multi_node_debug "$FUNCNAME starting to wait"
+
+if [ -n "$1" ] ; then
+ export LAVA_MULTI_NODE_CACHE=$1
+fi
+
+while read line; do
+ result=$(echo $line | grep "${MESSAGE_REPLY}")
+ if [ "${result}x" != "x" ] ; then
+ line=$(echo ${line}|sed -e "s/^${MESSAGE_REPLY}//"|sed -e 's/>$//')
+ _lava_multi_node_process_message "${line}"
+ if [ -n "$MESSAGE_NEED_ACK" ] ; then
+ echo ${MESSAGE_REPLY_ACK}
+ fi
+ break
+ fi
+done
+
+_lava_multi_node_debug "$FUNCNAME waiting over"
+
+}
+
+lava_multi_node_get_network_info () {
+
+_NETWORK_INTERFACE=$1
+_RAW_STREAM_V4=`ifconfig $_NETWORK_INTERFACE |grep -o -E '([[:xdigit:]]{1,3}\.){3}[[:xdigit:]]{1,3}'`
+_RAW_STREAM_V6=`ifconfig $_NETWORK_INTERFACE |grep "inet6 "`
+_RAW_STREAM_MAC=`ifconfig $_NETWORK_INTERFACE |grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
+
+_IPV4_STREAM_IP=`echo $_RAW_STREAM_V4 | awk '{print$1}'`
+
+_IFCONFIG_CHECK=`ifconfig $_NETWORK_INTERFACE | grep HWaddr`
+
+if [ "${_IFCONFIG_CHECK}x" != "x" ] ; then
+ _IPV4_STREAM_NM=`echo $_RAW_STREAM_V4 | awk '{print$3}'`
+ _IPV4_STREAM_BC=`echo $_RAW_STREAM_V4 | awk '{print$2}'`
+else
+ _IPV4_STREAM_NM=`echo $_RAW_STREAM_V4 | awk '{print$2}'`
+ _IPV4_STREAM_BC=`echo $_RAW_STREAM_V4 | awk '{print$3}'`
+fi
+
+_IPV4_STREAM="ipv4="$_IPV4_STREAM_IP" netmask="$_IPV4_STREAM_NM" \
+broadcast="$_IPV4_STREAM_BC
+
+_IPV6_STREAM_IP=`echo $_RAW_STREAM_V6 | grep -o -E '\s[[:xdigit:]]{0,4}:(:[[:xdigit:]]{0,4}){0,4}' | sed 's/ //'`
+_IPV6_STREAM="ipv6="$_IPV6_STREAM_IP
+
+_MAC_STREAM="mac="$_RAW_STREAM_MAC
+
+_HOSTNAME_STREAM="hostname="`hostname`
+
+_HOSTNAME_FULL_STREAM="hostname-full="`hostname -f`
+
+_DEF_GATEWAY_STREAM="default-gateway="`route -n |grep "UG "| cut -f10 -d" "`
+
+#get DNS configure
+_Counter=1
+for line in `cat /etc/resolv.conf | grep "nameserver"| cut -d " " -f 2` ; do
+ export _DNS_${_Counter}_STREAM=$line
+ _Counter=`expr ${_Counter} + 1`
+done
+_DNS_STREAM="dns_1=${_DNS_1_STREAM} dns_2=${_DNS_2_STREAM} \
+dns_3=${_DNS_3_STREAM}"
+
+_get_key_value_pattern $_IPV4_STREAM $_IPV6_STREAM $_MAC_STREAM \
+$_HOSTNAME_STREAM $_HOSTNAME_FULL_STREAM $_DEF_GATEWAY_STREAM $_DNS_STREAM
+
+}
+
+lava_multi_node_check_cache () {
+
+if [ -n "$1" ] ; then
+ export LAVA_MULTI_NODE_CACHE=$1
+fi
+
+if [ ! -f $LAVA_MULTI_NODE_CACHE ] ; then
+ _lava_multi_node_debug "$FUNCNAME no cache file exists $LAVA_MULTI_NODE_CACHE !"
+ exit $LAVA_MULTI_NODE_EXIT_ERROR
+fi
+
+}
+
+lava_multi_node_print_host_info () {
+
+_HOSTNAME=$1
+_INFO=$2
+_RAW_STREAM=`cat $LAVA_MULTI_NODE_NETWORK_CACHE |grep "$_HOSTNAME:$_INFO="`
+
+if [ -n "$_RAW_STREAM" ] ; then
+ echo $_RAW_STREAM|cut -d'=' -f2
+fi
+
+}
+
+lava_multi_node_make_hosts () {
+
+for line in `grep ":ipv4" $LAVA_MULTI_NODE_NETWORK_CACHE` ; do
+ _IP_STREAM=`echo $line | cut -d'=' -f2`
+ _TARGET_STREAM=`echo $line | cut -d':' -f1`
+ _HOSTNAME_STREAM=`grep "$_TARGET_STREAM:hostname=" \
+$LAVA_MULTI_NODE_NETWORK_CACHE | cut -d'=' -f2`
+ if [ -n "$_HOSTNAME_STREAM" ]; then
+ printf "$_IP_STREAM\t$_HOSTNAME_STREAM\n" >> $1
+ else
+ printf "$_IP_STREAM\t$_TARGET_STREAM\n" >> $1
+ fi
+done
+
+}
+
+lava_multi_node_make_aliased_hosts () {
+r=1
+SEEN_ROLES="."
+for DEVICE in `lava-group| awk '{ if ($1 == "^[a-z]\t"); print $1 }'`; do
+ # dump disallowed characters out of the device name, it's used as a variable.
+ DEV_NAME=`printf $DEVICE | sed -e 's/[^a-z0-9]//g'`
+ # dump disallowed characters out of the role, it's used as a variable.
+ ROLE_NAME=`lava-group | grep ${DEVICE} | cut -f3 | sed -e 's/[^a-z0-9]//g'`
+ ROLE_SUFFIX=$ROLE_NAME`printf "%02d" $r`
+ while [ -n "`printf "${SEEN_ROLES}" | grep ${ROLE_SUFFIX}`" ]; do
+ r=`expr $r + 1`
+ ROLE_SUFFIX=$ROLE_NAME`printf "%02d" $r`
+ done
+ SEEN_ROLES="${SEEN_ROLES} ${ROLE_SUFFIX}"
+ for DEVROLE in `lava-group | grep ${DEVICE} | cut -f3`; do
+ eval $DEVROLE`printf "%02d" $r`="${ROLE_SUFFIX}"
+ ROLE_NAME="$DEVROLE"`printf "%02d" $r`
+ done
+ line=`grep $DEVICE ${LAVA_MULTI_NODE_NETWORK_CACHE} | grep ":ipv4" `
+ _IP_STREAM=`printf $line | cut -d'=' -f2`
+ _TARGET_STREAM=`printf $line | cut -d':' -f1`
+ _HOSTNAME_STREAM=`grep "$_TARGET_STREAM:hostname=" ${LAVA_MULTI_NODE_NETWORK_CACHE} | cut -d'=' -f2`
+ ALIAS=`eval printf "%s" \\$${ROLE_NAME}`
+ if [ -n "$_IP_STREAM" ]; then
+ if [ -n "$_HOSTNAME_STREAM" ]; then
+ printf "$_IP_STREAM\t$_HOSTNAME_STREAM\t$ALIAS\n" >> $1
+ else
+ printf "$_IP_STREAM\t$_TARGET_STREAM\t$ALIAS\n" >> $1
+ fi
+ fi
+done
+}
diff --git a/lava_test_shell/multi_node/lava-network b/lava_test_shell/multi_node/lava-network
new file mode 100644
index 0000000..0f67290
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-network
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#lava-network
+#-----------------
+#Helper script to broadcast IP data from the test image, wait for data
+#to be received by the rest of the group (or one role within the group)
+#and then provide an interface to retrieve IP data about the group on
+#the command line.
+#
+#Raising a suitable network interface is a job left for the designer of
+#the test definition / image but once a network interface is available,
+#lava-network can be asked to broadcast this information to the rest of
+#the group. At a later stage of the test, before the IP details of the
+#group need to be used, call lava-network collect to receive the same
+#information about the rest of the group.
+#
+#All usage of lava-network needs to use a broadcast (which wraps a call
+#to lava-send) and a collect (which wraps a call to lava-wait-all). As
+#a wrapper around lava-wait-all, collect will block until the rest of
+#the group (or devices in the group with the specified role) has made a
+#broadcast.
+#
+#After the data has been collected, it can be queried for any board
+#specified in the output of lava-group:
+#
+#lava-network query server
+#192.168.3.56
+#
+#Usage:
+# broadcast network info:
+# lava-network broadcast [interface]
+# collect network info:
+# lava-network collect [interface] <role>
+# query specific host info:
+# lava-network query [hostname] [info]
+# export hosts file:
+# lava-network hosts [path of hosts]
+#
+#So interface would be mandatory for broadcast and collect, hostname
+#would be mandatory for query, "path of hosts" would be mandatory for
+#hosts, role is optional for collect.
+
+
+LAVA_MULTI_NODE_API="LAVA_NETWORK"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+_LAVA_NETWORK_ID="network_info"
+_LAVA_NETWORK_ARG_MIN=2
+
+. $LAVA_TEST_BIN/lava-multi-node.lib
+
+LAVA_MULTI_NODE_NETWORK_CACHE="/tmp/lava_multi_node_network_cache.txt"
+
+_lava_multi_node_debug "$LAVA_MULTI_NODE_API checking arguments..."
+if [ $# -lt $_LAVA_NETWORK_ARG_MIN ]; then
+ _lava_multi_node_debug "$FUNCNAME Not enough arguments."
+ exit $LAVA_MULTI_NODE_EXIT_ERROR
+fi
+
+_lava_multi_node_debug "$LAVA_MULTI_NODE_API handle sub-command..."
+case "$1" in
+ "broadcast")
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API handle broadcast command..."
+ LAVA_MULTI_NODE_API="LAVA_SEND"
+ MESSAGE_COMMAND="<${LAVA_MULTI_NODE_API}"
+ export MESSAGE_ACK="<${LAVA_MULTI_NODE_API}_ACK>"
+ export MESSAGE_REPLY="<${LAVA_MULTI_NODE_API}_COMPLETE"
+ export MESSAGE_REPLY_ACK="<${LAVA_MULTI_NODE_API}_COMPLETE_ACK>"
+ export MESSAGE_HEAD="$MESSAGE_PREFIX $MESSAGE_COMMAND"
+ NETWORK_INFO_STREAM=`lava_multi_node_get_network_info $2`
+ lava_multi_node_send $_LAVA_NETWORK_ID $NETWORK_INFO_STREAM
+ ;;
+
+ "collect")
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API handle collect command..."
+ LAVA_MULTI_NODE_API="LAVA_WAIT_ALL"
+ MESSAGE_COMMAND="<${LAVA_MULTI_NODE_API}"
+ export MESSAGE_ACK="<${LAVA_MULTI_NODE_API}_ACK>"
+ export MESSAGE_REPLY="<${LAVA_MULTI_NODE_API}_COMPLETE"
+ export MESSAGE_REPLY_ACK="<${LAVA_MULTI_NODE_API}_COMPLETE_ACK>"
+ export MESSAGE_HEAD="$MESSAGE_PREFIX $MESSAGE_COMMAND"
+ lava_multi_node_send $_LAVA_NETWORK_ID $3
+ lava_multi_node_wait_for_message $LAVA_MULTI_NODE_NETWORK_CACHE
+ ;;
+
+ "query")
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API handle query command..."
+ lava_multi_node_check_cache $LAVA_MULTI_NODE_NETWORK_CACHE
+ lava_multi_node_print_host_info $2 $3
+ ;;
+
+ "hosts")
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API handle hosts command..."
+ lava_multi_node_check_cache $LAVA_MULTI_NODE_NETWORK_CACHE
+ lava_multi_node_make_hosts $2
+ ;;
+
+ "alias-hosts")
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API handle aliased hosts command..."
+ lava_multi_node_check_cache $LAVA_MULTI_NODE_NETWORK_CACHE
+ lava_multi_node_make_aliased_hosts $2
+ ;;
+
+ *)
+ _lava_multi_node_debug "$LAVA_MULTI_NODE_API command $1 is not supported."
+ exit $LAVA_MULTI_NODE_EXIT_ERROR
+ ;;
+esac
diff --git a/lava_test_shell/multi_node/lava-role b/lava_test_shell/multi_node/lava-role
new file mode 100644
index 0000000..53568c1
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-role
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Prints the role the current device is playing in a multi-node job.
+#
+#Usage: ``lava-role``
+#
+#*Example.* In a directory with several scripts, one for each role
+#involved in the test::
+#
+# $ ./run-`lava-role`.sh
+#
+#Usage: ``lava-role list``
+#
+#Lists all the available roles for the current group, separated by whitespace.
+
+LIST=$1
+if [ "$LIST" != "list" ]; then
+ printf "%s" ${TARGET_ROLE}
+ exit 0
+fi
+lava-group | cut -f2
diff --git a/lava_test_shell/multi_node/lava-self b/lava_test_shell/multi_node/lava-self
new file mode 100644
index 0000000..e792d96
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-self
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Prints the name of the current device.
+#
+#Usage: ``lava-self``
+
+echo ${LAVA_HOSTNAME}
diff --git a/lava_test_shell/multi_node/lava-send b/lava_test_shell/multi_node/lava-send
new file mode 100644
index 0000000..9011c30
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-send
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Sends a message to the group, optionally passing associated key-value
+#data pairs. Sending a message is a non-blocking operation. The message
+#is guaranteed to be available to all members of the group, but some of
+#them might never retrieve it.
+#
+#Usage: ``lava-send <message-id> [key1=val1 [key2=val2] ...]``
+LAVA_MULTI_NODE_API="LAVA_SEND"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-multi-node.lib
+
+lava_multi_node_send $1 "$(_get_key_value_pattern $@)"
diff --git a/lava_test_shell/multi_node/lava-start-vms b/lava_test_shell/multi_node/lava-start-vms
new file mode 100644
index 0000000..f3df87a
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-start-vms
@@ -0,0 +1,6 @@
+#!/bin/sh -ex
+
+# Signals that the vms can be started. Must be called from the host node when
+# it's ready to start the VM's
+
+lava-send lava_vm_start host_ip=$_LAVA_VM_GROUP_HOST_IP
diff --git a/lava_test_shell/multi_node/lava-sync b/lava_test_shell/multi_node/lava-sync
new file mode 100644
index 0000000..ae49a92
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-sync
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Global synchronization primitive. Sends a message, and waits for the
+#same message from all of the other devices.
+#
+#Usage: ``lava-sync <message>``
+#
+#``lava-sync foo`` is effectively the same as ``lava-send foo`` followed
+#by ``lava-wait-all foo``.
+LAVA_MULTI_NODE_API="LAVA_SYNC"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-multi-node.lib
+
+lava_multi_node_send $1
+
+lava_multi_node_wait_for_message
diff --git a/lava_test_shell/multi_node/lava-wait b/lava_test_shell/multi_node/lava-wait
new file mode 100644
index 0000000..c5c6785
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-wait
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Waits until any other device in the group sends a message with the given
+#ID. This call will block until such message is sent.
+#
+#Usage: ``lava-wait <message-id>``
+#
+#If there was data passed in the message, the key-value pairs will be
+#printed in the standard output, each in one line. If no key values were
+#passed, nothing is printed.
+LAVA_MULTI_NODE_API="LAVA_WAIT"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-multi-node.lib
+
+lava_multi_node_send $1
+
+lava_multi_node_wait_for_message
diff --git a/lava_test_shell/multi_node/lava-wait-all b/lava_test_shell/multi_node/lava-wait-all
new file mode 100644
index 0000000..120f7a9
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-wait-all
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+#This file is for Multi-Node test
+#
+#Waits until **all** other devices in the group send a message with the
+#given message ID. IF ``<role>`` is passed, only wait until all devices
+#with that given role send a message.
+#
+#``lava-wait-all <message-id> [<role>]``
+#
+#If data was sent by the other devices with the message, the key-value
+#pairs will be printed one per line, prefixed with the device name and
+#whitespace.
+LAVA_MULTI_NODE_API="LAVA_WAIT_ALL"
+#MESSAGE_TIMEOUT=5
+#MESSAGE_NEED_ACK=yes
+
+. $LAVA_TEST_BIN/lava-multi-node.lib
+
+lava_multi_node_send $1 $2
+
+lava_multi_node_wait_for_message
+
diff --git a/lava_test_shell/multi_node/lava-wait-for-vms b/lava_test_shell/multi_node/lava-wait-for-vms
new file mode 100644
index 0000000..e8a9f33
--- /dev/null
+++ b/lava_test_shell/multi_node/lava-wait-for-vms
@@ -0,0 +1,6 @@
+#!/bin/sh -ex
+
+# Waits for all VM's to finish
+
+lava-send lava_vm_stop
+lava-wait-all lava_vm_stop
diff --git a/lava_test_shell/vland/lava-vland-self b/lava_test_shell/vland/lava-vland-self
new file mode 100644
index 0000000..f8ef85b
--- /dev/null
+++ b/lava_test_shell/vland/lava-vland-self
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# This file is for Vland test
+#
+# Prints the interface details for this device
+#
+# Usage: ``lava-vland-self``
+
+echo -e ${LAVA_VLAND_SELF}
diff --git a/lava_test_shell/vland/lava-vland-tags b/lava_test_shell/vland/lava-vland-tags
new file mode 100644
index 0000000..31f7eba
--- /dev/null
+++ b/lava_test_shell/vland/lava-vland-tags
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+# This file is for Vland test
+#
+# Prints the tag details for this device
+#
+# Usage: ``lava-vland-tags``
+
+echo -e ${LAVA_VLAND_TAGS}
diff --git a/pi.yaml b/pi.yaml
new file mode 100644
index 0000000..265dddf
--- /dev/null
+++ b/pi.yaml
@@ -0,0 +1,44 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: pi-stress-test
+ description: "PI-Stress-test for POSIX Priority Inheritance mutexes. It's a stress test that
+ checks Priority Inheritence Mutexes and their ability to avoid Priority Inversion
+ from occuring by running groups of threads that cause Priority Inversions."
+ maintainer:
+ - chase.qi@linaro.org
+ os:
+ - ubuntu
+ scope:
+ - functional
+ - preempt-rt
+ devices:
+ - panda
+ - panda-es
+ - arndale
+ - vexpress-a9
+ - vexpress-tc2
+ - beaglebone-black
+ - d01
+ - rtsm_fvp_base-aemv8a
+ - juno
+ environment:
+ - lava-test-shell
+
+install:
+ deps:
+ - rt-tests
+params:
+ # Length of the test run in seconds
+ DURATION: 300
+ # The number of inversion groups to run. By default pi_stress will detect the number of
+ # processors and determine the number of inversion groups automatically.
+ GROUP: 'default'
+ # Set MLOCKALL to ture to lock current and future memory
+ MLOCKALL: 'true'
+ # Set RR to true if you need use SCHED_RR for test threads. The
+ # default is to run the inversion threads as SCHED_FIFO
+ RR: 'false'
+
+run:
+ steps:
+ - ./ubuntu/scripts/pi-stress-test.py $DURATION $GROUP $MLOCKALL $RR
diff --git a/smoke.yaml b/smoke.yaml
new file mode 100644
index 0000000..6a33377
--- /dev/null
+++ b/smoke.yaml
@@ -0,0 +1,27 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: smoke-tests-basic
+ description: "Basic system test command for Linaro Ubuntu images. The test runs basic commands
+ like pwd, uname, vmstat, ifconfig, lscpu, lsusb and lsb_release."
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ os:
+ - ubuntu
+ scope:
+ - functional
+ devices:
+ - panda
+ - panda-es
+ - arndale
+ - vexpress-a9
+ - vexpress-tc2
+ - juno
+
+run:
+ steps:
+ - lava-test-case linux-linaro-ubuntu-pwd --shell pwd
+ - lava-test-case linux-linaro-ubuntu-uname --shell uname -a
+ - lava-test-case linux-linaro-ubuntu-vmstat --shell vmstat
+ - lava-test-case linux-linaro-ubuntu-ifconfig --shell ifconfig -a
+ - lava-test-case linux-linaro-ubuntu-lscpu --shell lscpu
+ - lava-test-case linux-linaro-ubuntu-lsb_release --shell lsb_release -a