trap_reached_timeout


Description:

[ Version ( since = "2.16" ) ]
public bool trap_reached_timeout ()

Check the result of the last trap_subprocess call.

Example: Add a timeout to a test:

public static int main (string[] args) {
Test.init (ref args);

Test.add_func ("/valadoc/driver-0.14.x", () => {
// Force GTest to kill the subprocess after 900 micro seconds:
Test.trap_subprocess ("/valadoc/driver-0.14.x/subprocess", 1000*5, 0);

// Test.trap_reached_timeout () = true:
if (!Test.trap_reached_timeout ()) {
Test.message ("timeout reached!");
Test.fail ();
} else {
Test.message ("timeout not reached!");
}
});

Test.add_func ("/valadoc/driver-0.14.x/subprocess", () => {
while (true) {
Thread.usleep (100);
}
});

Test.run ();
return 0;
}

valac --pkg glib-2.0 GLib.Test.trap_reached_timeout.vala

./GLib.Test.trap_reached_timeout --verbose

Returns:

true if the last test subprocess got killed due to a timeout.


Namespace: GLib.Test
Package: glib-2.0