tests_common.h 2.85 KB
/****************************************************************************
 *
 *   Copyright (c) 2019 Todd Stellanova. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name of the copyright holder nor the names of its
 *    contributors may be  used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ****************************************************************************/

#ifndef ECL_TESTS_COMMON_H
#define ECL_TESTS_COMMON_H

#include <validation/data_validator.h>

/**
 * Insert a series of samples around a mean value
 * @param validator The validator under test
 * @param mean The mean value
 * @param count The number of samples to insert in the validator
 * @param rms_err (out) calculated rms error of the inserted samples
 * @param timestamp_io (in/out) in: start timestamp, out: last timestamp
 */
void insert_values_around_mean(DataValidator *validator, const float mean, uint32_t count, float *rms_err,
			       uint64_t *timestamp_io);

/**
 * Print out the state of a DataValidator
 * @param validator
 */
void dump_validator_state(DataValidator *validator);

/**
 * Insert a time series of samples into the validator
 * @param validator
 * @param incr_value The amount to increment the value by on each iteration
 * @param value_io (in/out) in: initial value, out: final value
 * @param timestamp_io (in/out) in: initial timestamp, out: final timestamp
 */
void fill_validator_with_samples(DataValidator *validator,
				 const float incr_value,
				 float *value_io,
				 uint64_t *timestamp_io);

#endif //ECL_TESTS_COMMON_H