Add test documentation and example 29/11029/1
authorLoys Ollivier <lollivier@baylibre.com>
Tue, 26 Sep 2017 06:57:22 +0000 (08:57 +0200)
committerLoys Ollivier <lollivier@baylibre.com>
Tue, 26 Sep 2017 06:57:22 +0000 (08:57 +0200)
Added:
- README to point to releng-scripts
- test documentation
- a test example skeleton

Change-Id: I75e7be55eb836adf4c8c6816689ffe5a65b76145
Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
README.md [new file with mode: 0644]
doc/skeleton.sh [new file with mode: 0755]
doc/skeleton.yaml [new file with mode: 0644]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..c463ecd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,9 @@
+# qa-testdefinitions
+
+This folder contains the test definitions used by [https://git.automotivelinux.org/AGL/releng-scripts/](releng-scripts)
+tools.
+
+## Add test definition
+A test definition skeleton is provided in the doc repository. For more information
+on how to generate tests using this repo please visit:
+[https://git.automotivelinux.org/AGL/releng-scripts/tree/doc/test-documentation.md](releng-scripts/doc/test-documentation.md)
\ No newline at end of file
diff --git a/doc/skeleton.sh b/doc/skeleton.sh
new file mode 100755 (executable)
index 0000000..22a7cc2
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+result=unkown
+ANIMALS=42
+PENGUINS=0
+
+get_result () {
+    if [ $? -eq "0" ]; then
+        echo "pass"
+    else
+        echo "fail"
+    fi
+}
+
+get_animals_count() {
+    echo $ANIMALS
+}
+
+get_penguins_count() {
+    echo $PENGUINS
+}
+
+echo "My test skeleton"
+
+set -x
+
+# Reporting commands results as they get executed
+lava-test-set start print-to-log
+echo "Hello"
+result=$(get_result)
+lava-test-case echo-hello --result $result
+echo "Bye !"
+result=$(get_result)
+lava-test-case echo-bye --result $result
+ls
+result=$(get_result)
+lava-test-case ls --result $result
+lava-test-set stop print-to-log
+
+set +x
+
+# Reporting constant tests
+lava-test-set start constant
+lava-test-case always-pass --result pass
+lava-test-case always-fail --result fail
+lava-test-set stop constant
+
+# Animals custom testing
+animals_count=$(get_animals_count)
+if [ $animals_count -ne 0 ]; then
+    result_animals=pass
+else
+    result_animals=fail
+fi
+penguins_count=$(get_penguins_count)
+if [ $penguins_count -ne 0 ]; then
+    result_penguins=pass
+else
+    result_penguins=fail
+fi
+
+# Reporting of animals tests
+lava-test-set start animals-measure
+lava-test-case any-animals --result $result_animals --measurement $animals_count --units animals
+lava-test-case any-penguins --result $result_penguins --measurement $penguins_count --units penguins
+lava-test-set stop animals-measure
+
+exit 0
diff --git a/doc/skeleton.yaml b/doc/skeleton.yaml
new file mode 100644 (file)
index 0000000..9f11dd2
--- /dev/null
@@ -0,0 +1,13 @@
+metadata:
+    name: skeleton
+    format: "Lava-Test-Shell Test Definition 1.0"
+    description: "A test skeleton"
+    os:
+        - openembedded
+    scope:
+        - functional
+
+run:
+    steps:
+        - "cd doc/"
+        - "./skeleton.sh"