linux/lib/kunit/kunit-test.c

// SPDX-License-Identifier: GPL-2.0
/*
 * KUnit test for core test infrastructure.
 *
 * Copyright (C) 2019, Google LLC.
 * Author: Brendan Higgins <[email protected]>
 */
#include "linux/gfp_types.h"
#include <kunit/test.h>
#include <kunit/test-bug.h>

#include <linux/device.h>
#include <kunit/device.h>

#include "string-stream.h"
#include "try-catch-impl.h"

struct kunit_try_catch_test_context {};

static void kunit_test_successful_try(void *data)
{}

static void kunit_test_no_catch(void *data)
{}

static void kunit_test_try_catch_successful_try_no_catch(struct kunit *test)
{}

static void kunit_test_unsuccessful_try(void *data)
{}

static void kunit_test_catch(void *data)
{}

static void kunit_test_try_catch_unsuccessful_try_does_catch(struct kunit *test)
{}

static int kunit_try_catch_test_init(struct kunit *test)
{}

static struct kunit_case kunit_try_catch_test_cases[] =;

static struct kunit_suite kunit_try_catch_test_suite =;

#if IS_ENABLED(CONFIG_KUNIT_FAULT_TEST)

static void kunit_test_null_dereference(void *data)
{}

static void kunit_test_fault_null_dereference(struct kunit *test)
{}

#endif /* CONFIG_KUNIT_FAULT_TEST */

static struct kunit_case kunit_fault_test_cases[] =;

static struct kunit_suite kunit_fault_test_suite =;

/*
 * Context for testing test managed resources
 * is_resource_initialized is used to test arbitrary resources
 */
struct kunit_test_resource_context {};

static int fake_resource_init(struct kunit_resource *res, void *context)
{}

static void fake_resource_free(struct kunit_resource *res)
{}

static void kunit_resource_test_init_resources(struct kunit *test)
{}

static void kunit_resource_test_alloc_resource(struct kunit *test)
{}

static inline bool kunit_resource_instance_match(struct kunit *test,
						 struct kunit_resource *res,
						 void *match_data)
{}

/*
 * Note: tests below use kunit_alloc_and_get_resource(), so as a consequence
 * they have a reference to the associated resource that they must release
 * via kunit_put_resource().  In normal operation, users will only
 * have to do this for cases where they use kunit_find_resource(), and the
 * kunit_alloc_resource() function will be used (which does not take a
 * resource reference).
 */
static void kunit_resource_test_destroy_resource(struct kunit *test)
{}

static void kunit_resource_test_remove_resource(struct kunit *test)
{}

static void kunit_resource_test_cleanup_resources(struct kunit *test)
{}

static void kunit_resource_test_mark_order(int order_array[],
					   size_t order_size,
					   int key)
{}

#define KUNIT_RESOURCE_TEST_MARK_ORDER(ctx, order_field, key)

static int fake_resource_2_init(struct kunit_resource *res, void *context)
{}

static void fake_resource_2_free(struct kunit_resource *res)
{}

static int fake_resource_1_init(struct kunit_resource *res, void *context)
{}

static void fake_resource_1_free(struct kunit_resource *res)
{}

/*
 * TODO([email protected]): replace the arrays that keep track of the
 * order of allocation and freeing with strict mocks using the IN_SEQUENCE macro
 * to assert allocation and freeing order when the feature becomes available.
 */
static void kunit_resource_test_proper_free_ordering(struct kunit *test)
{}

static void kunit_resource_test_static(struct kunit *test)
{}

static void kunit_resource_test_named(struct kunit *test)
{}

static void increment_int(void *ctx)
{}

static void kunit_resource_test_action(struct kunit *test)
{}
static void kunit_resource_test_remove_action(struct kunit *test)
{}
static void kunit_resource_test_release_action(struct kunit *test)
{}
static void action_order_1(void *ctx)
{}
static void action_order_2(void *ctx)
{}
static void kunit_resource_test_action_ordering(struct kunit *test)
{}

static int kunit_resource_test_init(struct kunit *test)
{}

static void kunit_resource_test_exit(struct kunit *test)
{}

static struct kunit_case kunit_resource_test_cases[] =;

static struct kunit_suite kunit_resource_test_suite =;

/*
 * Log tests call string_stream functions, which aren't exported. So only
 * build this code if this test is built-in.
 */
#if IS_BUILTIN(CONFIG_KUNIT_TEST)

/* This avoids a cast warning if kfree() is passed direct to kunit_add_action(). */
KUNIT_DEFINE_ACTION_WRAPPER(kfree_wrapper, kfree, const void *);

static void kunit_log_test(struct kunit *test)
{}

static void kunit_log_newline_test(struct kunit *test)
{}
#else
static void kunit_log_test(struct kunit *test)
{
	kunit_skip(test, "Log tests only run when built-in");
}

static void kunit_log_newline_test(struct kunit *test)
{
	kunit_skip(test, "Log tests only run when built-in");
}
#endif /* IS_BUILTIN(CONFIG_KUNIT_TEST) */

static struct kunit_case kunit_log_test_cases[] =;

static struct kunit_suite kunit_log_test_suite =;

static void kunit_status_set_failure_test(struct kunit *test)
{}

static void kunit_status_mark_skipped_test(struct kunit *test)
{}

static struct kunit_case kunit_status_test_cases[] =;

static struct kunit_suite kunit_status_test_suite =;

static void kunit_current_test(struct kunit *test)
{}

static void kunit_current_fail_test(struct kunit *test)
{}

static struct kunit_case kunit_current_test_cases[] =;

static void test_dev_action(void *priv)
{}

static void kunit_device_test(struct kunit *test)
{}

static void kunit_device_cleanup_test(struct kunit *test)
{}

struct driver_test_state {};

static int driver_probe_hook(struct device *dev)
{}

static int driver_remove_hook(struct device *dev)
{}

static void kunit_device_driver_test(struct kunit *test)
{}

static struct kunit_case kunit_device_test_cases[] =;

static struct kunit_suite kunit_device_test_suite =;

static struct kunit_suite kunit_current_test_suite =;

kunit_test_suites();

MODULE_DESCRIPTION();
MODULE_LICENSE();