-- 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;