From 73fbe326ec0d9e0a35ec795076557ae2e9a213c2 Mon Sep 17 00:00:00 2001
From: Simon McVittie <simon.mcvittie@collabora.co.uk>
Date: Thu, 3 Mar 2016 19:35:51 +0000
Subject: [PATCH] Move cgroups automated test from chaiwala-tests to
 apertis-tests{,-bin}

Leave a symlink behind for compatibility.

The test still has a dependency on chaiwala-tests for now, so that it
can be run against older versions of apertis-tests.

While I'm editing dependencies, add python, since the test runs it
explicitly.

Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D2162
---
 cgroups/automated/Makefile           |  5 +++++
 cgroups/automated/run-test.sh        | 10 ++++++++++
 common/cgroups-resource-control.yaml |  3 +++
 debian/apertis-tests-bin.install     |  2 ++
 debian/apertis-tests.install         |  4 ++++
 debian/chaiwala-tests.links          |  1 +
 debian/chaiwala-tests.maintscript    |  1 +
 debian/control                       |  1 +
 8 files changed, 27 insertions(+)

diff --git a/cgroups/automated/Makefile b/cgroups/automated/Makefile
index ec44e4b2..f0b36adf 100644
--- a/cgroups/automated/Makefile
+++ b/cgroups/automated/Makefile
@@ -1,5 +1,8 @@
 # vim: set ts=8 tw=80 :
 
+LIBDIR = $(PREFIX)/lib/apertis-tests
+DATADIR = $(LIBDIR)
+
 progs		:= cgroup-memory-threshold-notifier random-reads
 
 include ../../global-config.mk
@@ -15,5 +18,7 @@ get-deps:
 	$(APT_GET) install cpuburn curl
 
 install: .INSTALL
+	$(INSTALL) Makefile $(DESTDIR)$(TESTDATADIR)
+	$(INSTALL) $(patsubst %,%.c,$(progs)) $(DESTDIR)$(TESTDATADIR)
 
 clean: .CLEAN
diff --git a/cgroups/automated/run-test.sh b/cgroups/automated/run-test.sh
index e07ac7ab..de5a9136 100755
--- a/cgroups/automated/run-test.sh
+++ b/cgroups/automated/run-test.sh
@@ -6,6 +6,16 @@ set -e
 TESTDIR=$(cd $(dirname $0); pwd; cd - &>/dev/null)
 . "${TESTDIR}/config.sh"
 
+# Allow running uninstalled with the installed binaries
+if ! [ -e "$TESTLIBDIR/random-reads" ]; then
+    TESTLIBDIR=/usr/lib/apertis-tests/cgroups/automated
+fi
+
+# Same (legacy path)
+if ! [ -e "$TESTLIBDIR/random-reads" ]; then
+    TESTLIBDIR=/usr/lib/chaiwala-tests/cgroups/automated
+fi
+
 CGFS_PATH="/sys/fs/cgroup"
 MID_CG="middleware"
 APP_CG="applications"
diff --git a/common/cgroups-resource-control.yaml b/common/cgroups-resource-control.yaml
index 5a1d5246..4ee9ab6e 100644
--- a/common/cgroups-resource-control.yaml
+++ b/common/cgroups-resource-control.yaml
@@ -12,9 +12,12 @@ metadata:
 
 install:
   deps:
+  - apertis-tests
+  - apertis-tests-bin
   - chaiwala-tests
   - cpuburn
   - curl
+  - python
 
 run:
   steps:
diff --git a/debian/apertis-tests-bin.install b/debian/apertis-tests-bin.install
index 97b8c56c..63e3d232 100644
--- a/debian/apertis-tests-bin.install
+++ b/debian/apertis-tests-bin.install
@@ -1 +1,3 @@
+usr/lib/apertis-tests/cgroups/automated/cgroup-memory-threshold-notifier
+usr/lib/apertis-tests/cgroups/automated/random-reads
 usr/lib/apertis-tests/networking/proxy-manual/libsoup-get
diff --git a/debian/apertis-tests.install b/debian/apertis-tests.install
index ad22ed0a..8de105b9 100644
--- a/debian/apertis-tests.install
+++ b/debian/apertis-tests.install
@@ -4,6 +4,10 @@ usr/lib/apertis-tests/apparmor/*.yaml
 usr/lib/apertis-tests/apparmor/automated
 usr/lib/apertis-tests/apparmor/folks
 usr/lib/apertis-tests/apparmor/run-aa-test
+usr/lib/apertis-tests/cgroups/automated/README
+usr/lib/apertis-tests/cgroups/automated/Makefile
+usr/lib/apertis-tests/cgroups/automated/*.c
+usr/lib/apertis-tests/cgroups/automated/*.sh
 usr/lib/apertis-tests/clutter
 usr/lib/apertis-tests/common
 usr/lib/apertis-tests/dbus
diff --git a/debian/chaiwala-tests.links b/debian/chaiwala-tests.links
index e6fb5aa8..b2ce6e22 100644
--- a/debian/chaiwala-tests.links
+++ b/debian/chaiwala-tests.links
@@ -1,2 +1,3 @@
+usr/lib/apertis-tests/cgroups usr/lib/chaiwala-tests/cgroups
 usr/lib/apertis-tests/dbus/dos-match-rules usr/share/chaiwala-tests/dbus-dos-match-rules/manual
 usr/lib/apertis-tests/dbus/dos-reply-time usr/share/chaiwala-tests/dbus-dos-reply-time/manual
diff --git a/debian/chaiwala-tests.maintscript b/debian/chaiwala-tests.maintscript
index 8147ea0f..105f07df 100644
--- a/debian/chaiwala-tests.maintscript
+++ b/debian/chaiwala-tests.maintscript
@@ -1,2 +1,3 @@
+dir_to_symlink /usr/lib/chaiwala-tests/cgroups /usr/lib/apertis-tests/cgroups
 symlink_to_dir /usr/share/chaiwala-tests/dbus-dos-match-rules/manual /usr/lib/apertis-tests/dbus/dos-match-rules
 symlink_to_dir /usr/share/chaiwala-tests/dbus-dos-reply-time/manual /usr/lib/apertis-tests/dbus/dos-reply-time
diff --git a/debian/control b/debian/control
index d5900706..dd695ff7 100644
--- a/debian/control
+++ b/debian/control
@@ -277,6 +277,7 @@ Package: chaiwala-tests
 Architecture: any
 Depends: ${shlibs:Depends}, ${misc:Depends},
          apertis-tests,
+         apertis-tests-bin,
          libglib2.0-bin, binutils,
          connman, python-dbus, python-gobject,
          gir1.2-gstreamer-1.0, gir1.2-gst-plugins-base-1.0,
-- 
GitLab