lib: new restore_wallclock field to restore realtime clock

Some tests that change the system-wide clock need to have a way to
restore the correct time after their execution.

This commit introduces a new field to tst_test struct called
"restore_wallclock": it makes the test to save current realtime clock
during setup phase, and, later, during cleanup, restore it to the
appropriate time using a monotonic raw clock difference.

Signed-off-by: Rafael David Tinoco <rafael.tinoco@linaro.org>
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/lib/tst_test.c b/lib/tst_test.c
index da3e0c8..7dd890b 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -35,6 +35,7 @@
 #include "tst_timer_test.h"
 #include "tst_clocks.h"
 #include "tst_timer.h"
+#include "tst_wallclock.h"
 #include "tst_sys_conf.h"
 #include "tst_kconfig.h"
 
@@ -872,6 +873,9 @@
 
 	if (tst_test->resource_files)
 		copy_resources();
+
+	if (tst_test->restore_wallclock)
+		tst_wallclock_save();
 }
 
 static void do_test_setup(void)
@@ -903,6 +907,9 @@
 		tst_sys_conf_restore(0);
 
 	cleanup_ipc();
+
+	if (tst_test->restore_wallclock)
+		tst_wallclock_restore();
 }
 
 static void run_tests(void)