From d05240297fa0f06c0e2c83f1663c0dc9f6da5d37 Mon Sep 17 00:00:00 2001
From: Luis Araujo <luis.araujo@collabora.co.uk>
Date: Tue, 20 Nov 2018 00:57:56 +0800
Subject: [PATCH] Add ported test cases for rhosydd and ribchester

This commit also adds a new macro 'macro_modules_preconditions'
to make convenient adding the preconditions for the library modules
test cases.

Signed-off-by: Luis Araujo <luis.araujo@collabora.co.uk>
---
 renderer/make_page.py          |  4 +++
 renderer/templates/index.html  |  5 ++--
 renderer/templates/macros.html | 11 +++++++
 tc/rhosydd.yaml                | 55 ++++++++++++++++++++++++++++++++++
 tc/ribchester.yaml             | 46 ++++++++++++++++++++++++++++
 5 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 tc/rhosydd.yaml
 create mode 100644 tc/ribchester.yaml

diff --git a/renderer/make_page.py b/renderer/make_page.py
index 69cddbf..936dea8 100755
--- a/renderer/make_page.py
+++ b/renderer/make_page.py
@@ -131,6 +131,10 @@ def get_template_values(testcase_data):
     if packages_list:
         template_values.update({ 'packages_list' :  packages_list })
 
+    modules_preconditions = metadata.get('macro_modules_preconditions')
+    if modules_preconditions:
+        template_values.update({ 'libname' : modules_preconditions })
+
     return template_values
 
 def generate_test_case(tc_file, directory):
diff --git a/renderer/templates/index.html b/renderer/templates/index.html
index 3207e39..6c15088 100644
--- a/renderer/templates/index.html
+++ b/renderer/templates/index.html
@@ -34,14 +34,15 @@
       <li>{{ resource|e }}</li>
       {% endfor %}
       </ul>
-      {% endif %}      
+      {% endif %}
 
-      {% if pre_conditions or pkgname or packages_list %}
+      {% if pre_conditions or pkgname or packages_list or libname %}
       <hr />
       <h4>Pre Conditions</h4>
       <ol>
       {% if pkgname %}{{ macros.ostree_preconditions(pkgname) }}{% endif %}
       {% if packages_list %}{{ macros.install_packages(packages_list) }}{% endif %}
+      {% if libname %}{{ macros.modules_preconditions(libname) }}{% endif %}
       {% for comment, command, output in pre_conditions %}
       {% if comment %}<li class="mb-sm-2">{{ comment|e }}</li>{% endif %}
       {% if command %}<p><kbd>{{ command|e }}</kbd></p>{% endif %}
diff --git a/renderer/templates/macros.html b/renderer/templates/macros.html
index 4c72012..c52198d 100644
--- a/renderer/templates/macros.html
+++ b/renderer/templates/macros.html
@@ -20,3 +20,14 @@
   <li class="mb-sm-2">Restart the system to restore the filesystem state to read-only before running the test.</li>
   <p><kbd>$ sudo reboot</kbd></p>
 {% endmacro %}
+
+{% macro modules_preconditions(libname) %}
+  <li class="mb-sm-2">Download the ribchester binary inside the /tmp directory.</li>
+  <p><kbd>$ cd /tmp/</kbd></p>
+  <p><kbd>$ apt source {{ libname }}</kbd></p>
+  <p><kbd>$ chown user:user -R /tmp/{{ libname }}-*</kbd></p>
+  <li class="mb-sm-2">Clone the apertis-tests git repository:</li>
+  <p><kbd>$ git clone https://gitlab.apertis.org/infrastructure/apertis-tests.git</kbd></p>
+  <li class="mb-sm-2">Enter the tests directory and follow the execution steps.</li>
+  <p><kbd>$ cd apertis-tests/</kbd></p>
+{% endmacro %}
diff --git a/tc/rhosydd.yaml b/tc/rhosydd.yaml
new file mode 100644
index 0000000..a066060
--- /dev/null
+++ b/tc/rhosydd.yaml
@@ -0,0 +1,55 @@
+metadata:
+  name: rhosydd
+  format: "Apertis Test Definition 1.0"
+  image-type: any
+  image-arch: any
+  type: unit
+  exec-type: automated
+  priority: medium
+  maintainer: "Apertis Project"
+  description: "Rhosydd module test."
+
+  macro_modules_preconditions: rhosydd
+
+  expected:
+    - "All tests should pass (ok). The output should be similar to:"
+    - |
+        >test.name0...ok
+        test.name1...ok
+        test.name2...ok
+        test.nameN...ok
+
+install:
+  deps:
+  - build-essential
+  - devscripts
+  - dpkg-dev
+  - gnome-desktop-testing
+  - libcroesor-0-dev
+  - libcroesor-0-tests
+  - librhosydd-0-dev
+  - librhosydd-0-tests
+  - python3-debian
+  - rhosydd
+  - rhosydd-tests
+  - rhosydd-tools
+  - rhosydd-mock-backends
+  steps:
+  # Download in /tmp directory
+  - cd /tmp/
+  - apt source rhosydd
+  - chown user:user -R /tmp/rhosydd-*
+
+run:
+  steps:
+  - "# Execute the following commands:"
+  - systemctl start rhosydd-mock-backend.service
+  - systemctl start rhosydd-speedo-backend.service
+  - common/run-test-in-systemd --timeout=900 --chdir /tmp/rhosydd-* --user=user --name=rhosydd -- sadt --verbose
+
+parse:
+  pattern: '^(?P<test_case_id>[a-zA-Z0-9_\-\./]+)\s...\s(?P<result>ok|FAIL|SKIP)'
+  fixupdict:
+    ok: pass
+    FAIL: fail
+    SKIP: skip
diff --git a/tc/ribchester.yaml b/tc/ribchester.yaml
new file mode 100644
index 0000000..63a05e0
--- /dev/null
+++ b/tc/ribchester.yaml
@@ -0,0 +1,46 @@
+metadata:
+  name: ribchester
+  format: "Apertis Test Definition 1.0"
+  image-type: any
+  image-arch: any
+  type: unit
+  exec-type: automated
+  priority: critical
+  maintainer: "Apertis Project"
+  description: "Ribchester library test."
+
+  macro_modules_preconditions: ribchester
+
+  expected:
+    - "All tests should pass (ok). The output should be similar to:"
+    - |
+        >test.name0...ok
+        test.name1...ok
+        test.name2...ok
+        test.nameN...ok
+
+install:
+  deps:
+  - build-essential
+  - devscripts
+  - gnome-desktop-testing
+  - python3-debian
+  - ribchester-dev
+  - ribchester-tests
+  steps:
+  # Download in /tmp directory
+  - cd /tmp/
+  - apt source ribchester
+  - chown user:user -R /tmp/ribchester-*
+
+run:
+  steps:
+    - "# Execute the following command:"
+    - common/run-test-in-systemd --timeout=900 --chdir /tmp/ribchester-* --user=user --name=ribchester -- sadt --verbose
+
+parse:
+  pattern: '^(?P<test_case_id>[a-zA-Z0-9_\-\./]+)\s...\s(?P<result>ok|FAIL|SKIP)'
+  fixupdict:
+    ok: pass
+    FAIL: fail
+    SKIP: skip
-- 
GitLab