=== modified file 'doc/lava_test_shell.rst'
@@ -54,6 +54,7 @@
* ``lava-test-case``
* ``lava-test-case-attach``
+ * ``lava-test-run-attach``
You need to use ``lava-test-case`` (specifically, ``lava-test-case
--shell``) when you are working with `hooks, signals and external
@@ -113,6 +114,22 @@
1. test case id
2. the file to attach
3. (optional) the MIME type of the file (if no MIME type is passed, a
+ guess is made based on the filename
+
+lava-test-run-attach
+--------------------
+
+This attaches a file to the overall test run that lava-test-shell is
+currently executing, for example::
+
+ steps:
+ - "echo content > file.txt"
+ - "lava-test-run-attach file.txt text/plain"
+
+The arguments are:
+
+ 1. the file to attach
+ 2. (optional) the MIME type of the file (if no MIME type is passed, a
guess is made based on the filename)
=== modified file 'lava_dispatcher/actions/lava_test_shell.py'
@@ -139,11 +139,13 @@
LAVA_TEST_SHELL = '%s/lava-test-shell' % LAVA_TEST_DIR
LAVA_TEST_CASE = '%s/lava-test-case' % LAVA_TEST_DIR
LAVA_TEST_CASE_ATTACH = '%s/lava-test-case-attach' % LAVA_TEST_DIR
+LAVA_TEST_RUN_ATTACH = '%s/lava-test-run-attach' % LAVA_TEST_DIR
Target.android_deployment_data['lava_test_runner'] = LAVA_TEST_ANDROID
Target.android_deployment_data['lava_test_shell'] = LAVA_TEST_SHELL
Target.android_deployment_data['lava_test_case'] = LAVA_TEST_CASE
Target.android_deployment_data['lava_test_case_attach'] = LAVA_TEST_CASE_ATTACH
+Target.android_deployment_data['lava_test_run_attach'] = LAVA_TEST_RUN_ATTACH
Target.android_deployment_data['lava_test_sh_cmd'] = '/system/bin/mksh'
Target.android_deployment_data['lava_test_dir'] = '/data/lava'
Target.android_deployment_data['lava_test_results_part_attr'] = 'data_part_android_org'
@@ -152,6 +154,7 @@
Target.ubuntu_deployment_data['lava_test_shell'] = LAVA_TEST_SHELL
Target.ubuntu_deployment_data['lava_test_case'] = LAVA_TEST_CASE
Target.ubuntu_deployment_data['lava_test_case_attach'] = LAVA_TEST_CASE_ATTACH
+Target.ubuntu_deployment_data['lava_test_run_attach'] = LAVA_TEST_RUN_ATTACH
Target.ubuntu_deployment_data['lava_test_sh_cmd'] = '/bin/bash'
Target.ubuntu_deployment_data['lava_test_dir'] = '/lava'
Target.ubuntu_deployment_data['lava_test_results_part_attr'] = 'root_part'
@@ -160,6 +163,7 @@
Target.oe_deployment_data['lava_test_shell'] = LAVA_TEST_SHELL
Target.oe_deployment_data['lava_test_case'] = LAVA_TEST_CASE
Target.oe_deployment_data['lava_test_case_attach'] = LAVA_TEST_CASE_ATTACH
+Target.oe_deployment_data['lava_test_run_attach'] = LAVA_TEST_RUN_ATTACH
Target.oe_deployment_data['lava_test_sh_cmd'] = '/bin/sh'
Target.oe_deployment_data['lava_test_dir'] = '/lava'
Target.oe_deployment_data['lava_test_results_part_attr'] = 'root_part'
@@ -527,7 +531,7 @@
shcmd = target.deployment_data['lava_test_sh_cmd']
- for key in ['lava_test_shell', 'lava_test_case_attach']:
+ for key in ['lava_test_shell', 'lava_test_case_attach', 'lava_test_run_attach']:
fname = target.deployment_data[key]
with open(fname, 'r') as fin:
with open('%s/bin/%s' % (mntdir, os.path.basename(fname)), 'w') as fout:
=== added file 'lava_test_shell/lava-test-run-attach'
@@ -0,0 +1,34 @@
+#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.
+which basename > /dev/null || basename () { echo ${1/*\//}; }
+
+usage () {
+ echo "Usage: lava-test--attach FILE [MIME_TYPE]"
+ echo ""
+ echo "Attach FILE to the current test run."
+}
+
+FILE="$1"
+shift
+MIMETYPE="$1"
+shift
+if [ $# -gt 0 ]; then
+ usage
+ exit 1
+fi
+if [ ! -f "$FILE" ]; then
+ usage
+ exit 1
+fi
+
+# $LAVA_RESULT_DIR is set by lava-test-shell
+attachment_dir="$LAVA_RESULT_DIR/attachments"
+mkdir -p "$attachment_dir"
+cp "$FILE" "$attachment_dir"
+if [ ! -z "$MIMETYPE" ]; then
+ echo "$MIMETYPE" > "$attachment_dir/$(basename $FILE).mimetype"
+fi