annotate tests/test-getprogname.c @ 40186:8964917f9574

autoupdate
author Karl Berry <karl@freefriends.org>
date Mon, 18 Feb 2019 08:02:49 -0800
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18404
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
1 /* Test the gnulib getprogname module.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2016-2019 Free Software Foundation, Inc.
18404
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
3
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
7 (at your option) any later version.
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
8
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
12 GNU General Public License for more details.
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
13
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18404
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
16
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
17 #include <config.h>
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
18
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
19 #include "getprogname.h"
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
20 #include <string.h>
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
21 #include <assert.h>
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
22
18482
7016824b7f88 getprogname: port to HP-UX
John David Anglin <dave.anglin@bell.net>
parents: 18462
diff changeset
23 #ifdef __hpux
7016824b7f88 getprogname: port to HP-UX
John David Anglin <dave.anglin@bell.net>
parents: 18462
diff changeset
24 # define STREQ(a, b) (strncmp (a, b, 14) == 0)
7016824b7f88 getprogname: port to HP-UX
John David Anglin <dave.anglin@bell.net>
parents: 18462
diff changeset
25 #else
7016824b7f88 getprogname: port to HP-UX
John David Anglin <dave.anglin@bell.net>
parents: 18462
diff changeset
26 # define STREQ(a, b) (strcmp (a, b) == 0)
7016824b7f88 getprogname: port to HP-UX
John David Anglin <dave.anglin@bell.net>
parents: 18462
diff changeset
27 #endif
18404
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
28
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
29 int
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
30 main (void)
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
31 {
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
32 char const *p = getprogname ();
18461
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
33
18462
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
34 /* libtool creates a temporary executable whose name is sometimes prefixed
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
35 with "lt-" (depends on the platform). But the name of the temporary
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
36 executable is a detail that should not be visible to the end user and to
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
37 the test suite. Remove this "lt-" prefix here. */
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
38 if (strncmp (p, "lt-", 3) == 0)
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
39 p += 3;
b6c7fb1f9e0c getprogname tests: Avoid failure in packages that use libtool.
Bruno Haible <bruno@clisp.org>
parents: 18461
diff changeset
40
18461
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
41 /* Note: You can make this test fail
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
42 a) by running it on a case-insensitive file system (such as on Windows,
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
43 Cygwin, or on Mac OS X with a case-insensitive HFS+ file system),
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
44 with an invocation that contains upper case characters, e.g.
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
45 test-GETPROGNAME,
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
46 b) by hardlinking or symlinking it to a different name (e.g. test-foo)
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
47 and invoking it through that name.
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
48 That's not the intended use. The Makefile always invokes it as
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
49 'test-getprogname${EXEEXT}'. */
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
50 #if defined __CYGWIN__
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
51 /* The Cygwin getprogname() function strips the ".exe" suffix. */
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
52 assert (STREQ (p, "test-getprogname"));
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
53 #else
18408
cd94b92d051c getprogname-tests: work also when EXEEXT is nonempty
Jim Meyering <meyering@fb.com>
parents: 18404
diff changeset
54 assert (STREQ (p, "test-getprogname" EXEEXT));
18461
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
55 #endif
66921c9564c8 getprogname: Fix test failure on Cygwin. Comments.
Bruno Haible <bruno@clisp.org>
parents: 18408
diff changeset
56
18404
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
57 return 0;
ee1b22cf7503 getprogname: port to systems with __argv (mingw, msvc)
Jim Meyering <meyering@fb.com>
parents:
diff changeset
58 }