Commit Graph

31 Commits

Author SHA1 Message Date
Jason Francis
04b683c34f gfileinfo: add file_path methods for language bindings
Including some tests by Philip Withnall.
2023-07-21 21:24:50 +01:00
Simon McVittie
32b0dd24e3 Add a SPDX LicenseRef for the license historically used for tests
Some of GLib's unit tests are under an apparently GLib-specific
permissive license, vaguely similar to the BSD/MIT family but with the
GPL's lack-of-warranty wording. This is not on SPDX's list of
well-known licenses, so we need to use a custom license name prefixed
with LicenseRef if we want to represent this in SPDX/REUSE syntax.

Most of the newer tests seem to be licensed under LGPL-2.1-or-later
instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:34:19 +00:00
Ross Burton
ed3998b390 gio/tests/g-file-info: don't assume million-in-one events don't happen
The access and creation time tests create a file, gets the time in
seconds, then gets the time in microseconds and assumes that the
difference between the two has to be above 0.

As rare as this may be, it can happen:

$ stat g-file-info-test-50A450 -c %y
2021-07-06 18:24:56.000000767 +0100

Change the test to simply assert that the difference not negative to
handle this case.

This is the same fix as 289f8b, but that was just modification time.

Signed-off-by: Ross Burton <ross.burton@arm.com>
2022-10-20 14:41:56 +01:00
Alyssa Ross
7c74fe4c1d
tests: skip based on g_file_info_has_attribute
Per review request.  Matches the style for the newly introduced skip
check in test_g_file_info_access_time.
2022-09-14 13:21:53 +00:00
Alyssa Ross
7162b3c496
tests: skip g-file-info test if atime unsupported
For example, g_file_query_info will not be able to determine access
time for files on ZFS with atime=off.
2022-09-14 13:21:39 +00:00
madmurphy
b295c53769 gfileinfo: Implement xattr attribute removal
Fixes: #1187
2022-07-26 07:58:32 +00:00
Philip Withnall
4282f22102 tests: Fix leaks in new GDateTime file info tests
From b7b10cc7e0. My fault!

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-01 15:19:59 +01:00
Philip Withnall
18c0088678 tests: Fix a memory leak when abandoning a file creation time test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-05-27 17:45:03 +01:00
Philip Withnall
b7b10cc7e0 tests: Add additional tests for nanosecond precision file timestamps
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #369
2022-05-27 17:45:03 +01:00
Marc-André Lureau
89539d9ae0 gio/tests: GStatBuf.st_size is 64 bits on win64
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 15:38:47 +04:00
Ross Burton
289f8be1b3 gio/tests/g-file-info: don't assume million-in-one events don't happen
The modification time test creates a file, gets the modification time in
seconds, then gets the modification time in microseconds and assumes
that the difference between the two has to be above 0.

As rare as this may be, it can happen:

$ stat g-file-info-test-50A450 -c %y
2021-07-06 18:24:56.000000767 +0100

Change the test to simply assert that the difference not negative to
handle this case.
2021-07-06 19:32:54 +01:00
Abanoub Ghadban
1bdfc1a36b gfileinfo: Add tests for get and set {access,creation}_date_time APIs 2021-03-28 23:07:39 +02:00
Philip Withnall
f4607def16 tests: Drop unnecessary volatile qualifiers from tests
These variables were already (correctly) accessed atomically. The
`volatile` qualifier doesn’t help with that.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #600
2020-11-20 14:40:19 +00:00
Philip Withnall
b80b864fe3 tests: Add a test for getting/setting xattrs on a local file
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #422
2020-07-24 23:43:01 +01:00
Руслан Ижбулатов
d09a6690e4 W32: add a test for setting file mtime 2020-01-30 01:33:09 +00:00
Philip Withnall
475b9b5f7c tests: Add tests for GFileInfo modification time
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-05 17:13:08 +01:00
Philip Withnall
b99cdf56dc tests: Use g_assert_*() rather than g_assert() in g-file-info test
They provide more detailed failure messages, and aren’t compiled out
when building with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-05 17:13:08 +01:00
Руслан Ижбулатов
19608e36d2 Straighten up the GFileType vs symlinks on Windows situation
On Windows NTFS symlinks are implemented as reparse points,
which are special kinds of files *or directories*. A directory
symlink should link to a directory. A file symlink should link
to a file. Mismatching (such as a file symlink pointing to a
directory) produces symlinks that simply do not function.

Therefore GFileType file vs directory vs symlink distinction is
too simplistic to correctly represent a NTFS filesystem object type.

Since we can't turn back time and choose a better way of representing
file types, make GFileType reflect the file vs directory type on
Windows, meaning that all FS objects are either files or
directories (or shortcuts, which are also files), but never symlinks.

A test for symlinkiness will have to be made via GFileInfo - it
tracks symlinkiness separately from file/directory/whatever.
2018-10-10 08:20:44 +00:00
Руслан Ижбулатов
ad3694b82a Enable GIO tests on Windows
1) Remove the non-Windows-only condition for subdir('tests').
2) Add libiphlpapi, libws2_32 and libsecur32 deps, needed for W32 tests.
3) Remove the -no-undefined argument (gcc doesn't understand it,
   it *does* understand -Wl,-no-undefined; either way, the test
   compiles without this argument just fine; maybe meson adds it
   by itself - you can hardly build shared modules without it).
4) Add or fix a number of includes
5) Disable gdbus-objectmanager tests when building with MSVC
   (right now these tests don't work on Windows anyway, so the fact
    that MSVC can't even build them properly is irrelevant;
    most likely gdbus-codegen needs changes to put _GLIB_EXTERN
    before each function)
2018-09-12 15:42:11 +00:00
Руслан Ижбулатов
157dfc8aae test_internal_enhanced_stdio: don't use g_assert()
g_assert() can be disabled, use more specific assertion macros.
2018-09-12 14:35:20 +00:00
Руслан Ижбулатов
c24d3b0fc3 W32: extend the g-file-info test with new DOS attributes 2018-09-12 14:35:18 +00:00
Руслан Ижбулатов
53bd6a359f W32: Add a stat() implementation for private use
This commit adds new W32-only functions to gstdio.c,
and a new header file, gstdioprivate.h.
These functions are:
g_win32_stat_utf8()
g_win32_lstat_utf8()
g_win32_fstat()
and they fill a private structure, GWin32PrivateStat,
which has all the fields that normal stat has, as well as some
extras.

