Commit Graph

892 Commits

Author SHA1 Message Date
Ryan Lortie
6e0bbd8adb appinfo: Add some testcases for searching
https://bugzilla.gnome.org/show_bug.cgi?id=711557
2013-11-07 12:41:27 -05:00
Chun-wei Fan
f493114280 gio/tests: Clean up inclusion of unistd.h
Include unistd.h only on *NIX and define items as necessary on Windows,
also replace instances of ssize_t with the GLib-equivilant gssize so to fix
the build on platforms that do not have ssize_t, such as Visual C++.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-04 22:55:30 +08:00
Chun-wei Fan
39a62a064b gio/test/resources.c: Fix for Windows
We need to use g_content_type_get_mime_type() to look up the mime type of
the file from the registry on the content type that was acquired on
Windows, as g_file_info_get_content_type() does not acquire the
file mime type (unlike on *NIX).

g_content_type_get_mime_type() on *NIX is more or less an no-op as it
simply returns the g_strdup()-ed version of the passed-in content type.

This will enable the resources test to pass on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-04 10:30:57 +08:00
Ross Lagerwall
89f9615835 gio: Don't allow skipping past the end of GLocalFileInputStream
The overridden implementation of the skip method for
GLocalFileInputStream allows skipping past the end of the file which is
inconsistent with the documentation.  Prevent this by first seeking to
the end of the file and then seeking backwards from there as much as
is necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=711048
2013-11-03 06:47:33 +02:00
Xavier Claessens
e94df7cfc2 Tests: It is useless to unset "DBUS_SESSION_BUS_ADDRESS" manually
If the goal is to make sure we don't have a dbus connection, it has
to call g_test_dbus_unset() instead which is much more complete.

In this case, g_test_dbus_unset() is called already, so it should be
fine.

https://bugzilla.gnome.org/show_bug.cgi?id=697348
2013-10-29 13:42:35 -04:00
Xavier Claessens
940fa98290 Tests: add session_bus_run() and use it where possible
This is to avoid having again the subtil bug in dbus-appinfo.c:
session_bus_down() was called before g_test_run() so the test was
running on the user's dbus session.

https://bugzilla.gnome.org/show_bug.cgi?id=697348
2013-10-29 13:30:22 -04:00
Colin Walters
5280c03368 tests/gdbus-introspection: Add a less trivial test case for _IGNORE_QUALIFIED
This is distilled from PackageKit which currently aborts on startup.

https://bugzilla.gnome.org/show_bug.cgi?id=665634
2013-10-29 09:37:06 -07:00
Emmanuele Bassi
1b08980b48 gdbus-codegen: Take into consideration MAX_ALLOWED for private data
The G_ADD_PRIVATE() macro, and the auto-generated get_instance_private()
internal function, should be used conditionally depending on the maximum
allowed version of GLib, as defined by the GLIB_VERSION_MAX_ALLOWED
pre-processor symbol.

This allows generating code that can be compiled in projects that wish
to use an older API version of GLib through the use of the
GLIB_VERSION_MAX_ALLOWED symbol.

https://bugzilla.gnome.org/show_bug.cgi?id=710133
2013-10-28 12:47:16 -04:00
Stef Walter
65af7c47ff Add a request_certificate virtual method to GTlsInteraction
This allows GTlsConnection implementations to request a certificate
from the user.

Fix ups by Dan Winship <danw@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=637257
2013-10-28 09:36:26 +01:00
Christian Persch
ef57996f44 Add test for extended schemas
The test checks that the keys of the base schema are all present in
the extended schema.

https://bugzilla.gnome.org/show_bug.cgi?id=645453
2013-10-27 17:23:17 -07:00
Ryan Lortie
00b35c78f8 Add a testcase for summary/description
https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 10:42:55 -07:00
Philip Withnall
fcd2f7e639 tests: Add tests for the thumbnail verification code in GIO
This code was added for use by the G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID
file attribute, but may end up being used elsewhere (e.g. in GVfs) as well.
As it’s dealing with untrusted external files, and the non-trivial PNG file
format, this commit adds several test cases to cover valid and invalid PNG
files.

The security model for the thumbnail verification code is that the user’s
cache directory is untrusted, and potentially any PNG file which is passed
to the verifier has been manipulated arbitrarily by an attacker.

This is a follow-up to commit fe7069749f.

https://bugzilla.gnome.org/show_bug.cgi?id=709898
2013-10-24 13:55:33 -04:00
Ryan Lortie
1d1c17d9ee GMemoryOutputStream: improve seek tests
Improve test coverage for testing seeking on fixed vs. resizable
GMemoryOutputStream.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:32:13 -04:00
Ryan Lortie
fdc5cd8d9f Change semantics of seek on memory output stream
It is our intention that memory output streams should operate in two
distinct modes, depending on if a realloc function was provided or not.

