/* Maximum size of parameter description string. */
 #define KUNIT_PARAM_DESC_SIZE 128
 
+/* Maximum size of a status comment. */
+#define KUNIT_STATUS_COMMENT_SIZE 256
+
 /*
  * TAP specifies subtest stream indentation of 4 spaces, 8 spaces for a
  * sub-subtest.  See the "Subtests" section in
 #define KUNIT_SUBTEST_INDENT           "    "
 #define KUNIT_SUBSUBTEST_INDENT                "        "
 
+/**
+ * enum kunit_status - Type of result for a test or test suite
+ * @KUNIT_SUCCESS: Denotes the test suite has not failed nor been skipped
+ * @KUNIT_FAILURE: Denotes the test has failed.
+ * @KUNIT_SKIPPED: Denotes the test has been skipped.
+ */
+enum kunit_status {
+       KUNIT_SUCCESS,
+       KUNIT_FAILURE,
+       KUNIT_SKIPPED,
+};
+
 /**
  * struct kunit_case - represents an individual test case.
  *
        const void* (*generate_params)(const void *prev, char *desc);
 
        /* private: internal use only. */
-       bool success;
+       enum kunit_status status;
        char *log;
 };
 
-static inline char *kunit_status_to_string(bool status)
+static inline char *kunit_status_to_ok_not_ok(enum kunit_status status)
 {
-       return status ? "ok" : "not ok";
+       switch (status) {
+       case KUNIT_SKIPPED:
+       case KUNIT_SUCCESS:
+               return "ok";
+       case KUNIT_FAILURE:
+               return "not ok";
+       }
+       return "invalid";
 }
 
 /**
        struct kunit_case *test_cases;
 
        /* private: internal use only */
+       char status_comment[KUNIT_STATUS_COMMENT_SIZE];
        struct dentry *debugfs;
        char *log;
 };
         * be read after the test case finishes once all threads associated
         * with the test case have terminated.
         */
-       bool success; /* Read only after test_case finishes! */
        spinlock_t lock; /* Guards all mutable test state. */
+       enum kunit_status status; /* Read only after test_case finishes! */
        /*
         * Because resources is a list that may be updated multiple times (with
         * new resources) from any thread associated with a test case, we must
         * protect it with some type of lock.
         */
        struct list_head resources; /* Protected by lock. */
+
+       char status_comment[KUNIT_STATUS_COMMENT_SIZE];
 };
 
 static inline void kunit_set_failure(struct kunit *test)
 {
-       WRITE_ONCE(test->success, false);
+       WRITE_ONCE(test->status, KUNIT_FAILURE);
 }
 
 void kunit_init_test(struct kunit *test, const char *name, char *log);
 #define kunit_suite_for_each_test_case(suite, test_case)               \
        for (test_case = suite->test_cases; test_case->run_case; test_case++)
 
-bool kunit_suite_has_succeeded(struct kunit_suite *suite);
+enum kunit_status kunit_suite_has_succeeded(struct kunit_suite *suite);
 
 /*
  * Like kunit_alloc_resource() below, but returns the struct kunit_resource
 
 void __printf(2, 3) kunit_log_append(char *log, const char *fmt, ...);
 
+/**
+ * kunit_mark_skipped() - Marks @test_or_suite as skipped
+ *
+ * @test_or_suite: The test context object.
+ * @fmt:  A printk() style format string.
+ *
+ * Marks the test as skipped. @fmt is given output as the test status
+ * comment, typically the reason the test was skipped.
+ *
+ * Test execution continues after kunit_mark_skipped() is called.
+ */
+#define kunit_mark_skipped(test_or_suite, fmt, ...)                    \
+       do {                                                            \
+               WRITE_ONCE((test_or_suite)->status, KUNIT_SKIPPED);     \
+               scnprintf((test_or_suite)->status_comment,              \
+                         KUNIT_STATUS_COMMENT_SIZE,                    \
+                         fmt, ##__VA_ARGS__);                          \
+       } while (0)
+
+/**
+ * kunit_skip() - Marks @test_or_suite as skipped
+ *
+ * @test_or_suite: The test context object.
+ * @fmt:  A printk() style format string.
+ *
+ * Skips the test. @fmt is given output as the test status
+ * comment, typically the reason the test was skipped.
+ *
+ * Test execution is halted after kunit_skip() is called.
+ */
+#define kunit_skip(test_or_suite, fmt, ...)                            \
+       do {                                                            \
+               kunit_mark_skipped((test_or_suite), fmt, ##__VA_ARGS__);\
+               kunit_try_catch_throw(&((test_or_suite)->try_catch));   \
+       } while (0)
+
 /*
  * printk and log to per-test or per-suite log buffer.  Logging only done
  * if CONFIG_KUNIT_DEBUGFS is 'y'; if it is 'n', no log is allocated/used.
 
                debugfs_print_result(seq, suite, test_case);
 
        seq_printf(seq, "%s %d - %s\n",
-                  kunit_status_to_string(success), 1, suite->name);
+                  kunit_status_to_ok_not_ok(success), 1, suite->name);
        return 0;
 }
 
 
 #endif
 }
 
+static void kunit_status_set_failure_test(struct kunit *test)
+{
+       struct kunit fake;
+
+       kunit_init_test(&fake, "fake test", NULL);
+
+       KUNIT_EXPECT_EQ(test, fake.status, (enum kunit_status)KUNIT_SUCCESS);
+       kunit_set_failure(&fake);
+       KUNIT_EXPECT_EQ(test, fake.status, (enum kunit_status)KUNIT_FAILURE);
+}
+
+static void kunit_status_mark_skipped_test(struct kunit *test)
+{
+       struct kunit fake;
+
+       kunit_init_test(&fake, "fake test", NULL);
+
+       /* Before: Should be SUCCESS with no comment. */
+       KUNIT_EXPECT_EQ(test, fake.status, KUNIT_SUCCESS);
+       KUNIT_EXPECT_STREQ(test, fake.status_comment, "");
+
+       /* Mark the test as skipped. */
+       kunit_mark_skipped(&fake, "Accepts format string: %s", "YES");
+
+       /* After: Should be SKIPPED with our comment. */
+       KUNIT_EXPECT_EQ(test, fake.status, (enum kunit_status)KUNIT_SKIPPED);
+       KUNIT_EXPECT_STREQ(test, fake.status_comment, "Accepts format string: YES");
+}
+
+static struct kunit_case kunit_status_test_cases[] = {
+       KUNIT_CASE(kunit_status_set_failure_test),
+       KUNIT_CASE(kunit_status_mark_skipped_test),
+       {}
+};
+
+static struct kunit_suite kunit_status_test_suite = {
+       .name = "kunit_status",
+       .test_cases = kunit_status_test_cases,
+};
+
 kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite,
-                 &kunit_log_test_suite);
+                 &kunit_log_test_suite, &kunit_status_test_suite);
 
 MODULE_LICENSE("GPL v2");
 
 
 static void kunit_print_ok_not_ok(void *test_or_suite,
                                  bool is_test,
-                                 bool is_ok,
+                                 enum kunit_status status,
                                  size_t test_number,
-                                 const char *description)
+                                 const char *description,
+                                 const char *directive)
 {
        struct kunit_suite *suite = is_test ? NULL : test_or_suite;
        struct kunit *test = is_test ? test_or_suite : NULL;
+       const char *directive_header = (status == KUNIT_SKIPPED) ? " # SKIP " : "";
 
        /*
         * We do not log the test suite results as doing so would
         * representation.
         */
        if (suite)
-               pr_info("%s %zd - %s\n",
-                       kunit_status_to_string(is_ok),
-                       test_number, description);
+               pr_info("%s %zd - %s%s%s\n",
+                       kunit_status_to_ok_not_ok(status),
+                       test_number, description, directive_header,
+                       (status == KUNIT_SKIPPED) ? directive : "");
        else
-               kunit_log(KERN_INFO, test, KUNIT_SUBTEST_INDENT "%s %zd - %s",
-                         kunit_status_to_string(is_ok),
-                         test_number, description);
+               kunit_log(KERN_INFO, test,
+                         KUNIT_SUBTEST_INDENT "%s %zd - %s%s%s",
+                         kunit_status_to_ok_not_ok(status),
+                         test_number, description, directive_header,
+                         (status == KUNIT_SKIPPED) ? directive : "");
 }
 
