[PATCH 1/3] tests: Add support for subtests.

Francois Gouget fgouget at codeweavers.com
Mon Aug 26 21:14:29 CDT 2019


Some Wine tests run code compiled from another C file, resulting in
traces and errors that look like they come from a different test.
subtest() allows such tests to declare their subtests so they are
recognized by scripts parsing the results such as the TestBot and
WineTest website.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

Currently the WineTest website just ignores the name of the unit test 
which is a bit suboptimal because it means it cannot detect when a 
test's subprocess stays around for too long and starts polluting the 
following tests.

But for proper parsing the subtest names should be declared. This 
patch makes it possible to do so through the subtest() API:

    subtest("driver");

The WineTest and TestBot scripts can then identify subtests and handle 
them as appropriate.


 include/wine/test.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/include/wine/test.h b/include/wine/test.h
index b5aa9c14c70..588a36eb85e 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -123,17 +123,20 @@ extern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) WINETEST_
 extern void __winetest_cdecl winetest_trace( const char *msg, ... ) WINETEST_PRINTF_ATTR(1,2);
 
 #ifdef WINETEST_NO_LINE_NUMBERS
+# define subtest_(file, line)  (winetest_set_location(file, 0), 0) ? (void)0 : winetest_subtest
 # define ok_(file, line)       (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ok
 # define skip_(file, line)     (winetest_set_location(file, 0), 0) ? (void)0 : winetest_skip
 # define win_skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_win_skip
 # define trace_(file, line)    (winetest_set_location(file, 0), 0) ? (void)0 : winetest_trace
 #else
+# define subtest_(file, line)  (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest
 # define ok_(file, line)       (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
 # define skip_(file, line)     (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
 # define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
 # define trace_(file, line)    (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
 #endif
 
+#define subtest  subtest_(__FILE__, __LINE__)
 #define ok       ok_(__FILE__, __LINE__)
 #define skip     skip_(__FILE__, __LINE__)
 #define win_skip win_skip_(__FILE__, __LINE__)
@@ -308,6 +311,13 @@ void winetest_set_location( const char* file, int line )
     data->current_line=line;
 }
 
+void winetest_subtest( const char* name )
+{
+    struct tls_data *data = get_tls_data();
+    printf( "%s:%d: Subtest %s\n",
+            data->current_file, data->current_line, name);
+}
+
 int broken( int condition )
 {
     return (strcmp(winetest_platform, "windows") == 0) && condition;
-- 
2.20.1




More information about the wine-devel mailing list