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 /testsuite/sources/embedding/check_pathnames.adb | |
parent | b3263dc7119ce5e7da4422bc48877b8b93fc187a (diff) |
Added testing of the switch variables.
Diffstat (limited to 'testsuite/sources/embedding/check_pathnames.adb')
-rw-r--r-- | testsuite/sources/embedding/check_pathnames.adb | 93 |
1 files changed, 93 insertions, 0 deletions
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; |