From aedfc53e9a783b8cc1091f5a6d6bb15317616646 Mon Sep 17 00:00:00 2001 From: Björn Persson Date: Sat, 1 Feb 2014 09:58:52 +0100 Subject: more testcases --- testsuite/inputs/build_with_Gnatmake | 4 +++ testsuite/inputs/configure_and_build | 8 +++++ testsuite/inputs/configure_and_clean | 13 ++++++++ testsuite/inputs/directories_project | 5 +++ testsuite/inputs/relocatable | 4 +++ testsuite/library | 40 +++++++++++------------ testsuite/run_tests | 11 ++++--- testsuite/sources/library_1/build_testcase.gpr.gp | 2 +- testsuite/sources/library_1/generated_files | 2 +- testsuite/sources/program_1/Makefile | 16 +++++++++ testsuite/sources/program_1/build_testcase.gpr | 20 ++++++++++++ testsuite/sources/program_1/generated_files | 2 ++ testsuite/sources/program_1/testcase.adb | 20 ++++++++++++ testsuite/test_directories.gpr | 9 +++++ 14 files changed, 130 insertions(+), 26 deletions(-) create mode 100644 testsuite/inputs/build_with_Gnatmake create mode 100644 testsuite/inputs/configure_and_build create mode 100644 testsuite/inputs/configure_and_clean create mode 100644 testsuite/inputs/directories_project create mode 100644 testsuite/inputs/relocatable create mode 100644 testsuite/sources/program_1/Makefile create mode 100644 testsuite/sources/program_1/build_testcase.gpr create mode 100644 testsuite/sources/program_1/generated_files create mode 100644 testsuite/sources/program_1/testcase.adb create mode 100644 testsuite/test_directories.gpr diff --git a/testsuite/inputs/build_with_Gnatmake b/testsuite/inputs/build_with_Gnatmake new file mode 100644 index 0000000..124f632 --- /dev/null +++ b/testsuite/inputs/build_with_Gnatmake @@ -0,0 +1,4 @@ +expect_configuration +expect_generated_files +common_setup +GNAT_BUILDER=gnatmake make diff --git a/testsuite/inputs/configure_and_build b/testsuite/inputs/configure_and_build new file mode 100644 index 0000000..3b4a060 --- /dev/null +++ b/testsuite/inputs/configure_and_build @@ -0,0 +1,8 @@ +prefix=/usr +libdir=/usr/lib64 +frobnicate=true +expect_configuration always +expect_generated_files +common_setup +make configure prefix="${prefix}" libdir="${libdir}" frobnicate=true +make diff --git a/testsuite/inputs/configure_and_clean b/testsuite/inputs/configure_and_clean new file mode 100644 index 0000000..ba9b640 --- /dev/null +++ b/testsuite/inputs/configure_and_clean @@ -0,0 +1,13 @@ +expect_configuration always +common_setup +make configure bindir='${prefix}/special' +make clean +expected='bindir = ${prefix}/special' +conf=$(make show_configuration --no-print-directory) +if [ "${conf}" != "${expected}" ] ; then + echo "Expected configuration:" >&2 + echo "${expected}" >&2 + echo "Configuration found:" >&2 + echo "${conf}" >&2 + exit 1 +fi diff --git a/testsuite/inputs/directories_project b/testsuite/inputs/directories_project new file mode 100644 index 0000000..128e893 --- /dev/null +++ b/testsuite/inputs/directories_project @@ -0,0 +1,5 @@ +prefix=/opt/comfignat_test +expect_configuration +expect_generated_files +common_setup +make dirgpr="${dirgpr}" gprdir="${gprdir}" diff --git a/testsuite/inputs/relocatable b/testsuite/inputs/relocatable new file mode 100644 index 0000000..a060390 --- /dev/null +++ b/testsuite/inputs/relocatable @@ -0,0 +1,4 @@ +expect_configuration +expect_generated_files +common_setup +make relocatable_package=true diff --git a/testsuite/library b/testsuite/library index c665c71..4482215 100644 --- a/testsuite/library +++ b/testsuite/library @@ -11,26 +11,6 @@ # modified is included with the above copyright notice. -# These directory variables mustn't be conveyed from Comfignat, because then -# the testsuite would rely on the same thing that it's supposed to test. -prefix=/usr/local -exec_prefix=${prefix} -datarootdir=${prefix}/share -bindir=${exec_prefix}/bin -libexecdir=${exec_prefix}/libexec -includedir=${prefix}/include -libdir=${exec_prefix}/lib -alidir=${libdir} -gprdir=${datarootdir}/gpr -stagedir=stage -stage_bindir=${stagedir}${bindir} -stage_libexecdir=${stagedir}${libexecdir} -stage_includedir=${stagedir}${includedir} -stage_libdir=${stagedir}${libdir} -stage_alidir=${stagedir}${alidir} -stage_gprdir=${stagedir}${gprdir} - - expect_configuration () { # If "always" is passed, the testcase is always expected to leave a # configuration file. If this is called without "always", a configuration @@ -45,6 +25,26 @@ expect_generated_files () { # The testcase is expected to generate files which are listed in the file # generated_files. The list is whitespace-separated and may contain shell # variable references. + + # These directory variables mustn't be conveyed from Comfignat, because then + # the testsuite would rely on the same thing that it's supposed to test. + prefix=${prefix:-/usr/local} + exec_prefix=${exec_prefix:-${prefix}} + datarootdir=${datarootdir:-${prefix}/share} + bindir=${bindir:-${exec_prefix}/bin} + libexecdir=${libexecdir:-${exec_prefix}/libexec} + includedir=${includedir:-${prefix}/include} + libdir=${libdir:-${exec_prefix}/lib} + alidir=${alidir:-${libdir}} + gprdir=${gprdir:-${datarootdir}/gpr} + stagedir=stage + stage_bindir=${stagedir}${bindir} + stage_libexecdir=${stagedir}${libexecdir} + stage_includedir=${stagedir}${includedir} + stage_libdir=${stagedir}${libdir} + stage_alidir=${stagedir}${alidir} + stage_gprdir=${stagedir}${gprdir} + for file in $(cat "${srcdir}"/generated_files) ; do # Expand variables in the string to get the pathname. eval file="${file}" diff --git a/testsuite/run_tests b/testsuite/run_tests index f440f8d..06e9c4c 100755 --- a/testsuite/run_tests +++ b/testsuite/run_tests @@ -21,6 +21,8 @@ set -e outer_srcdir="$1" outer_builddir="$2" +testsuitedir="${outer_srcdir}"/testsuite + # Initialize counters. passed=0 failed=0 @@ -36,6 +38,7 @@ export file_list # absolute pathname of list of expected files export srcdir # testcase's source directory relative to testrundir export builddir # testcase's build directory relative to testrundir export relative_builddir # testcase's build directory relative to srcdir +export dirgpr="${testsuitedir}"/test_directories.gpr pass () { @@ -61,9 +64,9 @@ fail () { # Clean out any old test results. rm -Rf "${outer_builddir}"/testruns -for source_directory in "${outer_srcdir}"/testsuite/sources/* ; do - for location_file in "${outer_srcdir}"/testsuite/locations/* ; do - for input_script in "${outer_srcdir}"/testsuite/inputs/* ; do +for source_directory in "${testsuitedir}"/sources/* ; do + for location_file in "${testsuitedir}"/locations/* ; do + for input_script in "${testsuitedir}"/inputs/* ; do # Compose the name of the combined testcase. test_name=$(basename "${source_directory}")+$(basename "${location_file}")+$(basename "${input_script}") @@ -87,7 +90,7 @@ for source_directory in "${outer_srcdir}"/testsuite/sources/* ; do # Run the testcase in a child process. # The child process first loads the function library and then runs the # input script. - if sh -e -c ". ${outer_srcdir}/testsuite/library; . ${input_script}" >output 2>&1 ; then + if sh -e -c ". ${testsuitedir}/library; . ${input_script}" >output 2>&1 ; then # Check that the expected files and no others are present. # Sort the list of expected files and remove duplicates. diff --git a/testsuite/sources/library_1/build_testcase.gpr.gp b/testsuite/sources/library_1/build_testcase.gpr.gp index abfa866..5861788 100644 --- a/testsuite/sources/library_1/build_testcase.gpr.gp +++ b/testsuite/sources/library_1/build_testcase.gpr.gp @@ -1,4 +1,4 @@ --- Comfignat's testsuite +-- part of Comfignat's testsuite -- Copyright 2014 B. Persson, Bjorn@Rombobeorn.se -- -- This material is provided as is, with absolutely no warranty expressed diff --git a/testsuite/sources/library_1/generated_files b/testsuite/sources/library_1/generated_files index 2acba75..525613f 100644 --- a/testsuite/sources/library_1/generated_files +++ b/testsuite/sources/library_1/generated_files @@ -1,7 +1,7 @@ build_testcase.gpr comfignat.gpr ${stage_includedir}/testcase/testcase.ads -${stage_libdir}/libtestcase.so.1 +${stage_libdir}/libtestcase${frobnicate:+-frob}.so.1 ${stage_libdir}/libtestcase.so ${stage_alidir}/testcase/testcase.ali ${stage_gprdir}/testcase.gpr diff --git a/testsuite/sources/program_1/Makefile b/testsuite/sources/program_1/Makefile new file mode 100644 index 0000000..c5f8e5c --- /dev/null +++ b/testsuite/sources/program_1/Makefile @@ -0,0 +1,16 @@ +# part of Comfignat's testsuite +# Copyright 2014 B. Persson, Bjorn@Rombobeorn.se +# +# This material is provided as is, with absolutely no warranty expressed +# or implied. Any use is at your own risk. +# +# Permission is hereby granted to use or copy this testsuite +# for any purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is granted, +# provided the above notices are retained, and a notice that the code was +# modified is included with the above copyright notice. + + +include comfignat.mk + +build_GPRs = build_testcase.gpr diff --git a/testsuite/sources/program_1/build_testcase.gpr b/testsuite/sources/program_1/build_testcase.gpr new file mode 100644 index 0000000..912115b --- /dev/null +++ b/testsuite/sources/program_1/build_testcase.gpr @@ -0,0 +1,20 @@ +-- part of Comfignat's testsuite +-- Copyright 2014 B. Persson, Bjorn@Rombobeorn.se +-- +-- This material is provided as is, with absolutely no warranty expressed +-- or implied. Any use is at your own risk. +-- +-- Permission is hereby granted to use or copy this testsuite +-- for any purpose, provided the above notices are retained on all copies. +-- Permission to modify the code and to distribute modified code is granted, +-- provided the above notices are retained, and a notice that the code was +-- modified is included with the above copyright notice. + + +with "comfignat.gpr"; + +standard project Build_Testcase is + for Main use ("testcase"); + for Object_Dir use Comfignat.Objdir; + for Exec_Dir use Comfignat.Stage_Bindir; +end Build_Testcase; diff --git a/testsuite/sources/program_1/generated_files b/testsuite/sources/program_1/generated_files new file mode 100644 index 0000000..cfccc4c --- /dev/null +++ b/testsuite/sources/program_1/generated_files @@ -0,0 +1,2 @@ +comfignat.gpr +${stage_bindir}/testcase diff --git a/testsuite/sources/program_1/testcase.adb b/testsuite/sources/program_1/testcase.adb new file mode 100644 index 0000000..4121845 --- /dev/null +++ b/testsuite/sources/program_1/testcase.adb @@ -0,0 +1,20 @@ +-- part of Comfignat's testsuite +-- Copyright 2014 B. Persson, Bjorn@Rombobeorn.se +-- +-- This material is provided as is, with absolutely no warranty expressed +-- or implied. Any use is at your own risk. +-- +-- Permission is hereby granted to use or copy this testsuite +-- for any purpose, provided the above notices are retained on all copies. +-- Permission to modify the code and to distribute modified code is granted, +-- provided the above notices are retained, and a notice that the code was +-- modified is included with the above copyright notice. + + +with Ada.Calendar; use Ada.Calendar; +with Ada.Text_IO; use Ada.Text_IO; + +procedure Testcase is +begin + Put_Line(Year(Clock)'Img); +end Testcase; diff --git a/testsuite/test_directories.gpr b/testsuite/test_directories.gpr new file mode 100644 index 0000000..e402a25 --- /dev/null +++ b/testsuite/test_directories.gpr @@ -0,0 +1,9 @@ +abstract project Test_Directories is + Hardware_Platform := "multivac"; + Bindir := "/opt/comfignat_test/bin"; + Libexecdir := "/opt/comfignat_test/libexec"; + Includedir := "/opt/comfignat_test/include"; + Libdir := "/opt/comfignat_test/lib"; + Alidir := Libdir; + Archincludedir := Libdir & "/include"; +end Test_Directories; -- cgit v1.2.3