mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-08-11 12:19:29 +00:00
e822e429f3 utils: Silence an MSVC warning about conversion from double to float abf8fb0261 utils: Add checkasm_randomize_interval() and float equivalent 7aea236f8f utils: Simplify checkasm_randomize_range() formulation 49972c1c72 utils: Fix advertised value range of checkasm_randf() 11c569cbdc utils: Use appropriate PRNG size for checkasm_init() 6fd9bafd11 utils: Add way more PRNG helper functions d7f10858c8 utils: Use prng() primitive for checkasm_randomize() 781f16f1ac utils: Parallelize PRNG 4681280b65 selftest: Add tests for utils.h functions 02d0b1ee4c Clear CPU state after any checkasm_call() 48821c5d14 Print cpu mask in JSON output 5d500889dc tests/selftest: Test CPU flag masking dbf5380202 tests: Offset arch-specific CPU flags by 10 09b4c6a8c9 include/checkasm.h: Add CheckasmCpuInfo.mask dd1ca4ed09 utils: Document PRNG re-seeding at the start of each test c93961a221 utils: Use substantially more robust PRNG e46c473f73 Re-order conditional (mostly cosmetic) 16738f028d Seed PRNG before running CheckasmTest.init() 9292f9cf6d Bikeshed summary line a bit more, especially for interrupted runs 0f03612ec9 Suppress non-failure output after first iteration bfdb230dd9 checkasm: Print statusline to track current test/bench progress c8996a284b checkasm: Move test iteration variable to global state 46e136ee0e utils: Add self-repainting statusline buffer 800053edca Route all log messages through checkasm_fprintf() f6791fee59 utils: Redefine checkasm_fprintf() as checkasm_vfprintf() 629a211feb Add optional CheckasmTest.init() and uninit() 354f3d3e8d riscv/callcheck: Avoid out-of-range li immediate under LLVM on rv32 6e1b4cd6ca riscv/cpu: Include <asm/unistd.h> for __NR_riscv_hwprobe 8130043b32 Fix CPU detection for AVX512F 9760810b49 Support YMM copy tests on processors with only AVX dc8c320313 Support XMM copy tests on processors with only SSE git-subtree-dir: tests/checkasm/ext git-subtree-split: e822e429f33e4d02e0815bd497952b3f6deb0a7d
119 lines
4.4 KiB
C
119 lines
4.4 KiB
C
/*
|
|
* Copyright © 2025, Niklas Haas
|
|
* 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.
|
|
*
|
|
* 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 CHECKASM_TESTS_H
|
|
#define CHECKASM_TESTS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
#include "src/checkasm_config.h"
|
|
|
|
#include <checkasm/test.h>
|
|
#include <checkasm/utils.h>
|
|
|
|
enum {
|
|
SELFTEST_CPU_FLAG_BAD_C = 1 << 0, // dummy flag for "bad" C implementations
|
|
SELFTEST_CPU_FLAG_A = 1 << 1, // dummy flag for testing flag masking
|
|
SELFTEST_CPU_FLAG_B = 1 << 2,
|
|
SELFTEST_CPU_FLAG_AB = SELFTEST_CPU_FLAG_A | SELFTEST_CPU_FLAG_B,
|
|
#if ARCH_X86
|
|
SELFTEST_CPU_FLAG_X86 = 1 << 10,
|
|
SELFTEST_CPU_FLAG_MMX = 1 << 11,
|
|
SELFTEST_CPU_FLAG_SSE = 1 << 12,
|
|
SELFTEST_CPU_FLAG_AVX = 1 << 13,
|
|
SELFTEST_CPU_FLAG_AVX512 = 1 << 14,
|
|
#elif ARCH_RISCV
|
|
SELFTEST_CPU_FLAG_RVI = 1 << 10,
|
|
SELFTEST_CPU_FLAG_RVF = 1 << 11,
|
|
SELFTEST_CPU_FLAG_RVV = 1 << 12,
|
|
#elif ARCH_AARCH64
|
|
SELFTEST_CPU_FLAG_AARCH64 = 1 << 10,
|
|
#elif ARCH_ARM
|
|
SELFTEST_CPU_FLAG_ARM = 1 << 10,
|
|
SELFTEST_CPU_FLAG_VFP = 1 << 11,
|
|
SELFTEST_CPU_FLAG_VFPD32 = 1 << 12,
|
|
#endif
|
|
};
|
|
|
|
#define DEF_GETTER(FLAG, NAME, func_type, fallback) \
|
|
static func_type *get_##NAME(void) \
|
|
{ \
|
|
return (checkasm_get_cpu_flags() & FLAG) ? selftest_##NAME : fallback; \
|
|
}
|
|
|
|
/* Should return the arch-specific flags */
|
|
uint64_t selftest_get_cpu_flags_x86(void);
|
|
uint64_t selftest_get_cpu_flags_riscv(void);
|
|
uint64_t selftest_get_cpu_flags_aarch64(void);
|
|
uint64_t selftest_get_cpu_flags_arm(void);
|
|
|
|
/**
|
|
* Copy `size` (power-of-two) bytes from aligned buffers `src` to `dst`.
|
|
*/
|
|
typedef void(copy_func)(uint8_t *dst, const uint8_t *src, size_t size);
|
|
void selftest_test_copy(copy_func *func, const char *name, int min_width);
|
|
|
|
#define DEF_COPY_FUNC(NAME) \
|
|
void selftest_##NAME(uint8_t *dst, const uint8_t *src, size_t size)
|
|
|
|
#define DEF_COPY_GETTER(FLAG, NAME) DEF_GETTER(FLAG, NAME, copy_func, selftest_copy_c)
|
|
|
|
/* Reference function for copy routines */
|
|
static inline DEF_COPY_FUNC(copy_c)
|
|
{
|
|
memcpy(dst, src, size);
|
|
}
|
|
|
|
/**
|
|
* Do nothing. Used to test side effects, stack corruption etc.
|
|
* The singular int parameter is just to have at least one parameter,
|
|
* which is required by `declare_func`.
|
|
*/
|
|
typedef void(noop_func)(int unused);
|
|
void selftest_test_noop(noop_func *func, const char *name);
|
|
|
|
#define DEF_NOOP_FUNC(NAME) void selftest_##NAME(int unused)
|
|
#define DEF_NOOP_GETTER(FLAG, NAME) DEF_GETTER(FLAG, NAME, noop_func, NULL)
|
|
|
|
/* Used for testing floating point operations */
|
|
typedef float(float_func)(float input);
|
|
typedef double(double_func)(double input);
|
|
void selftest_test_float(float_func *func, const char *name, float input);
|
|
|
|
#define DEF_FLOAT_FUNC(NAME) float selftest_##NAME(float input)
|
|
|
|
/* Platform-specific tests */
|
|
void selftest_check_generic(void);
|
|
void selftest_check_utils(void);
|
|
void selftest_check_x86(void);
|
|
void selftest_check_riscv(void);
|
|
void selftest_check_aarch64(void);
|
|
void selftest_check_arm(void);
|
|
|
|
#endif /* CHECKASM_TESTS_H */
|