@@ -47,6 +47,7 @@ typedef void (*QOSStartFunct) (QOSGraphObject *object);
/* Test options functions */
typedef void *(*QOSBeforeTest) (GString *cmd_line, void *arg);
+typedef void (*QOSAfterTest) (void *arg);
/**
* SECTION: qgraph.h
@@ -341,6 +342,7 @@ struct QOSGraphTestOptions {
* additional parameters to the command line
* and modify the argument to the test function.
*/
+ QOSAfterTest after; /* executed after the test */
bool subprocess; /* run the test in a subprocess */
};
@@ -68,6 +68,7 @@ struct QOSGraphNode {
QOSTestFunc function;
void *arg;
QOSBeforeTest before;
+ QOSAfterTest after;
bool subprocess;
} test;
} u;
@@ -603,6 +603,7 @@ void qos_add_test(const char *name, const char *interface,
assert(!opts->edge.size_arg);
node->u.test.before = opts->before;
+ node->u.test.after = opts->after;
node->u.test.subprocess = opts->subprocess;
node->available = true;
add_edge(interface, test_name, QEDGE_CONSUMED_BY, &opts->edge);
@@ -273,6 +273,7 @@ void *qos_allocate_objects(QTestState *qts, QGuestAllocator **p_alloc)
* 3) call all nodes constructor and get_driver/get_device depending on edge,
* start the hardware (*_device_enable functions)
* 4) start test
+ * 5) @after test function as defined in the given QOSGraphTestOptions
*/
static void run_one_test(const void *arg)
{
@@ -296,6 +297,11 @@ static void run_one_test(const void *arg)
obj = qos_allocate_objects(global_qtest, &alloc);
test_node->u.test.function(obj, test_arg, alloc);
+
+ /* After test */
+ if (test_node->u.test.after) {
+ test_node->u.test.after(test_arg);
+ }
}
static void subprocess_run_one_test(const void *arg)
Add a callback that runs after a test completes. This will be used for cleanup. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> --- tests/libqos/qgraph.h | 2 ++ tests/libqos/qgraph_internal.h | 1 + tests/libqos/qgraph.c | 1 + tests/qos-test.c | 6 ++++++ 4 files changed, 10 insertions(+)