This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git
commit 091af01090b6b6013dd44628af27dc7a31be9c84 Author: Tristan van Berkom <[email protected]> AuthorDate: Thu Mar 24 15:29:45 2022 +0900 tests/elements/autotools.py: Adding autotools element test --- tests/elements/autotools.py | 99 +++++++++++++++++++++ tests/elements/autotools/elements/amhello.bst | 10 +++ .../autotools/elements/amhelloconfroot.bst | 15 ++++ tests/elements/autotools/elements/base.bst | 3 + .../autotools/elements/base/alpine-image.bst | 6 ++ tests/elements/autotools/files/amhello.tar.gz | Bin 0 -> 30555 bytes tests/elements/autotools/project.conf | 15 ++++ 7 files changed, 148 insertions(+) diff --git a/tests/elements/autotools.py b/tests/elements/autotools.py new file mode 100644 index 0000000..2b4ce65 --- /dev/null +++ b/tests/elements/autotools.py @@ -0,0 +1,99 @@ +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os +import pytest + +from buildstream._testing.integration import integration_cache # pylint: disable=unused-import +from buildstream._testing import cli_integration as cli # pylint: disable=unused-import +from buildstream._testing.integration import assert_contains +from buildstream._testing._utils.site import HAVE_SANDBOX + + +pytestmark = pytest.mark.integration + + +DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "autotools") + + +# Test that an autotools build 'works' - we use the autotools sample +# amhello project for this. [email protected](DATA_DIR) [email protected](not HAVE_SANDBOX, reason="Only available with a functioning sandbox") +def test_autotools_build(cli, datafiles): + project = str(datafiles) + checkout = os.path.join(cli.directory, "checkout") + element_name = "amhello.bst" + + result = cli.run(project=project, args=["build", element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout]) + assert result.exit_code == 0 + + assert_contains( + checkout, + [ + "/usr", + "/usr/lib", + "/usr/bin", + "/usr/share", + "/usr/bin/hello", + "/usr/share/doc", + "/usr/share/doc/amhello", + "/usr/share/doc/amhello/README", + ], + ) + + # Check the log + result = cli.run(project=project, args=["artifact", "log", element_name]) + assert result.exit_code == 0 + log = result.output + + # Verify we get expected output exactly once + assert log.count("Making all in src") == 1 + + +# Test that an autotools build 'works' - we use the autotools sample +# amhello project for this. [email protected](DATA_DIR) [email protected](not HAVE_SANDBOX, reason="Only available with a functioning sandbox") +def test_autotools_confroot_build(cli, datafiles): + project = str(datafiles) + checkout = os.path.join(cli.directory, "checkout") + element_name = "amhelloconfroot.bst" + + result = cli.run(project=project, args=["build", element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout]) + assert result.exit_code == 0 + + assert_contains( + checkout, + [ + "/usr", + "/usr/lib", + "/usr/bin", + "/usr/share", + "/usr/bin/hello", + "/usr/share/doc", + "/usr/share/doc/amhello", + "/usr/share/doc/amhello/README", + ], + ) + + +# Test running an executable built with autotools [email protected](DATA_DIR) [email protected](not HAVE_SANDBOX, reason="Only available with a functioning sandbox") +def test_autotools_run(cli, datafiles): + project = str(datafiles) + element_name = "amhello.bst" + + result = cli.run(project=project, args=["build", element_name]) + assert result.exit_code == 0 + + result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"]) + assert result.exit_code == 0 + assert result.output == "Hello World!\nThis is amhello 1.0.\n" diff --git a/tests/elements/autotools/elements/amhello.bst b/tests/elements/autotools/elements/amhello.bst new file mode 100644 index 0000000..ee3a029 --- /dev/null +++ b/tests/elements/autotools/elements/amhello.bst @@ -0,0 +1,10 @@ +kind: autotools +description: Autotools test + +depends: +- base.bst + +sources: +- kind: tar + url: project_dir:/files/amhello.tar.gz + ref: 9ba123fa4e660929e9a0aa99f0c487b7eee59c5e7594f3284d015640b90f5590 diff --git a/tests/elements/autotools/elements/amhelloconfroot.bst b/tests/elements/autotools/elements/amhelloconfroot.bst new file mode 100644 index 0000000..2892644 --- /dev/null +++ b/tests/elements/autotools/elements/amhelloconfroot.bst @@ -0,0 +1,15 @@ +kind: autotools +description: Autotools test + +depends: +- base.bst + +sources: +- kind: tar + url: project_dir:/files/amhello.tar.gz + ref: 9ba123fa4e660929e9a0aa99f0c487b7eee59c5e7594f3284d015640b90f5590 + directory: SourceFile + +variables: + conf-root: "%{build-root}/SourceFile" + command-subdir: build diff --git a/tests/elements/autotools/elements/base.bst b/tests/elements/autotools/elements/base.bst new file mode 100644 index 0000000..da7c70b --- /dev/null +++ b/tests/elements/autotools/elements/base.bst @@ -0,0 +1,3 @@ +kind: stack +depends: +- base/alpine-image.bst diff --git a/tests/elements/autotools/elements/base/alpine-image.bst b/tests/elements/autotools/elements/base/alpine-image.bst new file mode 100644 index 0000000..f8e00ba --- /dev/null +++ b/tests/elements/autotools/elements/base/alpine-image.bst @@ -0,0 +1,6 @@ +kind: import +description: Import an alpine image as the platform +sources: +- kind: tar + url: alpine:integration-tests-base.v1.x86_64.tar.xz + ref: 3eb559250ba82b64a68d86d0636a6b127aa5f6d25d3601a79f79214dc9703639 diff --git a/tests/elements/autotools/files/amhello.tar.gz b/tests/elements/autotools/files/amhello.tar.gz new file mode 100644 index 0000000..afe1899 Binary files /dev/null and b/tests/elements/autotools/files/amhello.tar.gz differ diff --git a/tests/elements/autotools/project.conf b/tests/elements/autotools/project.conf new file mode 100644 index 0000000..76ce388 --- /dev/null +++ b/tests/elements/autotools/project.conf @@ -0,0 +1,15 @@ +# test project config +name: test +min-version: 2.0 + +element-path: elements + +plugins: +- origin: pip + package-name: buildstream-plugins + elements: + - autotools + +aliases: + alpine: https://bst-integration-test-images.ams3.cdn.digitaloceanspaces.com/ + project_dir: file://{project_dir}
