tests: Replace g_test_trap_fork() with g_test_trap_subprocess()

For GLib versions newer than 2.38.0. This continues to work for older
versions, so the GLib dependency is not bumped.

https://bugzilla.gnome.org/show_bug.cgi?id=712565