1 /* Test the gnulib getprogname module.
2 Copyright (C) 2016-2025 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
25 # define STREQ(a, b) (strncmp (a, b, 14) == 0)
27 # define STREQ(a, b) (strcmp (a, b) == 0)
33 char const *p
= getprogname ();
35 /* libtool creates a temporary executable whose name is sometimes prefixed
36 with "lt-" (depends on the platform). But the name of the temporary
37 executable is a detail that should not be visible to the end user and to
38 the test suite. Remove this "lt-" prefix here. */
39 if (str_startswith (p
, "lt-"))
42 /* Note: You can make this test fail
43 a) by running it on a case-insensitive file system (such as on Windows,
44 Cygwin, or on Mac OS X with a case-insensitive HFS+ file system),
45 with an invocation that contains upper case characters, e.g.
47 b) by hardlinking or symlinking it to a different name (e.g. test-foo)
48 and invoking it through that name.
49 That's not the intended use. The Makefile always invokes it as
50 'test-getprogname${EXEEXT}'. */
51 #if defined __CYGWIN__
52 /* The Cygwin getprogname() function strips the ".exe" suffix. */
53 assert (STREQ (p
, "test-getprogname"));
55 assert (STREQ (p
, "test-getprogname" EXEEXT
));