In the case that we have a realloc function (resizable mode), we want
the stream to behave as if it were a file that started out empty.  In
the case that we don't have a realloc function (fixed-sized mode), we
want the stream to behave as a block device would.

To this end, we introduce two changes in functionality:

 - seeking to SEEK_END on a resizable stream will now seek to the end of
   the valid data region, not to the end of the allocated memory (which
   is really just an implementation detail)

 - seeks past the end of the allocated memory size are now permitted,
   but only on resizable streams.  The next write will grow the buffer
   (inserting zeros between).

Some tweaks to testcases were required in order not to break the build,
which indicates that this is an API break, but it seems unlikely that
anyone will be effected by these changes 'in the real world'.

Updates to documentation and further testcases are in following commits.

Based on a patch from Maciej Piechotka <uzytkownik2@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:31:27 -04:00
Ryan Lortie
358588ed2a GSubprocess win32 fixups
Note: we go out of our way not to pass a child setup function on win32
(even if it does nothing) because we get a g_warning() from gspawn if we
do so.
2013-10-21 15:24:55 -04:00
Colin Walters
ebd098155b tests/gsubprocess: Locate test child binary for installed tests too
Just use the new g_test_build_filename() rather than assuming
it's in cwd.
2013-10-17 22:39:48 +01:00
Colin Walters
9318d5a429 gsubprocess: Add UTF-8 variants of communicate()
Over many years of writing code interacting with subprocesses, a pattern
that comes up a lot is to run a child and get its output as UTF-8, to
put inside a JSON document or render in a GtkTextBuffer, etc.

It's very important to validate at the boundaries, and not say deep
inside Pango.

We could do this a bit more efficiently if done in a streaming fashion,
but realistically this should be OK for now.
2013-10-17 14:32:44 -04:00
Colin Walters
0e1a3ee345 gsubprocess: Fix up communicate
We weren't closing the streams after we were done reading or writing,
which is kind of essential.  The easy way to fix this is to just use
g_output_stream_splice() to a GMemoryOutputStream rather than
hand-rolling it.  This results in a substantial reduction of code
complexity.

A second serious issue is that we were marking the task as complete when
the process exits, but that's racy - there could still be data to read
from stdout.  Fix this by just refcounting outstanding operations.

This code, not surprisingly, looks a lot like the "multi" test.

Next, because processes output binary data, I'd be forced to annotate
the char*/length pairs as (array) (element-type uint8).  But rather than
doing that, it's *far* simpler to just use GBytes.

We need a version of this that actually validates as UTF-8, that will be
in the next patch.
2013-10-17 14:32:44 -04:00
Colin Walters
5b48dc40cc GSubprocess: New class for spawning child processes
There are a number of nice things this class brings:

0) Has a race-free termination API on all platforms (on UNIX, calls to
   kill() and waitpid() are coordinated as not to cause problems).
1) Operates in terms of G{Input,Output}Stream, not file descriptors
2) Standard GIO-style async API for wait() with cancellation
3) Makes some simple cases easy, like synchronously spawning a
   process with an argument list
4) Makes hard cases possible, like asynchronously running a process
   with stdout/stderr merged, output directly to a file path

Much rewriting and code review from Ryan Lortie <desrt@desrt.ca>

https://bugzilla.gnome.org/show_bug.cgi?id=672102
2013-10-17 14:32:44 -04:00
Dan Winship
5a269e5a90 gcredentials: add Solaris support
Based on patches from Igor Pashev.

https://bugzilla.gnome.org/show_bug.cgi?id=705029
2013-10-04 09:51:31 -04:00
Dan Winship
cedd697bf8 gcredentials: add internal macros to simplify all the #ifdefs
Rather than having lots of obscure platform-based #ifdefs all over
gio, define some macros in gcredentialsprivate.h, and use those to
simplify the rest of the code.

https://bugzilla.gnome.org/show_bug.cgi?id=701482
2013-10-04 09:51:31 -04:00
Mike Ruprecht
e967a76728 tests: Add testcases for g_output_stream_splice_async()
Previously, no testcases tested the close flags of
g_output_stream_splice_async. This patch adds tests for that and
also tests various combinations of threaded and non-threaded
GInputStream async reads and GOutputStream async writes.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:40 -04:00
Ryan Lortie
abf505fd0e More gio-du win32 fixes
Don't free the utf8 filename before the async function completes.

