summaryrefslogtreecommitdiff
path: root/tests/test-canonicalize.c
Commit message (Collapse)AuthorAgeFilesLines
* canonicalize[-lgpl] tests: Add more tests.Bruno Haible2021-01-171-1/+46
| | | | | * tests/test-canonicalize.c (main): Add detailed tests for // handling. * tests/test-canonicalize-lgpl.c (main): Likewise.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* canonicalize, canonicalize-lgpl: fix symlink bugPaul Eggert2020-12-241-11/+25
| | | | | | | | | | | | | | | | | | | Problem reported by Adhemerval Zanella in: https://lists.gnu.org/r/bug-gnulib/2020-12/msg00155.html * lib/canonicalize-lgpl.c, lib/canonicalize.c: (suffix_requires_dir_check, dir_check): New functions. (GCC_BOGUS_WRETURN_LOCAL_ADDR): New macro, to put the diagnostic closer to the related GCC diagnostics. * lib/canonicalize-lgpl.c (realpath_stk): * lib/canonicalize.c (canonicalize_file_mode_stk): Use them to fix a bug with .../symlink-to-regular-file/ etc. * lib/canonicalize-lgpl.c (__stat) [!_LIBC]: New macro. (realpath_stk): New function, with the contents of the old __realpath and a new scratch buffer arg. This is needed to pacify GCC 10.1, as canonicalize.c is already doing. (__realpath): Use it. * tests/test-canonicalize-lgpl.c, tests/test-canonicalize.c: Add test cases for the bugs.
* test-canonicalize: avoid an unused function warningPádraig Brady2020-02-041-1/+4
| | | | | | | | * tests/test-canonicalize.c: Protect the inclusion of null-ptr.h with the same guard as that used to protect usage of the null_ptr function, so that one doesn't get a -Wunused warning about the function being defined but unused. * tests/test-canonicalize-lgpl.c: Likewise.
* tests: Avoid GCC over-optimization caused by _GL_ARG_NONNULL attributes.Bruno Haible2020-01-051-0/+17
| | | | | | | | | | | | | | | | | Reported by Jim Meyering in <https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00040.html>. * lib/stdlib.in.h (GNULIB_defined_canonicalize_file_name): New macro. (GNULIB_defined_ptsname_r): New macro. * tests/test-canonicalize.c (_GL_ARG_NONNULL): Define to empty. (main): Disable the NULL argument test if canonicalize_file_name does not come from gnulib. * tests/test-canonicalize-lgpl.c (_GL_ARG_NONNULL): Define to empty. (main): Disable the NULL argument test if canonicalize_file_name does not come from gnulib. * tests/test-ptsname_r.c (_GL_ARG_NONNULL): Define to empty. (test_errors): Disable the NULL argument test if ptsname_r does not come from gnulib.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* tests: Avoid compiler warning about uses of null_ptr.Bruno Haible2017-03-041-6/+2
| | | | | | | | | | | | | | * tests/null-ptr.h: New file. * tests/test-canonicalize.c: Include null-ptr.h. (null_ptr): Remove function. * tests/test-canonicalize-lgpl.c: Likewise. * tests/test-memmem.c: Likewise. * tests/test-ptsname_r.c: Likewise. * modules/canonicalize-tests (Files): Add tests/null-ptr.h. * modules/canonicalize-lgpl-tests: Likewise. * modules/memmem-tests: Likewise. * modules/ptsname_r-tests: Likewise. Reported by Jim Meyering.
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* canonicalize: add support for not resolving symlinksPádraig Brady2011-12-301-0/+12
| | | | | | | | | | | | | | | | | This will initially be used by a new coreutils realpath command. * lib/canonicalize.h: Add the CAN_NOLINKS flag to indicate we don't want to follow symlinks. Also provide CAN_MODE_MASK to aid setting these existing mutually exclusive values. * lib/canonicalize.c (canonicalize_filename_mode): Extract the flags from can_mode parameter, which are currently just used to select between stat() and lstat(). Also ensure that mutually exclusive values are flagged immediately as invalid. * tests/test-canonicalize.c: Verify symlinks are not followed, and that invalid flag combinations are diagnosed.
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-1/+1
| | | | Run the new "make update-copyright" rule.
* tests: silence warning about system returnEric Blake2010-02-011-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Silence a compiler warning for platforms that mark system() with attribute warn_unused_result. * tests/test-areadlink-with-size.c (main): Ignore system result. * tests/test-areadlink.c (main): Likewise. * tests/test-areadlinkat-with-size.c (main): Likewise. * tests/test-areadlinkat.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-chown.c (main): Likewise. * tests/test-fchownat.c (main): Likewise. * tests/test-fdutimensat.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-futimens.c (main): Likewise. * tests/test-lchown.c (main): Likewise. * tests/test-link.c (main): Likewise. * tests/test-linkat.c (main): Likewise. * tests/test-lstat.c (main): Likewise. * tests/test-mkdir.c (main): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-mkfifo.c (main): Likewise. * tests/test-mkfifoat.c (main): Likewise. * tests/test-mknod.c (main): Likewise. * tests/test-readlink.c (main): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-rename.c (main): Likewise. * tests/test-renameat.c (main): Likewise. * tests/test-rmdir.c (main): Likewise. * tests/test-symlink.c (main): Likewise. * tests/test-symlinkat.c (main): Likewise. * tests/test-unlink.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-utimens.c (main): Likewise. * tests/test-utimensat.c (main): Likewise. * modules/areadlink-tests (Depends-on): Add ignore-value. * modules/areadlink-with-size-tests (Depends-on): Likewise. * modules/areadlinkat-tests (Depends-on): Likewise. * modules/areadlinkat-with-size-tests (Depends-on): Likewise. * modules/canonicalize-lgpl-tests (Depends-on): Likewise. * modules/canonicalize-tests (Depends-on): Likewise. * modules/chown-tests (Depends-on): Likewise. * modules/fdutimensat-tests (Depends-on): Likewise. * modules/futimens-tests (Depends-on): Likewise. * modules/lchown-tests (Depends-on): Likewise. * modules/link-tests (Depends-on): Likewise. * modules/linkat-tests (Depends-on): Likewise. * modules/lstat-tests (Depends-on): Likewise. * modules/mkdir-tests (Depends-on): Likewise. * modules/mkfifo-tests (Depends-on): Likewise. * modules/mkfifoat-tests (Depends-on): Likewise. * modules/mknod-tests (Depends-on): Likewise. * modules/openat-tests (Depends-on): Likewise. * modules/readlink-tests (Depends-on): Likewise. * modules/remove-tests (Depends-on): Likewise. * modules/rename-tests (Depends-on): Likewise. * modules/renameat-tests (Depends-on): Likewise. * modules/rmdir-tests (Depends-on): Likewise. * modules/symlink-tests (Depends-on): Likewise. * modules/symlinkat-tests (Depends-on): Likewise. * modules/unlink-tests (Depends-on): Likewise. * modules/utimens-tests (Depends-on): Likewise. * modules/utimensat-tests (Depends-on): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-1/+1
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* tests: don't require debug system() to passEric Blake2009-12-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running a cross-compilation to mingw on a Linux host, but without a valid mingw rm executable, the debug-only system() call would fail. This is not fatal to the test, since the call is merely a debugging aid if a prior call to the test encountered a failure and left garbage; in general, the tests should pass and the system() call have nothing to clean in the first place. Also, the system() call only needs to happen once at startup, not once per iteration into the tests performed by .h files. * tests/test-lstat.h (test_lstat_func): Move debug cleanup... * tests/test-rmdir.h (test_rmdir_func): Likewise. * tests/test-unlink.h (test_unlink_func): Likewise. * tests/test-fstatat.c (main): ...into callers. * tests/test-lstat.c (main): Likewise. * tests/test-rmdir.c (main): Likewise. * tests/test-unlink.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-areadlink-with-size.c (main): Don't require a debug-only system call to pass, aiding cross-testing to mingw. * tests/test-areadlink.c (main): Likewise. * tests/test-areadlinkat-with-size.c (main): Likewise. * tests/test-areadlinkat.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-chown.c (main): Likewise. * tests/test-fchownat.c (main): Likewise. * tests/test-lchown.c (main): Likewise. * tests/test-fdutimensat.c (main): Likewise. * tests/test-futimens.c (main): Likewise. * tests/test-link.c (main): Likewise. * tests/test-linkat.c (main): Likewise. * tests/test-mkdir.c (main): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-mkfifo.c (main): Likewise. * tests/test-mkfifoat.c (main): Likewise. * tests/test-mknod.c (main): Likewise. * tests/test-readlink.c (main): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-rename.c (main): Likewise. * tests/test-renameat.c (main): Likewise. * tests/test-symlink.c (main): Likewise. * tests/test-symlinkat.c (main): Likewise. * tests/test-utimens.c (main): Likewise. * tests/test-utimensat.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Refactor common macros used in tests.Bruno Haible2009-12-241-12/+1
|
* New module 'arg-nonnull'. Declare which arguments expect non-NULL values.Bruno Haible2009-12-111-1/+7
|
* Use spaces for indentation, not tabs.Bruno Haible2009-12-101-10/+10
|
* tests: avoid several compiler warningsEric Blake2009-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tests/test-getcwd.c (main): Avoid buffer underflow. * tests/test-getdate.c (main): String literals are not safe with putenv, so use setenv. Declare unused argument. * modules/getdate-tests (Depends-on): Add setenv. * tests/test-argv-iter.c (main): Declare unused argument. Avoid problems with string literals in char *. * tests/test-hash.c (main): Avoid shadowing declaration. (insert_new): Treat string literals as char const *. * tests/test-getopt.h (test_getopt): Likewise. (getopt_loop): Alter types to minimize casting elsewhere. * tests/test-getopt_long.h (test_getopt_long, getopt_long_loop) (test_getopt_long_posix): Likewise. (do_getopt_long): Add wrapper to minimize casting. * tests/test-atexit.c (clear_temp_file): Use void. * tests/test-areadlink-with-size.c (main): Declare unused arguments. * tests/test-areadlink.c (main): Likewise. * tests/test-areadlinkat-with-size.c (main): Likewise. * tests/test-areadlinkat.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-dirent-safer.c (main): Likewise. * tests/test-dirname.c (main): Likewise. * tests/test-dup2.c (main): Likewise. * tests/test-fchdir.c (main): Likewise. * tests/test-fcntl-h.c (main): Likewise. * tests/test-fcntl-safer.c (main): Likewise. * tests/test-fdopendir.c (main): Likewise. * tests/test-fdutimensat.c (main): Likewise. * tests/test-fflush.c (main): Likewise. * tests/test-filenamecat.c (main): Likewise. * tests/test-filevercmp.c (main): Likewise. * tests/test-fopen-safer.c (main): Likewise. * tests/test-fopen.c (main): Likewise. * tests/test-fpending.c (main): Likewise. * tests/test-fpurge.c (main): Likewise. * tests/test-freading.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-fsync.c (main): Likewise. * tests/test-futimens.c (main): Likewise. * tests/test-getndelim2.c (main): Likewise. * tests/test-gettimeofday.c (main): Likewise. * tests/test-getopt.c (main): Likewise. * tests/test-i-ring.c (main): Likewise. * tests/test-inttypes.c (main): Likewise. * tests/test-link.c (main): Likewise. * tests/test-lstat.c (main): Likewise. * tests/test-math.c (main): Likewise. * tests/test-md5.c (main): Likewise. * tests/test-memchr2.c (main): Likewise. * tests/test-memrchr.c (main): Likewise. * tests/test-mkdir.c (main): Likewise. * tests/test-mkdirat.c (main): Likewise. * tests/test-mkfifoat.c (main): Likewise. * tests/test-open.c (main): Likewise. * tests/test-openat-safer.c (main): Likewise. * tests/test-openat.c (main): Likewise. * tests/test-quotearg.c (main): Likewise. * tests/test-rawmemchr.c (main): Likewise. * tests/test-readlink.c (main): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-rename.c (main): Likewise. * tests/test-renameat.c (main): Likewise. * tests/test-rmdir.c (main): Likewise. * tests/test-sha1.c (main): Likewise. * tests/test-signal.c (main): Likewise. * tests/test-sigaction.c (main): Likewise. * tests/test-stat.c (main): Likewise. * tests/test-stat-time.c (main): Likewise. * tests/test-stddef.c (main): Likewise. * tests/test-stdint.c (main): Likewise. * tests/test-stdio.c (main): Likewise. * tests/test-stdlib.c (main): Likewise. * tests/test-strchrnul.c (main): Likewise. * tests/test-strerror.c (main): Likewise. * tests/test-string.c (main): Likewise. * tests/test-strtod.c (main): Likewise. * tests/test-strverscmp.c (main): Likewise. * tests/test-symlink.c (main): Likewise. * tests/test-symlinkat.c (main): Likewise. * tests/test-sys_stat.c (main): Likewise. * tests/test-sys_time.c (main): Likewise. * tests/test-time.c (main): Likewise. * tests/test-unistd.c (main): Likewise. * tests/test-unlink.c (main): Likewise. * tests/test-unlinkat.c (main): Likewise. * tests/test-utimens.c (main): Likewise. * tests/test-utimensat.c (main): Likewise. * tests/test-version-etc.c (main): Likewise. * tests/test-wchar.c (main): Likewise. * tests/test-wctype.c (main): Likewise. * tests/test-xprintf-posix.c (main): Likewise. * tests/test-posixtm.c (main): Likewise. (STREQ): Delete unused macro. * tests/test-linkat.c (main): Declare unused arguments. Avoid shadowed variables. * tests/test-memchr.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* maint: prefer 'file system' over 'filesystem'Eric Blake2009-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/posix-functions/fstatat.texi (fstatat): Likewise. * doc/posix-functions/lstat.texi (lstat): Likewise. * lib/file-has-acl.c (file_has_acl): Likewise. * lib/fwriteerror.c [TEST]: Likewise. * tests/test-areadlink.h (test_areadlink): Likewise. * tests/test-areadlinkat-with-size.c (main): Likewise. * tests/test-areadlinkat.c (main): Likewise. * tests/test-canonicalize-lgpl.c (main): Likewise. * tests/test-canonicalize.c (main): Likewise. * tests/test-fstatat.c (main): Likewise. * tests/test-linkat.c (main): Likewise. * tests/test-lstat.h (test_lstat_func): Likewise. * tests/test-mkdir.h (test_mkdir): Likewise. * tests/test-readlink.h (test_readlink): Likewise. * tests/test-remove.c (main): Likewise. * tests/test-rename.h (test_rename): Likewise. * tests/test-renameat.c (main): Likewise. * tests/test-rmdir.h (test_rmdir_func): Likewise. * tests/test-symlink.h (test_symlink): Likewise. * tests/test-symlinkat.c (main): Likewise. * tests/test-unlink.h (test_unlink_func): Likewise. * tests/test-unlinkat.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* symlink: use throughout gnulibEric Blake2009-09-231-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | * m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Omit symlink check. * lib/symlinkat.c (symlinkat) [!HAVE_SYMLINK]: Document why symlink is not used. * modules/symlinkat (Depends-on): Add symlink. * modules/canonicalize-lgpl-tests (Depends-on): Likewise. * modules/canonicalize-tests (Depends-on): Likewise. * modules/lstat-tests (Depends-on): Likewise. * modules/openat-tests (Depends-on): Likewise. * modules/remove-tests (Depends-on): Likewise. * modules/rmdir-tests (Depends-on): Likewise. * modules/unlink-tests (Depends-on): Likewise. * tests/test-canonicalize-lgpl.c (symlink): Delete stub. * tests/test-canonicalize.c (symlink): Likewise. * tests/test-fstatat.c (symlink): Likewise. * tests/test-lstat.c (symlink): Likewise. * tests/test-remove.c (symlink): Likewise. * tests/test-rmdir.c (symlink): Likewise. * tests/test-unlink.c (symlink): Likewise. * tests/test-unlinkat.c (symlink): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* canonicalize: in CAN_ALL_BUT_LAST, allow trailing slashEric Blake2009-09-171-0/+16
| | | | | | | | | | | Coreutils' `readlink -f foo/' should not fail if lstat("foo") gives ENOENT. * lib/canonicalize.c (canonicalize_filename_mode): Skip trailing slashes when checking if last component is missing. * tests/test-canonicalize.c (main): Test this. Signed-off-by: Eric Blake <ebb9@byu.net>
* canonicalize, canonicalize-lgpl: honor // if distinct from /Eric Blake2009-09-171-0/+38
| | | | | | | | | | | | | | | | | | * modules/canonicalize (Files): Add double-slash-root.m4. * modules/canonicalize-lgpl (Files): Likewise. * m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE) (gl_CANONICALIZE_LGPL_SEPARATE): Add dependency. * lib/canonicalize.c (DOUBLE_SLASH_IS_DISTINCT_ROOT): Provide fallback definition. (canonicalize_filename_mode): Use it to protect //. * lib/canonicalize-lgpl.c (DOUBLE_SLASH_IS_DISTINCT_ROOT) (__realpath): Likewise. * tests/test-canonicalize.c (main): Test this. * tests/test-canonicalize-lgpl.c (main): Likewise. * modules/canonicalize-tests (Depends-on): Add same-inode. * modules/canonicalize-lgpl-tests (Depends-on): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* canonicalize-lgpl: reject non-directory with trailing slashEric Blake2009-09-171-0/+56
| | | | | | | | | | | | This synchronizes glibc to gnulib. For gnulib to glibc, see: http://sources.redhat.com/bugzilla/show_bug.cgi?id=10635 * lib/canonicalize-lgpl.c (__realpath): Synchronize with glibc. * tests/test-canonicalize-lgpl.c (main): Enhance test. This catches failures in glibc 2.3.5. * tests/test-canonicalize.c (main): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* test-canonicalize: consolidate into single C programEric Blake2009-09-171-23/+125
| | | | | | | | | | | * tests/test-canonicalize.sh: Delete; move setup into... * tests/test-canonicalize.c (main): ...the program, making it easier to run in debugger. Add some tests. * modules/canonicalize-tests (Files): Remove unused file. (Depends-on): Add progname. (configure.ac, Makefile.am): Simplify. Signed-off-by: Eric Blake <ebb9@byu.net>
* Flush the standard error stream before aborting.Bruno Haible2008-04-111-1/+2
|
* Change copyright notice from GPLv2+ to GPLv3+.Bruno Haible2007-10-071-5/+4
|
* canonicalize: Avoid a false-positive cycle failure.Jim Meyering2007-09-271-0/+12
| | | | | | | | | | * modules/canonicalize (Depends-on): Add file-set and hash-triple. Sort. Remove cycle-check. * lib/canonicalize.c: Include file-set.h and hash-triple.h, not cycle-check.h. (seen_triple): New function. (canonicalize_filename_mode): Use it instead of cycle-check. * tests/test-canonicalize.c: Add a test for this bug. * tests/test-canonicalize.sh: Set up and run the test.
* Fix testing canonicalize on cygwin.Eric Blake2007-07-061-0/+131
* modules/canonicalize-lgpl-tests (test_canonicalize_lgpl_LDADD): Revert patch from 2007-06-19. * tests/test-canonicalize-lgpl.c (main): Instead, skip test when canonicalize module is also in use. * tests/test-canonicalize.c: New file. * tests/test-canonicalize.sh: Likewise. * modules/canonicalize-tests: Likewise.