linux/drivers/iio/test/iio-test-gts.c

// SPDX-License-Identifier: GPL-2.0-only
/* Unit tests for IIO light sensor gain-time-scale helpers
 *
 * Copyright (c) 2023 Matti Vaittinen <[email protected]>
 */

#include <kunit/device.h>
#include <kunit/test.h>
#include <linux/device.h>
#include <linux/iio/iio-gts-helper.h>
#include <linux/iio/types.h>

/*
 * Please, read the "rant" from the top of the lib/test_linear_ranges.c if
 * you see a line of helper code which is not being tested.
 *
 * Then, please look at the line which is not being tested. Is this line
 * somehow unusually complex? If answer is "no", then chances are that the
 * "development inertia" caused by adding a test exceeds the benefits.
 *
 * If yes, then adding a test is probably a good idea but please stop for a
 * moment and consider the effort of changing all the tests when code gets
 * refactored. Eventually it neeeds to be.
 */

#define TEST_TSEL_50
#define TEST_TSEL_X_MIN
#define TEST_TSEL_100
#define TEST_TSEL_200
#define TEST_TSEL_400
#define TEST_TSEL_X_MAX

#define TEST_GSEL_1
#define TEST_GSEL_X_MIN
#define TEST_GSEL_4
#define TEST_GSEL_16
#define TEST_GSEL_32
#define TEST_GSEL_64
#define TEST_GSEL_256
#define TEST_GSEL_512
#define TEST_GSEL_1024
#define TEST_GSEL_2048
#define TEST_GSEL_4096
#define TEST_GSEL_X_MAX

#define TEST_SCALE_1X
#define TEST_SCALE_MIN_X
#define TEST_SCALE_2X
#define TEST_SCALE_4X
#define TEST_SCALE_8X
#define TEST_SCALE_16X
#define TEST_SCALE_32X
#define TEST_SCALE_64X

#define TEST_SCALE_NANO_128X
#define TEST_SCALE_NANO_256X
#define TEST_SCALE_NANO_512X
#define TEST_SCALE_NANO_1024X
#define TEST_SCALE_NANO_2048X
#define TEST_SCALE_NANO_4096X
#define TEST_SCALE_NANO_4096X2
#define TEST_SCALE_NANO_4096X4
#define TEST_SCALE_NANO_4096X8

#define TEST_SCALE_NANO_MAX_X

/*
 * Can't have this allocated from stack because the kunit clean-up will
 * happen only after the test function has already gone
 */
static struct iio_gts gts;

/* Keep the gain and time tables unsorted to test the sorting */
static const struct iio_gain_sel_pair gts_test_gains[] =;

static const struct iio_itime_sel_mul gts_test_itimes[] =;
#define TOTAL_GAIN_MAX
#define IIO_GTS_TEST_DEV

static struct device *__test_init_iio_gain_scale(struct kunit *test,
		struct iio_gts *gts, const struct iio_gain_sel_pair *g_table,
		int num_g, const struct iio_itime_sel_mul *i_table, int num_i)
{}

#define test_init_iio_gain_scale(test, gts)

static void test_init_iio_gts_invalid(struct kunit *test)
{}

static void test_iio_gts_find_gain_for_scale_using_time(struct kunit *test)
{}

static void test_iio_gts_find_new_gain_sel_by_old_gain_time(struct kunit *test)
{}

static void test_iio_find_closest_gain_low(struct kunit *test)
{}

static void test_iio_gts_total_gain_to_scale(struct kunit *test)
{}

static void test_iio_gts_chk_times(struct kunit *test, const int *vals)
{}

static void test_iio_gts_chk_scales_all(struct kunit *test, struct iio_gts *gts,
					const int *vals, int len)
{}

static void test_iio_gts_chk_scales_t200(struct kunit *test, struct iio_gts *gts,
					 const int *vals, int len)
{}

static void test_iio_gts_avail_test(struct kunit *test)
{}

static struct kunit_case iio_gts_test_cases[] =;

static struct kunit_suite iio_gts_test_suite =;

kunit_test_suite();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_IMPORT_NS();