also, gitignore
2013-09-23 16:31:40 -04:00
Ryan Lortie
348764269d gio-du: show the correct filename in progress
We were showing argv[1] in the progress output before, which is not
always the filename.
2013-09-16 13:42:02 -04:00
Chun-wei Fan
2684dec447 gio-du: Improve test program on Windows
Make use of __wgetmainargs() on Windows so that we can get wide char
versions of the argv's that are passed in when this test program is being
invoked.  This is necessary as one might enter non-ASCII, such as
CJK characters filenames and/or directories to run the test program
against, so that we can process the name(s) and pass the proper
UTF-8-encoded name(s) of the files/directories that is being tested.

https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-16 13:40:14 -04:00
Chun-wei Fan
7a91a6c9a5 gio/tests/gio-du.c: Avoid Using Unintialized Variable
https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-13 11:31:05 +08:00
Ryan Lortie
5a11019034 tests: remove assertion for '!uncertain' on .txt
Virtaal installs a mime package for various .po-like file formats, one
of which has the extension .txt.  This causes GLib to report ".txt"
files still as "text/plain" but no longer with complete certainty.

The result is that asserting !uncertain during the testsuite causes the
test to fail if Virtaal happens to be installed.

Remove this assertion.
2013-09-12 14:40:24 -04:00
Dieter Verfaillie
49bbebc0b9 gio/tests/network-address: fix SCOPE_ID_TEST_INDEX fallback 2013-09-09 23:57:30 +02:00
Ryan Lortie
a61c9f489a tests/: add gio-du
This is basically a minimally-featured 'du' equivalent to manually test
g_file_measure_disk_usage().

https://bugzilla.gnome.org/show_bug.cgi?id=704893
2013-09-09 10:41:17 -04:00
Dan Winship
cde9f4598b gio/tests/socket: fix warning building on win32
setsockopt() has a broken prototype on win32. Fix this by just using
g_socket_set_option() instead.
2013-08-31 11:40:44 -04:00
Sebastian Dröge
02393e6faf gio/tests/socket: add test for g_socket_get_available_bytes()
https://bugzilla.gnome.org/show_bug.cgi?id=686786
2013-08-31 11:40:44 -04:00
Dan Winship
c069c51db5 gnetworkaddress: allow IPv6 scope ids in URIs
GNetworkAddress was allowing IPv6 scope ids in g_network_address_new()
/ g_network_address_parse(), but not in g_network_address_parse_uri().
Fix that.

Part of https://bugzilla.gnome.org/show_bug.cgi?id=669724
2013-08-19 12:15:36 -04:00
Dan Winship
e1f92431c1 gnetworkaddress: fix parsing of URIs with IPv6 literal and port
Addresses like "http://[::1]:8080/" were being parsed as though they
did not include a port. Fix that, and add some more parsing tests.
2013-08-19 12:15:36 -04:00
Matthias Clasen
0e9f9867fa Start using TAP
Convert {glib,gobject,gio}/tests to use the automake TAP driver
and test harness instead of gtester. To do so, we add a glib-tap.mk
that provides the same interface as glib.mk, except for the
reporting and coverage testing functionality. Eventually, we may
want to replace glib.mk with it. I've not yet converted the
toplevel tests/ directory, since it mixes gtestutils tests with
other binaries.

https://bugzilla.gnome.org/show_bug.cgi?id=692125
2013-08-17 17:25:58 -04:00
Dan Winship
547df5937c GSocket: fix g_socket_bind() allow_reuse semantics
With UDP sockets, g_socket_bind() with allow_reuse=TRUE on Linux
behaved in a way that the documentation didn't suggest, and that
didn't match other OSes. (Specifically, it allowed binding multiple
multicast sockets to the same address.)

Since this behavior is useful, and since allow_reuse didn't have any
other meaning with UDP sockets, update the docs to reflect the Linux
behavior, and make it do the same thing on non-Linux.

https://bugzilla.gnome.org/show_bug.cgi?id=689245
2013-08-17 13:26:42 -04:00
Dan Winship
f550c0dc9d update .gitignores 2013-08-17 10:35:13 -04:00
Dan Winship
a93d373812 gio/tests/task: fix a race condition in test_run_in_thread()
When running a task in a thread, GTask may still be internally holding
a ref on the task in that thread even after the callback is called in
the original thread (depending on thread scheduling). Fix the test to
handle that by using a weak notify that signals a GCond, and wait for
that GCond from the main thread. (And add a corresponding check to
test_return_on_cancel().)

