On Mon, Dec 15, 2025 at 07:00:27PM -0300, Fabiano Rosas wrote: > Move TLS PSK setup and cleanup into a common function instead of using > hooks. Hooks are for when the test needs to access the QTestState. > > This primarily moves setup of TLS PSK tests from ->start_hook time > earlier into test function call time, which brings the migrate_set_* > calls within earlier, where they can be replaced in subsequent patches > with the new config setup. > > Signed-off-by: Fabiano Rosas <[email protected]> > --- > tests/qtest/migration/tls-tests.c | 149 +++++++++++++++++------------- > 1 file changed, 83 insertions(+), 66 deletions(-) > > diff --git a/tests/qtest/migration/tls-tests.c > b/tests/qtest/migration/tls-tests.c > index 2eeed1fc5b..aade57f7de 100644 > --- a/tests/qtest/migration/tls-tests.c > +++ b/tests/qtest/migration/tls-tests.c > @@ -23,12 +23,12 @@ > #endif /* CONFIG_TASN1 */ > > > -struct TestMigrateTLSPSKData { > +typedef struct { > char *workdir; > char *workdiralt; > char *pskfile; > char *pskfilealt; > -}; > +} TestMigrateTLSPSKData; > > typedef struct { > bool mismatch; > @@ -44,59 +44,62 @@ static TestMigrateTLSPSK tls_psk_mismatch = { > > static char *tmpfs; > > -static void * > -migrate_hook_start_tls_psk_common(QTestState *from, > - QTestState *to, > - void *opaque) > +static void *migrate_hook_start_tls_psk_common(QTestState *from, > + QTestState *to, > + void *opaque) > { > TestMigrateTLSPSK *args = opaque; > - struct TestMigrateTLSPSKData *data = > - g_new0(struct TestMigrateTLSPSKData, 1); > + g_autofree char *workdir = g_strdup_printf("%s/tlscredspsk0", tmpfs); > + g_autofree char *workdiralt = NULL; > > + if (args->mismatch) { > + workdiralt = g_strdup_printf("%s/tlscredspskalt0", tmpfs); > + }
Nit: similar string duplications here, now two (workdir, workdiralt). I guess OK for now, Reviewed-by: Peter Xu <[email protected]> dedup somehow would be better. -- Peter Xu
