selftests: Add test plan API to kselftest.h and adjust callers
[sfrench/cifs-2.6.git] / tools / testing / selftests / kselftest.h
index 47e1d995c1822903499e6597bc863f3b41402e6a..ec15c4f6af552d57a5584e18abb7cb9bb17cc90f 100644 (file)
@@ -33,6 +33,7 @@ struct ksft_count {
 };
 
 static struct ksft_count ksft_cnt;
 };
 
 static struct ksft_count ksft_cnt;
+static unsigned int ksft_plan;
 
 static inline int ksft_test_num(void)
 {
 
 static inline int ksft_test_num(void)
 {
@@ -61,13 +62,21 @@ static inline void ksft_print_header(void)
                printf("TAP version 13\n");
 }
 
                printf("TAP version 13\n");
 }
 
+static inline void ksft_set_plan(unsigned int plan)
+{
+       ksft_plan = plan;
+       printf("1..%d\n", ksft_plan);
+}
+
 static inline void ksft_print_cnts(void)
 {
 static inline void ksft_print_cnts(void)
 {
-       printf("Pass %d Fail %d Xfail %d Xpass %d Skip %d Error %d\n",
+       if (ksft_plan != ksft_test_num())
+               printf("# Planned tests != run tests (%u != %u)\n",
+                       ksft_plan, ksft_test_num());
+       printf("# Pass %d Fail %d Xfail %d Xpass %d Skip %d Error %d\n",
                ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
                ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
                ksft_cnt.ksft_xskip, ksft_cnt.ksft_error);
                ksft_cnt.ksft_pass, ksft_cnt.ksft_fail,
                ksft_cnt.ksft_xfail, ksft_cnt.ksft_xpass,
                ksft_cnt.ksft_xskip, ksft_cnt.ksft_error);
-       printf("1..%d\n", ksft_test_num());
 }
 
 static inline void ksft_print_msg(const char *msg, ...)
 }
 
 static inline void ksft_print_msg(const char *msg, ...)
@@ -111,7 +120,7 @@ static inline void ksft_test_result_skip(const char *msg, ...)
        ksft_cnt.ksft_xskip++;
 
        va_start(args, msg);
        ksft_cnt.ksft_xskip++;
 
        va_start(args, msg);
-       printf("ok %d # skip ", ksft_test_num());
+       printf("not ok %d # SKIP ", ksft_test_num());
        vprintf(msg, args);
        va_end(args);
 }
        vprintf(msg, args);
        va_end(args);
 }
@@ -172,7 +181,7 @@ static inline int ksft_exit_skip(const char *msg, ...)
                va_list args;
 
                va_start(args, msg);
                va_list args;
 
                va_start(args, msg);
-               printf("1..%d # Skipped: ", ksft_test_num());
+               printf("not ok %d # SKIP ", 1 + ksft_test_num());
                vprintf(msg, args);
                va_end(args);
        } else {
                vprintf(msg, args);
                va_end(args);
        } else {