https://bugzilla.gnome.org/show_bug.cgi?id=705152
2013-08-15 12:43:57 -04:00
Matthias Clasen
06b968b6db Make a test desktop file a little less invalid
Add a missing Name entry, and add a terminal ; to the Actions
entry in org.gtk.test.dbusappinfo.desktop. desktop-file-validate
still contains about the DBusActivatable entry and about the
missing Exec entries. The former will go away when desktop-file-validate
gets updated for the latest spec revision.
2013-07-14 11:36:45 -04:00
Ryan Lortie
973464781c Fix a typo in a filename in Makefile.am 2013-07-11 15:57:59 -04:00
Ryan Lortie
3b1b04433c Add a testcase for DBusActivatable=true
Add a fairly realistic testcase that ensures that GDesktopAppInfo with
DBusActivatable=true can successfully talk to GApplication for a variety
of purposes.

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-07-11 15:49:28 -04:00
Ryan Lortie
985e95e831 Add missing file
This got removed during the OnlyShowIn shuffle.
2013-07-11 13:49:20 -04:00
Ryan Lortie
6dc5c118e4 Implement the Desktop Action specification
For some time, the desktop file specification has supported "additional
application actions".  This is intended to allow for additional methods
of starting an app, such as a mail client having a "Compose New Message"
action that brings up the compose window instead of the folder list.

This patch adds support for this with a relatively minimal API.

In the case that the application is a GApplication and DBusActivatable,
desktop actions are translated into GActions that have been added to the
application with g_action_map_add_action().  This more or less closes
the loop on being able to activate an application with an action
invocation (instead of 'activate').

https://bugzilla.gnome.org/show_bug.cgi?id=664444
2013-07-11 12:48:08 -04:00
Ryan Lortie
f77e121650 add GPropertyAction
Add a new type of GAction that represents the value of a property on an
object.  As an example, this might be used on the "visible-child-name"
property of a GtkStack.

https://bugzilla.gnome.org/show_bug.cgi?id=703270
2013-07-11 12:35:45 -04:00
Ryan Lortie
cb4469600c GDBusConnection: be more careful with async GetAll
It's possible to get a org.freedesktop.Properties.GetAll call even if we
have no readable properties in the introspection, in which case we
should return the empty list in the usual way.

We should certainly _not_ be dispatching to the method call handler of
an interface which has no properties (since it will not be expecting
this).

Add a check to make sure that there is at least one readable property
before assuming that a NULL get_property handler implies that we want to
handle properties asynchronously.

Add a testcase that was failing before the change and works after it.

https://bugzilla.gnome.org/show_bug.cgi?id=703437
2013-07-01 23:36:30 -04:00
Ryan Lortie
f754c4e85b GDBusConnection: allow async property handling
The existing advice in the documentation to "simply" register the
"org.freedesktop.DBus.Properties" interface if you want to handle
properties asynchronously is pretty unreasonable.  If you want to handle
this interface you have to deal with all properties for all interfaces
on the path, and you have to do all of the checking for yourself.  You
also have to provide your own introspection data.

Introduce a new convention for dealing with properties asynchronously.

If the user provides NULL for their get_property() or set_property()
functions in the vtable and has properties registered then the
properties are sent to the method_call() handler.  We get lucky here
that this function takes an "interface_name" parameter that we can set
to "org.freedesktop.DBus.Properties".

We also do the user the favour of setting the GDBusPropertyInfo on the
GDBusMethodInvocation for their convenience (for much the same reasons
as they might want the already-available GDBusMethodInfo).

Add a testcase as well as a bunch of documentation about this new
feature.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:31 -04:00
Ryan Lortie
12958ed5cc gio/tests: sort tests in the Makefile.am
...to make it clear where people should add theirs, reducing the chance
of conflicts caused by everyone always adding at the end.
2013-06-08 17:01:56 -04:00
Dan Winship
6965b721b1 tests: fix and re-add the broken test 2013-06-05 23:49:56 -03:00
Matthias Clasen
1dac271ace Remove a failing testcase
One of the recently added examples seems wrong. Drop it.
2013-06-05 21:50:52 -04:00
Ryan Lortie
74a034028a tests: add a few more invalid IPv6 address tests
https://bugzilla.gnome.org/show_bug.cgi?id=701401
2013-06-05 19:48:29 -03:00
Dan Winship
16b26231ca gio/tests/inet-address: fix to work on OS X
OS X's getaddrinfo() only supports IPv6 scope IDs that are interface
names, not numbers. So use if_indextoname() to get the name of an
interface and construct an address using that.

https://bugzilla.gnome.org/show_bug.cgi?id=700123
2013-06-04 09:24:47 -03:00