From: Alex G. Date: Mon, 1 Feb 2021 10:47:34 -0600 Subject: [PATCH v2 26/40] test: Use a local variable for test state In-Reply-To: <20210131033248.1502385-27-sjg@chromium.org> References: <20210131033248.1502385-1-sjg@chromium.org> <20210131033248.1502385-27-sjg@chromium.org> Message-ID: <7e66e9c7-41a9-04ce-002f-6874f5401cfb@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon, On 1/30/21 9:32 PM, Simon Glass wrote: [snip] > > +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 +192,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 */ > + cur_test_state = uts; > + Is there a reason for setting 'cur_test_state' directly instead of through test_set_state() ? > ret = test_pre_run(uts, test); > if (ret == -EAGAIN) > return -EAGAIN; > @@ -192,6 +207,8 @@ static int ut_run_test(struct unit_test_state *uts, struct unit_test *test, > if (ret) > return ret; > > + cur_test_state = NULL; > + ditto > return 0; > } > >