summaryrefslogtreecommitdiff
path: root/test/test-main.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-main.c')
-rw-r--r--test/test-main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test-main.c b/test/test-main.c
index 4e17c9edb2..139fc1f6f1 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -16,6 +16,19 @@
DECLARE_GLOBAL_DATA_PTR;
+/* This is valid when a test is running, NULL otherwise */
+static struct unit_test_state *cur_test_state;
+
+struct unit_test_state *test_get_state(void)
+{
+ return cur_test_state;
+}
+
+void test_set_state(struct unit_test_state *uts)
+{
+ cur_test_state = uts;
+}
+
/**
* dm_test_pre_run() - Get ready to run a driver model test
*
@@ -180,6 +193,9 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test,
note = " (flat tree)";
printf("Test: %s: %s%s\n", test_name, fname, note);
+ /* Allow access to test state from drivers */
+ test_set_state(uts);
+
ret = test_pre_run(uts, test);
if (ret == -EAGAIN)
return -EAGAIN;
@@ -192,6 +208,8 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test,
if (ret)
return ret;
+ test_set_state( NULL);
+
return 0;
}