diff options
author | Benjamin Berg <bberg@redhat.com> | 2020-11-25 18:10:08 +0100 |
---|---|---|
committer | Benjamin Berg <bberg@redhat.com> | 2020-11-25 18:32:23 +0100 |
commit | 1299b99cea1a76bdcd07698664657a85f76604a7 (patch) | |
tree | 4cc4b9575be7744deca3ed090e413430504cea2a | |
parent | 82356e0f9db9de306a1f2c2864755727c6383b96 (diff) | |
download | gnome-settings-daemon-benzea/timetravel.tar.gz |
meson: Add option to run using UML time-travel modebenzea/timetravel
Not that this actually helps much. Loading all the python stuff inside
UML is extremely slow (due to ptrace). As such, it is actually slower to
use, but still academically interesting.
-rw-r--r-- | meson.build | 10 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | tests/time-travel | 53 |
3 files changed, 65 insertions, 0 deletions
diff --git a/meson.build b/meson.build index 7dbee64b..16f715c4 100644 --- a/meson.build +++ b/meson.build @@ -253,6 +253,16 @@ meson.add_install_script( gsd_datadir ) + +# Add a time-travel test setup which optimizes away all the sleeps +if get_option('uml') != '' + time_travel = find_program('tests/time-travel') + add_test_setup( + 'timetravel', + exe_wrapper : [ time_travel, get_option('uml')], + ) +endif + output = '\n ' + meson.project_name() + ' ' + meson.project_version() +'\n' output += ' =============================\n\n' output += ' prefix: ' + gsd_prefix + '\n' diff --git a/meson_options.txt b/meson_options.txt index 3e04cf64..e30846d7 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -12,3 +12,5 @@ option('usb-protection', type: 'boolean', value: true, description: 'build with option('wayland', type: 'boolean', value: true, description: 'build with Wayland support') option('wwan', type: 'boolean', value: true, description: 'build with WWAN support') option('colord', type: 'boolean', value: true, description: 'build with colord support') + +option('uml', type: 'string', value: '', description: 'Absolute path to UML binary that supports time-travel, speeds up testing') diff --git a/tests/time-travel b/tests/time-travel new file mode 100644 index 00000000..48842da1 --- /dev/null +++ b/tests/time-travel @@ -0,0 +1,53 @@ +#!/bin/sh + +UML_BIN="$1" +shift + +wrapper=$( mktemp time-travel-setup-XXXXXX.sh ) +wrapper_full_path="$( pwd )/$wrapper" + +result="$wrapper_full_path.res" +cat >"$wrapper" <<%EOF +#! /bin/sh + +# Serialized environment +$( export ) + +mount -o remount,rw / +mount tmp -t tmpfs /tmp +mount tmp -t tmpfs /root +mount tmp -t tmpfs /var +mount proc -t proc /proc +mount sys -t sysfs /sys + +if which haveged >/dev/null 2>&1 ; then + haveged +elif which rngd >/dev/null 2>&1 ; then + # for some strange reason, this doesn't work so well + # when we don't start it into foreground with -f ... + rngd -f -r /dev/hw_random & +else + echo "No entropy gathering daemon available - aborting!" + exit 1 +fi + +# Execute the test +$@ +res=\$? +echo \$res >"$result" + +poweroff -f +%EOF +chmod +x "$wrapper" + +$UML_BIN mem=512M root=none hostfs=/ rootfstype=hostfs rootflags=/ init="$wrapper_full_path" no_console_suspend con=null con0=null,fd:1 time-travel=inf-cpu +reset -I +rm -f $wrapper + +if [ -f $result ]; then + res=$( cat "$result" ) + rm -f "$result" + exit $res +else + exit -1 +fi |