These functions are then used throughout glib and gio to get better
data about the system. Specifically:
* Full, 64-bit size, guaranteed (g_stat() is forced to use 32-bit st_size)
* Full, 64-bit file identifier (st_ino is 0 when normal stat() is used, and still is)
* W32 File attributes (which stat() doesn't report); in particular, this allows
  symlinks to be correctly identified
* Full, 64-bit time, guaranteed (g_stat() uses 32-bit st_*time on 32-bit Windows)
* Allocated file size (as a W32 replacement for the missing st_blocks)

st_mode remains unchanged (thus, no S_ISLNK), so when these are given back to
glib users (via g_stat(), for example, which is now implemented by calling g_win32_stat_utf8),
this field does not contain anything unexpected.

g_lstat() now calls g_win32_lstat_utf8(), which works on symlinks the way it's supposed to.

Also adds the g_win32_readlink_utf8() function, which behaves like readlink()
(including its inability to return 0-terminated strings and inability to say how large
the output buffer should be; these limitations are purely for compatibility with
existing glib code).

Thus, symlink support should now be much better, although far from being complete.

A new W32-only test in gio/tests/file.c highlights the following features:
* allocated size
* 64-bit time
* unique file IDs

https://bugzilla.gnome.org/show_bug.cgi?id=788180
2017-11-01 12:46:38 +00:00
Matthias Clasen
c40e0b59da Improve GFileAttributeMatcher test coverage 2013-06-02 01:43:13 -04:00
Ryan Lortie
1dc774a653 Remove g_type_init() calls
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().

Remove those uses, as they are no longer required.

https://bugzilla.gnome.org/show_bug.cgi?id=686161
2012-10-16 09:39:24 -04:00
Christian Persch
d5d277dccf Plug a mem leak in g-file-info test
==2395== 64 bytes in 1 blocks are definitely lost in loss record 381 of 407
==2395==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
==2395==    by 0x4005C66: realloc (vg_replace_malloc.c:476)
==2395==    by 0x40571A5: g_realloc (gmem.c:181)
==2395==    by 0x401D670: g_ptr_array_maybe_expand (garray.c:968)
==2395==    by 0x401DD0B: g_ptr_array_add (garray.c:1225)
==2395==    by 0x4199AA9: g_file_info_list_attributes (gfileinfo.c:646)
==2395==    by 0x80491CE: test_g_file_info (g-file-info.c:76)

==2395== 132 (64 direct, 68 indirect) bytes in 1 blocks are definitely lost in loss record 396 of 407
==2395==    at 0x4005BDC: malloc (vg_replace_malloc.c:195)
==2395==    by 0x4005C66: realloc (vg_replace_malloc.c:476)
==2395==    by 0x40571A5: g_realloc (gmem.c:181)
==2395==    by 0x401D670: g_ptr_array_maybe_expand (garray.c:968)
==2395==    by 0x401DD0B: g_ptr_array_add (garray.c:1225)
==2395==    by 0x4199A82: g_file_info_list_attributes (gfileinfo.c:642)
==2395==    by 0x80492B7: test_g_file_info (g-file-info.c:86)

Bug #628331.
2010-09-03 15:37:08 -04:00
Matthias Clasen
5694ab7642 Revert "Move gio tests from gio/tests/ to tests/gio/"
This reverts commit 2262d76b33.

Move GIO tests back to where they belong.
2009-07-05 22:49:24 -04:00
Benjamin Otte
2262d76b33 Move gio tests from gio/tests/ to tests/gio/
This avoids getting tests built every time when working on libgio and
running make in the gio/ directory.
2009-07-01 19:03:19 +02:00
Michael Natterer
03a5797a62 don't define G_DISABLE_SINGLE_INCLUDES, it's in the global CPPFLAGS now.
2008-05-28  Michael Natterer  <mitch@imendio.com>

	* Makefile.am: don't define G_DISABLE_SINGLE_INCLUDES, it's in
	the global CPPFLAGS now.

	* tests/data-input-stream.c
	* tests/data-output-stream.c
	* tests/g-file-info.c
	* tests/g-file.c
	* tests/live-g-file.c
	* tests/memory-input-stream.c: don't include <glib/gtestutils.h>


svn path=/trunk/; revision=6954
2008-05-28 16:17:45 +00:00
Matthias Clasen
689a9e4b1a Revert the patch for bug 527214 and related changes. GTimer
is supposed to work without threads.


svn path=/trunk/; revision=6943
2008-05-27 16:00:51 +00:00
Matthias Clasen
cdc2910103 Make tests work
svn path=/trunk/; revision=6935
2008-05-26 05:57:09 +00:00
Alexander Larsson
b784923e9c Allow UTF-8 in file:// parse names.
2008-01-22  Alexander Larsson  <alexl@redhat.com>

        * glocalfile.c:
	Allow UTF-8 in file:// parse names.
	
        * tests/Makefile.am:
        * tests/data-input-stream.c:
        * tests/data-output-stream.c:
        * tests/g-file-info.c:
        * tests/g-file.c:
	Added a bunch of tests from Tomas Bzatek


svn path=/trunk/; revision=6351
2008-01-22 09:13:28 +00:00