From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top, Stefano Brivio <sbrivio@redhat.com>
Cc: crosa@redhat.com, jarichte@redhat.com,
David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH 12/27] avocado: Convert build tests to avocado
Date: Tue, 27 Jun 2023 12:54:13 +1000 [thread overview]
Message-ID: <20230627025429.2209702-13-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20230627025429.2209702-1-david@gibson.dropbear.id.au>
Move the build and make install tests from the old hand-rolled test
harness to avocado. The avocado versions are safer, in that they make a
private copy of the sources before building, so they won't interfere with
concurrent tests or builds in the original source tree.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
oldtest/run | 2 +-
test/Makefile | 2 +-
test/avocado/build.py | 94 +++++++++++++++++++++++++++++++++++++++++++
test/build/all | 61 ----------------------------
test/lib/setup | 7 ----
test/run | 4 --
6 files changed, 96 insertions(+), 74 deletions(-)
create mode 100644 test/avocado/build.py
delete mode 100644 test/build/all
diff --git a/oldtest/run b/oldtest/run
index 56fcd1b3..a16bc49b 100755
--- a/oldtest/run
+++ b/oldtest/run
@@ -65,7 +65,7 @@ run() {
[ ${CI} -eq 1 ] && video_start ci
setup build
-# test build/all
+ test build/all
test build/cppcheck
test build/clang_tidy
teardown build
diff --git a/test/Makefile b/test/Makefile
index 0e641024..58159c83 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -210,7 +210,7 @@ PYTHON = python3
VENV = venv
PLUGIN = avocado_classless
PYPKGS = $(PLUGIN)/$(PLUGIN) $(wildcard $(PLUGIN)/*.py) \
- tasst
+ tasst $(shell find avocado -name '*.py')
# Put this back if/when the plugin becomes available in upstream/system avocado
#AVOCADO := $(shell which avocado)
diff --git a/test/avocado/build.py b/test/avocado/build.py
new file mode 100644
index 00000000..4cce77a6
--- /dev/null
+++ b/test/avocado/build.py
@@ -0,0 +1,94 @@
+#! /usr/bin/env avocado-runner-avocado-classless
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright Red Hat
+# Author: David Gibson <david@gibson.dropbear.id.au>
+
+"""
+avocado/build.py - Test passt & pasta build targets
+"""
+
+
+import contextlib
+import os
+import os.path
+import shutil
+from tempfile import TemporaryDirectory
+
+from avocado_classless.test import assert_raises, test
+
+from tasst.exesite import CmdError, REAL_HOST
+
+
+@contextlib.contextmanager
+def clone_source_tree():
+ REAL_HOST.require_cmds('git', 'make')
+
+ with TemporaryDirectory(ignore_cleanup_errors=False) as tmpdir:
+ os.chdir('..')
+ # Make a temporary copy of the sources
+ srcfiles = REAL_HOST.output('git ls-files') \
+ .decode('utf-8').splitlines()
+ for src in srcfiles:
+ dst = os.path.join(tmpdir, src)
+ os.makedirs(os.path.dirname(dst), exist_ok=True)
+ shutil.copy(src, dst)
+ os.chdir(tmpdir)
+ yield tmpdir
+
+
+def build_target(target, outputs):
+ with clone_source_tree():
+ for o in outputs:
+ assert not os.path.exists(o)
+ REAL_HOST.fg(f'make {target} CFLAGS="-Werror"')
+ for o in outputs:
+ assert os.path.exists(o)
+ REAL_HOST.fg('make clean')
+ for o in outputs:
+ assert not os.path.exists(o)
+
+
+@test
+def test_make_passt():
+ build_target('passt', ['passt'])
+
+
+@test
+def test_make_pasta():
+ build_target('pasta', ['pasta'])
+
+
+@test
+def test_make_qrap():
+ build_target('qrap', ['qrap'])
+
+
+@test
+def test_make_all():
+ build_target('all', ['passt', 'pasta', 'qrap'])
+
+
+@test
+def test_make_install_uninstall():
+ with clone_source_tree():
+ with TemporaryDirectory(ignore_cleanup_errors=False) as prefix:
+ bindir = os.path.join(prefix, 'bin')
+ mandir = os.path.join(prefix, 'share', 'man')
+ exes = ['passt', 'pasta', 'qrap']
+
+ # Install
+ REAL_HOST.fg(f'make install CFLAGS="-Werror" prefix={prefix}')
+
+ for t in exes:
+ assert os.path.isfile(os.path.join(bindir, t))
+ REAL_HOST.fg(f'man -M {mandir} -W passt')
+
+ # Uninstall
+ REAL_HOST.fg(f'make uninstall prefix={prefix}')
+
+ for t in exes:
+ assert not os.path.exists(os.path.join(bindir, t))
+ assert_raises(CmdError, REAL_HOST.fg,
+ f'man -M {mandir} -W passt')
diff --git a/test/build/all b/test/build/all
deleted file mode 100644
index 1f79e0d8..00000000
--- a/test/build/all
+++ /dev/null
@@ -1,61 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-#
-# PASST - Plug A Simple Socket Transport
-# for qemu/UNIX domain socket mode
-#
-# PASTA - Pack A Subtle Tap Abstraction
-# for network namespace/tap device mode
-#
-# test/build/all - Build targets, one by one, then all together, check output
-#
-# Copyright (c) 2021 Red Hat GmbH
-# Author: Stefano Brivio <sbrivio@redhat.com>
-
-htools make cc rm uname getconf mkdir cp rm man
-
-test Build passt
-host make clean
-check ! [ -e passt ]
-host CFLAGS="-Werror" make passt
-check [ -f passt ]
-
-test Build pasta
-host make clean
-check ! [ -e pasta ]
-host CFLAGS="-Werror" make pasta
-check [ -h pasta ]
-
-test Build qrap
-host make clean
-check ! [ -e qrap ]
-host CFLAGS="-Werror" make qrap
-check [ -f qrap ]
-
-test Build all
-host make clean
-check ! [ -e passt ]
-check ! [ -e pasta ]
-check ! [ -e qrap ]
-host CFLAGS="-Werror" make
-check [ -f passt ]
-check [ -h pasta ]
-check [ -f qrap ]
-
-test Install
-host mkdir __STATEDIR__/prefix
-host prefix=__STATEDIR__/prefix make install
-check [ -f __STATEDIR__/prefix/bin/passt ]
-check [ -h __STATEDIR__/prefix/bin/pasta ]
-check [ -f __STATEDIR__/prefix/bin/qrap ]
-check man -M __STATEDIR__/prefix/share/man -W passt
-check man -M __STATEDIR__/prefix/share/man -W pasta
-check man -M __STATEDIR__/prefix/share/man -W qrap
-
-test Uninstall
-host prefix=__STATEDIR__/prefix make uninstall
-check ! [ -f __STATEDIR__/prefix/bin/passt ]
-check ! [ -h __STATEDIR__/prefix/bin/pasta ]
-check ! [ -f __STATEDIR__/prefix/bin/qrap ]
-check ! man -M __STATEDIR__/prefix/share/man -W passt 2>/dev/null
-check ! man -M __STATEDIR__/prefix/share/man -W pasta 2>/dev/null
-check ! man -M __STATEDIR__/prefix/share/man -W qrap 2>/dev/null
diff --git a/test/lib/setup b/test/lib/setup
index 9b39b9fe..5386805f 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -18,13 +18,6 @@ VCPUS="$( [ $(nproc) -ge 8 ] && echo 6 || echo $(( $(nproc) / 2 + 1 )) )"
__mem_kib="$(sed -n 's/MemTotal:[ ]*\([0-9]*\) kB/\1/p' /proc/meminfo)"
VMEM="$((${__mem_kib} / 1024 / 4))"
-# setup_build() - Set up pane layout for build tests
-setup_build() {
- context_setup_host host
-
- layout_host
-}
-
# setup_passt() - Start qemu and passt
setup_passt() {
context_setup_host host
diff --git a/test/run b/test/run
index ce24f446..b8000224 100755
--- a/test/run
+++ b/test/run
@@ -64,10 +64,6 @@ run() {
perf_init
[ ${CI} -eq 1 ] && video_start ci
- setup build
- test build/all
- teardown build
-
setup pasta
test pasta/ndp
test pasta/dhcp
--
@@ -64,10 +64,6 @@ run() {
perf_init
[ ${CI} -eq 1 ] && video_start ci
- setup build
- test build/all
- teardown build
-
setup pasta
test pasta/ndp
test pasta/dhcp
--
2.41.0
next prev parent reply other threads:[~2023-06-27 2:54 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-27 2:54 [PATCH 00/27] RFC: Start converting passt & pasta tests to Avocado using special plugin David Gibson
2023-06-27 2:54 ` [PATCH 01/27] avocado: Make a duplicate copy of testsuite for comparison purposes David Gibson
2023-06-27 2:54 ` [PATCH 02/27] avocado: Don't double download assets for test/ and oldtest/ David Gibson
2023-06-27 2:54 ` [PATCH 03/27] avocado: Move static checkers to avocado David Gibson
2023-06-27 2:54 ` [PATCH 04/27] avocado: Introduce "avocado-classless" plugin, runner and outline David Gibson
2023-06-27 2:54 ` [PATCH 05/27] avocado, test: Add static checkers for Python code David Gibson
2023-06-27 2:54 ` [PATCH 06/27] avocado: Resolver implementation for avocado-classless plugin David Gibson
2023-06-27 2:54 ` [PATCH 07/27] avocado: Add basic assertion helpers to " David Gibson
2023-06-27 2:54 ` [PATCH 08/27] tasst, avocado: Introduce library of common test helpers David Gibson
2023-06-27 2:54 ` [PATCH 09/27] avocado-classless: Test matrices by composition David Gibson
2023-06-27 2:54 ` [PATCH 10/27] tasst: Helper functions for executing commands in different places David Gibson
2023-06-27 2:54 ` [PATCH 11/27] avocado-classless: Allow overriding default timeout David Gibson
2023-06-27 2:54 ` David Gibson [this message]
2023-06-27 2:54 ` [PATCH 13/27] tasst: Add helpers for running background commands on sites David Gibson
2023-06-27 2:54 ` [PATCH 14/27] tasst: Add helper to get network interface names for a site David Gibson
2023-06-27 2:54 ` [PATCH 15/27] tasst: Add helpers to run commands with nstool David Gibson
2023-06-27 2:54 ` [PATCH 16/27] tasst: Add ifup and network address helpers to Site David Gibson
2023-06-27 2:54 ` [PATCH 17/27] tasst: Helper for creating veth devices between namespaces David Gibson
2023-06-27 2:54 ` [PATCH 18/27] tasst: Add helper for getting MTU of a network interface David Gibson
2023-06-27 2:54 ` [PATCH 19/27] tasst: Add helper to wait for IP address to appear David Gibson
2023-06-27 2:54 ` [PATCH 20/27] tasst: Add helpers for getting a site's routes David Gibson
2023-06-27 2:54 ` [PATCH 21/27] tasst: Helpers to test transferring data between sites David Gibson
2023-06-27 2:54 ` [PATCH 22/27] tasst: IP address allocation helpers David Gibson
2023-06-27 2:54 ` [PATCH 23/27] tasst: Helpers for running daemons with a pidfile David Gibson
2023-06-27 2:54 ` [PATCH 24/27] tasst: Helpers for testing NDP behaviour David Gibson
2023-06-27 2:54 ` [PATCH 25/27] tasst: Helpers for testing DHCP & DHCPv6 behaviour David Gibson
2023-06-27 2:54 ` [PATCH 26/27] tasst: Helpers to construct a simple network environment for tests David Gibson
2023-06-27 2:54 ` [PATCH 27/27] avocado: Convert basic pasta tests David Gibson
2023-07-05 0:30 ` Stefano Brivio
2023-07-05 3:27 ` David Gibson
2023-07-07 17:42 ` Stefano Brivio
2023-07-10 7:45 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230627025429.2209702-13-david@gibson.dropbear.id.au \
--to=david@gibson.dropbear.id.au \
--cc=crosa@redhat.com \
--cc=jarichte@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).