-bool kunit_suite_has_succeeded(struct kunit_suite *suite)
+enum kunit_status kunit_suite_has_succeeded(struct kunit_suite *suite)
 {
        const struct kunit_case *test_case;
+       enum kunit_status status = KUNIT_SKIPPED;
 
        kunit_suite_for_each_test_case(suite, test_case) {
-               if (!test_case->success)
-                       return false;
+               if (test_case->status == KUNIT_FAILURE)
+                       return KUNIT_FAILURE;
+               else if (test_case->status == KUNIT_SUCCESS)
+                       status = KUNIT_SUCCESS;
        }
 
-       return true;
+       return status;
 }
 EXPORT_SYMBOL_GPL(kunit_suite_has_succeeded);
 
        kunit_print_ok_not_ok((void *)suite, false,
                              kunit_suite_has_succeeded(suite),
                              kunit_suite_counter++,
-                             suite->name);
+                             suite->name,
+                             suite->status_comment);
 }
 
 unsigned int kunit_test_case_num(struct kunit_suite *suite,
        test->log = log;
        if (test->log)
                test->log[0] = '\0';
-       test->success = true;
+       test->status = KUNIT_SUCCESS;
+       test->status_comment[0] = '\0';
 }
 EXPORT_SYMBOL_GPL(kunit_init_test);
 
        context.test_case = test_case;
        kunit_try_catch_run(try_catch, &context);
 
-       test_case->success &= test->success;
+       /* Propagate the parameter result to the test case. */
+       if (test->status == KUNIT_FAILURE)
+               test_case->status = KUNIT_FAILURE;
+       else if (test_case->status != KUNIT_FAILURE && test->status == KUNIT_SUCCESS)
+               test_case->status = KUNIT_SUCCESS;
 }
 
 int kunit_run_tests(struct kunit_suite *suite)
 
        kunit_suite_for_each_test_case(suite, test_case) {
                struct kunit test = { .param_value = NULL, .param_index = 0 };
-               test_case->success = true;
+               test_case->status = KUNIT_SKIPPED;
 
                if (test_case->generate_params) {
                        /* Get initial param. */
                                          KUNIT_SUBTEST_INDENT
                                          "# %s: %s %d - %s",
                                          test_case->name,
-                                         kunit_status_to_string(test.success),
+                                         kunit_status_to_ok_not_ok(test.status),
                                          test.param_index + 1, param_desc);
 
                                /* Get next param. */
                        }
                } while (test.param_value);
 
-               kunit_print_ok_not_ok(&test, true, test_case->success,
+               kunit_print_ok_not_ok(&test, true, test_case->status,
                                      kunit_test_case_num(suite, test_case),
-                                     test_case->name);
+                                     test_case->name,
+                                     test.status_comment);
        }
 
        kunit_print_subtest_end(suite);
 static void kunit_init_suite(struct kunit_suite *suite)
 {
        kunit_debugfs_create_suite(suite);
+       suite->status_comment[0] = '\0';
 }
 
 int __kunit_test_suites_init(struct kunit_suite * const * const suites)