diff options
author | Matthew Booth <mbooth@redhat.com> | 2012-04-12 09:29:45 +0100 |
---|---|---|
committer | Matthew Booth <mbooth@redhat.com> | 2012-04-26 13:35:34 +0100 |
commit | 8fb67ee66acbdcff805984715567a92a30428aec (patch) | |
tree | 8f9552f317c2bab2cd4dba57e8243d6f9d881211 /gobject | |
parent | 6c88c3758b60f4c4ec9ec7fcaf89074949dd88a4 (diff) | |
download | libguestfs-8fb67ee66acbdcff805984715567a92a30428aec.tar.gz libguestfs-8fb67ee66acbdcff805984715567a92a30428aec.tar.xz libguestfs-8fb67ee66acbdcff805984715567a92a30428aec.zip |
gobject: Implement libguestfs events as signals
Implement libguestfs events as GObject signals. Callback arguments are passed in
a boxed object.
Note that this patch fixes the length of the uint64_t array in the callback
arguments at 16, whereas it is actually arbitrary length. This is to make it
introspectable. There is currently no way to pass an arbitrary length array to a
callback, and have its type introspected.
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/tests-misc.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gobject/tests-misc.js b/gobject/tests-misc.js index aadc2f39..8faf8a80 100644 --- a/gobject/tests-misc.js +++ b/gobject/tests-misc.js @@ -21,6 +21,39 @@ var fail = false; var g = new Guestfs.Session(); +var progress_detected = false; +var trace_detected = false; + +// Test events +g.connect('progress', function(session, params) { + if (params.array_len == 4) { + // Look for the final progress notification where position = total + if (params.array[2] == params.array[3] && params.array[2] != 0) { + progress_detected = true; + } + } +}); +g.connect('trace', function(session, params) { + if (params.buf == 'launch') { + trace_detected = true; + } +}); + +g.add_drive('../tests/guests/fedora.img'); +g.set_trace(true); +g.launch(); +// Fake progress messages for a 5 second event. We do this as launch() will not +// generate any progress messages unless it takes at least 5 seconds. +g.debug('progress', ['5']); +if (!trace_detected) { + print("failed to detect trace message for launch"); + fail = true; +} +if (!progress_detected) { + print("failed to detect progress message for launch"); + fail = true; +} + // Test close() g.close(); var threw = false; |