Commit Graph

10 Commits

Author SHA1 Message Date
Philip Withnall
a4ce8399cd tests: Fix memory leaks in the g-file-info-filesystem-readonly test
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-02-20 10:43:26 +00:00
Philip Withnall
7e9585177d tests: Drop use of g_test_bug_base()
Include the base URI in the `g_test_bug()` calls instead. This resolves
inconsistencies between the old bug base (bugzilla.gnome.org) and the
new bug base (gitlab.gnome.org). It also has the advantage that the URI
passed to `g_test_bug()` is now clickable in the code editor, rather
than being split across two locations.

See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/275#note_303175

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2021-05-13 22:16:27 +01:00
Philip Withnall
55eb360c65 tests: Skip g-file-info-filesystem-readonly test if bindfs fails
bindfs is part of the setup process, so if it fails (as can happen if
the `fuse` kernel module has not been loaded — not much we can do about
that) then skip the test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 09:08:20 +00:00
Bastien Nocera
fc95385627 tests: Don't run tests that require fuse on rootless containers
If the fuse module is loaded but /dev/fuse doesn't exist, it's likely
that we're running in a rootless container, or a badly setup one, and we
won't be able to use fuse, so skip this test.

This happened on my local system using podman running as a normal user,
but this apparently works as expected in our CI[1].

[1]: https://gitlab.gnome.org/GNOME/glib/merge_requests/466
2019-12-04 14:06:23 +01:00
Will Thompson
a2f32f6a11
tests/g-file-info-filesystem-readonly: remove output stream stuff
This test is intended to verify the fix for
https://bugzilla.gnome.org/show_bug.cgi?id=787731, which was that
g_file_query_filesystem_info() would return stale information for the
mount. After replacing a read-only mount with a read-write mount, this
test used to only fail if G_FILE_ATTRIBUTE_FILESYSTEM_READONLY was TRUE
and yet the file could be opened for writing. In particular, if (due to
a test bug) the file really was still on a read-only filesystem, the
test would pass.

Now that we have fixed that bug in the test, we can make a stronger
assertion.
2018-11-13 10:34:09 +00:00
Will Thompson
5b106cdc56
tests/g-file-info-filesystem-readonly: unmount lazily
fusermount -z behaves like umount --lazy, which is documented thus:

> Detach the filesystem from the file hierarchy now, and clean up all
> references to this filesystem as soon as it is not busy anymore.

Without this, the call to `fusermount -u` often fails with:

  /usr/bin/fusermount: failed to unmount /home/wjt/src/gnome/glib/_build/dir_bindfs_mountpoint: Device or resource busy

which causes the subsequent call to bindfs to fail:

  fuse: mountpoint is not empty
  fuse: if you are sure this is safe, use the 'nonempty' mount option

It's not clear what is causing the mount to be busy. Inserting a
g_usleep (100 * 1000) before the calls to `fusermount -u` also works to
make the problem go away, but for the purposes of this test the
important point is that the mount is detached from the directory, for
which a lazy unmount is fine.

Fixes #1590.
2018-11-13 10:34:09 +00:00
Will Thompson
3821ba06b1
tests/g-file-info-filesystem-readonly: assert subcommands succeed
In practice, fusermount -u often fails:

  /usr/bin/fusermount: failed to unmount /home/wjt/src/gnome/glib/_build/dir_bindfs_mountpoint: Device or resource busy

which causes the subsequent calls to bindfs to fail:

  fuse: mountpoint is not empty
  fuse: if you are sure this is safe, use the 'nonempty' mount option

This may or may not cause the current test run to fail, but it reliably
causes a repeat run of the test to fail. This change causes the current
run to fail instead.
2018-11-13 10:34:09 +00:00
Philip Withnall
93b519b104 tests: Various minor leak fixes in the GIO tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-29 12:13:32 +01:00
Emmanuele Bassi
ac42183c33 Initialize variable
The `mount_monitor` variable is only set if the boolean
`with_mount_monitor` variable is set to TRUE, but the compiler does not
know that, so it'll warn when calling `g_clear_object()` even if the
clearing operation is gated with the same boolean.

Initializing with NULL does not cost us anything, and eliminates a
conditional branch.

https://bugzilla.gnome.org/show_bug.cgi?id=794732
2018-03-28 11:49:59 +01:00
Nelson Benítez León
32a9b88b20 gio/tests: Add testcase for bug 787731
Add testcase for function g_file_query_filesystem_info()
reporting outdated info for "filesystem::readonly" attribute
when said attribute was different in a previous mounted
partition in the same device (as GIO maintains a mounts cache
per 'st_dev' stat() member).

To trigger a mount operation, testcase uses program 'bindfs'
instead of 'mount --bind' as bindfs does not require root
privileges. And 'fusermount -u' command is used to unmount said
bindfs mount.

As a reference in Fedora, 'bindfs' is installed from 'bindfs'
package and 'fusermount' from 'fuse' package (this one is installed
by default as being part of 'System Tools' group).

The test creates a directory with a file in it, then mounts it
readonly over another directory (the mountpoint), it then checks
that g_file_query_filesystem_info() for the file in it indeed reports
"filesystem::readonly" as TRUE. Then unmounts and mounts again this
time rw (not readonly), it then checks again if g_file_query_filesystem_info()
is reporting "filesystem::readonly" as TRUE, if that's the case, it
confirms the bug by opening said file in write mode.

Testcase is only added for Unix builds.

https://bugzilla.gnome.org/show_bug.cgi?id=787731
2017-09-22 20:28:44 +05:00