diff options
author | Björn Persson <Bjorn@Rombobjörn.se> | 2025-09-05 12:12:42 +0200 |
---|---|---|
committer | Björn Persson <Bjorn@Rombobjörn.se> | 2025-09-05 12:12:42 +0200 |
commit | 140a63ae7af13b8db25237c387efabd8ba1e2325 (patch) | |
tree | 072900b437905b5ee7d4f5c7fc35933e1cb45f22 | |
parent | b3263dc7119ce5e7da4422bc48877b8b93fc187a (diff) |
Added testing of the switch variables.
-rw-r--r-- | testsuite/sources/embedding/Makefile | 28 | ||||
-rw-r--r-- | testsuite/sources/embedding/build_check_pathnames.gpr | 29 | ||||
-rw-r--r-- | testsuite/sources/embedding/check_pathnames.adb | 93 | ||||
-rw-r--r-- | testsuite/sources/embedding/generated_files | 2 |
4 files changed, 152 insertions, 0 deletions
diff --git a/testsuite/sources/embedding/Makefile b/testsuite/sources/embedding/Makefile new file mode 100644 index 0000000..696e5a8 --- /dev/null +++ b/testsuite/sources/embedding/Makefile @@ -0,0 +1,28 @@ +# part of Comfignat's testsuite +# Copyright 2025 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. + + +# This test checks that the switch variables convey directory names correctly +# to a compiled program. + + +include comfignat.mk + +build_GPRs = build_check_pathnames.gpr + +# Convey relocatable_package so check_pathnames knows whether the pathnames +# shall be absolute or relative. +options = relocatable_package + +# After check_pathnames has been built, run it to check the values. +build: + "${stage_libexecdir}/check_pathnames" diff --git a/testsuite/sources/embedding/build_check_pathnames.gpr b/testsuite/sources/embedding/build_check_pathnames.gpr new file mode 100644 index 0000000..735e354 --- /dev/null +++ b/testsuite/sources/embedding/build_check_pathnames.gpr @@ -0,0 +1,29 @@ +-- part of Comfignat's testsuite +-- Copyright 2025 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_Check_Pathnames is + for Main use ("check_pathnames"); + for Object_Dir use Comfignat.Objdir; + for Exec_Dir use Comfignat.Stage_Libexecdir; + + Relocatable := external("relocatable_package"); + + package Compiler is + for Default_Switches ("Ada") use + ("-Wall", "-Wextra", "-gnatwa", "-gnatVa", + "-gnateDRelocatable=" & Relocatable) & + Comfignat.All_Dir_Switches; + end Compiler; +end Build_Check_Pathnames; diff --git a/testsuite/sources/embedding/check_pathnames.adb b/testsuite/sources/embedding/check_pathnames.adb new file mode 100644 index 0000000..9da0cf4 --- /dev/null +++ b/testsuite/sources/embedding/check_pathnames.adb @@ -0,0 +1,93 @@ +-- part of Comfignat's testsuite +-- Copyright 2025 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.Text_IO; use Ada.Text_IO; +with Ada.Command_Line; use Ada.Command_Line; +with GNAT.Regexp; use GNAT.Regexp; + +procedure Check_Pathnames is + + Result : Exit_Status := Success; + + procedure Check_Pattern(Name : String; Pattern : String; Value : String) is + begin + if not Match(Value, Compile(Pattern)) then + Put_Line(Current_Error, + "Bad value of " & Name & + ": expected """ & Pattern & """, got """ & Value & '"'); + Result := Failure; + end if; + end Check_Pattern; + + procedure Check_Relocatable(Name : String; Value : String) is + Relocatable : constant Boolean := $Relocatable; + begin + if (Value(Value'First) = '/') = Relocatable then + Put_Line(Current_Error, + Name & " is not " & + (if Relocatable then "relative" else "absolute") & + ": """ & Value & '"'); + Result := Failure; + end if; + end Check_Relocatable; + + Bindir : constant String := $Bindir; + Libexecdir : constant String := $Libexecdir; + Datadir : constant String := $Datadir; + Sysconfdir : constant String := $Sysconfdir; + Statedir : constant String := $Statedir; + Cachedir : constant String := $Cachedir; + Logdir : constant String := $Logdir; + Runstatedir : constant String := $Runstatedir; + Lockdir : constant String := $Lockdir; + Libdir : constant String := $Libdir; + Localedir : constant String := $Localedir; + Mandir : constant String := $Mandir; + Infodir : constant String := $Infodir; + Miscdocdir : constant String := $Miscdocdir; + +begin + -- Check those parts of the pathnames that are unchanged in all of + -- Comfignat's tests. + Check_Pattern("Bindir", ".+/bin", Bindir); + Check_Pattern("Libexecdir", ".+/libexec", Libexecdir); + Check_Pattern("Datadir", ".+/share", Datadir); + Check_Pattern("Sysconfdir", ".+/etc", Sysconfdir); + Check_Pattern("Statedir", ".*/var/lib", Statedir); + Check_Pattern("Cachedir", ".*/var/cache", Cachedir); + Check_Pattern("Logdir", ".*/var/log", Logdir); + Check_Pattern("Runstatedir", "/run", Runstatedir); + Check_Pattern("Lockdir", "/run/lock", Lockdir); + Check_Pattern("Libdir", ".+lib.*", Libdir); + Check_Pattern("Localedir", ".+/locale", Localedir); + Check_Pattern("Mandir", ".+/man", Mandir); + Check_Pattern("Infodir", ".+/info", Infodir); + Check_Pattern("Miscdocdir", ".+/doc", Miscdocdir); + + -- All except Runstatedir and Lockdir shall be relative pathnames in a + -- relocatable build. + Check_Relocatable("Bindir", Bindir); + Check_Relocatable("Libexecdir", Libexecdir); + Check_Relocatable("Datadir", Datadir); + Check_Relocatable("Sysconfdir", Sysconfdir); + Check_Relocatable("Statedir", Statedir); + Check_Relocatable("Cachedir", Cachedir); + Check_Relocatable("Logdir", Logdir); + Check_Relocatable("Libdir", Libdir); + Check_Relocatable("Localedir", Localedir); + Check_Relocatable("Mandir", Mandir); + Check_Relocatable("Infodir", Infodir); + Check_Relocatable("Miscdocdir", Miscdocdir); + + Set_Exit_Status(Result); +end Check_Pathnames; diff --git a/testsuite/sources/embedding/generated_files b/testsuite/sources/embedding/generated_files new file mode 100644 index 0000000..af67a6a --- /dev/null +++ b/testsuite/sources/embedding/generated_files @@ -0,0 +1,2 @@ +comfignat.gpr +${stage_libexecdir}/check_pathnames |