public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [RFC] Getting rid of cleanup parameter
@ 2015-11-10 14:14 Cyril Hrubis
  2015-11-11 10:20 ` Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2015-11-10 14:14 UTC (permalink / raw)
  To: ltp

Hi!
I was looking into the LTP API expecially the tst_res* part to make it
cleaner and easier to use and one of the things I would like to change
is how we execute the cleanup function.

Currenlty we pass the cleanup as function parameter. The 99% of the time
we just pass the very same function to every call with the exception of
the calls in the cleanup function itself. And the callback function is
made in a way that it could be called at any point in the setup() as
well.

The common mistakes with that API is that people pass cleanup() paramter
to functions in cleanup() and to tst api in child processes. But as we
use it now the cleanup can be set exactly once and called from the test
library which could make sure that it's called exactly once, etc.

So my proposal is to add a call to set cleanup function,
tst_set_cleanup(void (*cleanup)(void)) that would be called once in the
setup and would store the function pointer, which would later be called
either when test exits prematurely or on tst_exit(). When the cleanup
function was set with this interface the cleanup paramter for all
functions would be ignored (we may create static inline wrappers that
sets it to NULL to be used from new code).

Does everybody agree with this change?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-11-11 18:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-10 14:14 [LTP] [RFC] Getting rid of cleanup parameter Cyril Hrubis
2015-11-11 10:20 ` Jan Stancek
2015-11-11 13:30   ` Cyril Hrubis
2015-11-11 16:53     ` Jiri Jaburek
2015-11-11 18:45       ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox