Rename testcrate to builtins-test

The repo will soon have `libm` as a top-level crate, so make it clear
that this is only the test crate for `compiler-builtins`.
This commit is contained in:
Trevor Gross 2025-03-18 09:52:53 +00:00 committed by Trevor Gross
parent 3ea9f849d5
commit 92b1e8454d
35 changed files with 38 additions and 37 deletions

View file

@ -2,16 +2,16 @@
resolver = "3"
members = [
# Note that builtins-test-intrinsics cannot be a default member because it
# needs the `mangled-names` feature disabled, while `testcrate` needs it
# enabled.
# needs the `mangled-names` feature disabled, while `builtins-test` needs
# it enabled.
"builtins-test",
"builtins-test-intrinsics",
"compiler-builtins",
"testcrate",
]
default-members = [
"compiler-builtins",
"testcrate",
"builtins-test",
]
[profile.release]

View file

@ -1,5 +1,5 @@
[package]
name = "testcrate"
name = "builtins-test"
version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
edition = "2024"
@ -56,8 +56,9 @@ icount = ["dep:iai-callgrind"]
benchmarking-reports = ["criterion/plotters", "criterion/html_reports"]
# NOTE: benchmarks must be run with `--no-default-features` or with
# `-p testcrate`, otherwise the default `compiler-builtins` feature of the
# `compiler_builtins` crate gets activated, resulting in linker errors.
# `-p builtins-test`, otherwise the default `compiler-builtins` feature
# of the `compiler_builtins` crate gets activated, resulting in linker
# errors.
[[bench]]
name = "float_add"

View file

@ -1,8 +1,8 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::add;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
float_bench! {
name: add_f32,

View file

@ -1,7 +1,7 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
use compiler_builtins::float::cmp;

View file

@ -1,9 +1,9 @@
#![allow(improper_ctypes)]
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::conv;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
/* unsigned int -> float */

View file

@ -1,8 +1,8 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::div;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
float_bench! {
name: div_f32,

View file

@ -2,9 +2,9 @@
#![cfg_attr(f128_enabled, feature(f128))]
#![cfg_attr(f16_enabled, feature(f16))]
use builtins_test::float_bench;
use compiler_builtins::float::extend;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
#[cfg(f16_enabled)]
float_bench! {

View file

@ -1,8 +1,8 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::mul;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
float_bench! {
name: mul_f32,

View file

@ -1,8 +1,8 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::pow;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
float_bench! {
name: powi_f32,

View file

@ -1,8 +1,8 @@
#![cfg_attr(f128_enabled, feature(f128))]
use builtins_test::float_bench;
use compiler_builtins::float::sub;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
float_bench! {
name: sub_f32,

View file

@ -1,9 +1,9 @@
#![cfg_attr(f128_enabled, feature(f128))]
#![cfg_attr(f16_enabled, feature(f16))]
use builtins_test::float_bench;
use compiler_builtins::float::trunc;
use criterion::{Criterion, criterion_main};
use testcrate::float_bench;
#[cfg(f16_enabled)]
float_bench! {

View file

@ -7,8 +7,8 @@
//! edge case testing is crucial for checking cases like where both inputs are equal or equal to
//! special values such as `i128::MIN`, which is unlikely for the random fuzzer by itself to
//! encounter. The randomized fuzz testing is specially designed to cover wide swaths of search
//! space in as few iterations as possible. See `fuzz_values` in `testcrate/tests/misc.rs` for an
//! example.
//! space in as few iterations as possible. See `fuzz_values` in `builtins-test/tests/misc.rs` for
//! an example.
//!
//! Some floating point tests are disabled for specific architectures, because they do not have
//! correct rounding.

View file

@ -1,7 +1,7 @@
#![allow(unused_macros)]
#![cfg_attr(f128_enabled, feature(f128))]
use testcrate::*;
use builtins_test::*;
mod int_addsub {
use super::*;

View file

@ -2,7 +2,7 @@
#![allow(unreachable_code)]
#![cfg_attr(f128_enabled, feature(f128))]
use testcrate::*;
use builtins_test::*;
mod float_comparisons {
use super::*;

View file

@ -4,9 +4,9 @@
#![allow(unused_macros)]
#![allow(unused_imports)]
use builtins_test::*;
use compiler_builtins::float::Float;
use rustc_apfloat::{Float as _, FloatConvert as _};
use testcrate::*;
mod i_to_f {
use super::*;

View file

@ -4,7 +4,7 @@
use compiler_builtins::int::sdiv::{__divmoddi4, __divmodsi4, __divmodti4};
use compiler_builtins::int::udiv::{__udivmoddi4, __udivmodsi4, __udivmodti4, u128_divide_sparc};
use testcrate::*;
use builtins_test::*;
// Division algorithms have by far the nastiest and largest number of edge cases, and experience shows
// that sometimes 100_000 iterations of the random fuzzer is needed.

View file

@ -2,7 +2,7 @@
#![cfg_attr(f128_enabled, feature(f128))]
#![cfg(not(all(target_arch = "x86", not(target_feature = "sse"))))]
use testcrate::*;
use builtins_test::*;
// This is approximate because of issues related to
// https://github.com/rust-lang/rust/issues/73920.

View file

@ -14,7 +14,7 @@ mod cas {
pub(super) macro test($_ordering:ident, $bytes:tt, $name:ident) {
#[test]
fn $name() {
testcrate::fuzz_2(10000, |expected: super::int_ty!($bytes), new| {
builtins_test::fuzz_2(10000, |expected: super::int_ty!($bytes), new| {
let mut target = expected.wrapping_add(10);
assert_eq!(
unsafe {
@ -50,7 +50,7 @@ mod swap {
pub(super) macro test($_ordering:ident, $bytes:tt, $name:ident) {
#[test]
fn $name() {
testcrate::fuzz_2(10000, |left: super::int_ty!($bytes), mut right| {
builtins_test::fuzz_2(10000, |left: super::int_ty!($bytes), mut right| {
let orig_right = right;
assert_eq!(
unsafe { compiler_builtins::aarch64_linux::$name::$name(left, &mut right) },
@ -69,7 +69,7 @@ macro_rules! test_op {
($_ordering:ident, $bytes:tt, $name:ident) => {
#[test]
fn $name() {
testcrate::fuzz_2(10000, |old, val| {
builtins_test::fuzz_2(10000, |old, val| {
let mut target = old;
let op: fn(super::int_ty!($bytes), super::int_ty!($bytes)) -> _ = $($op)*;
let expected = op(old, val);

View file

@ -1,7 +1,7 @@
// makes configuration easier
#![allow(unused_macros)]
use testcrate::*;
use builtins_test::*;
/// Make sure that the the edge case tester and randomized tester don't break, and list examples of
/// fuzz values for documentation purposes.

View file

@ -1,7 +1,7 @@
#![allow(unused_macros)]
#![cfg_attr(f128_enabled, feature(f128))]
use testcrate::*;
use builtins_test::*;
mod int_mul {
use super::*;

View file

@ -1,4 +1,4 @@
use testcrate::*;
use builtins_test::*;
macro_rules! shift {
($($i:ty, $fn_std:ident, $fn_builtins:ident);*;) => {

View file

@ -12,5 +12,5 @@ TARGETS=(x86_64-unknown-linux-gnu
s390x-unknown-linux-gnu)
for TARGET in "${TARGETS[@]}"; do
# Only run the `mem` tests to avoid this taking too long.
cargo miri test --manifest-path testcrate/Cargo.toml --features no-asm --target $TARGET -- mem
cargo miri test --manifest-path builtins-test/Cargo.toml --features no-asm --target $TARGET -- mem
done

View file

@ -23,7 +23,7 @@ fi
if [ "${NO_STD:-}" = "1" ]; then
echo "nothing to do for no_std"
else
run="cargo test --package testcrate --no-fail-fast --target $target"
run="cargo test --package builtins-test --no-fail-fast --target $target"
$run
$run --release
$run --features c
@ -37,8 +37,8 @@ else
fi
if [ "${TEST_VERBATIM:-}" = "1" ]; then
verb_path=$(cmd.exe //C echo \\\\?\\%cd%\\testcrate\\target2)
cargo build --package testcrate \
verb_path=$(cmd.exe //C echo \\\\?\\%cd%\\builtins-test\\target2)
cargo build --package builtins-test \
--target "$target" --target-dir "$verb_path" --features c
fi

View file

@ -68,7 +68,7 @@ mangled-names = []
rustc-dep-of-std = ['compiler-builtins', 'core']
# This makes certain traits and function specializations public that
# are not normally public but are required by the `testcrate`
# are not normally public but are required by the `builtins-test`
public-test-deps = []
[lints.rust]

View file

@ -1,4 +1,4 @@
// Configuration that is shared between `compiler_builtins` and `testcrate`.
// Configuration that is shared between `compiler_builtins` and `builtins_test`.
use std::env;

View file

@ -48,8 +48,8 @@ pub trait Int:
+ ops::BitAnd<Output = Self>
{
/// LUT used for maximizing the space covered and minimizing the computational cost of fuzzing
/// in `testcrate`. For example, Self = u128 produces [0,1,2,7,8,15,16,31,32,63,64,95,96,111,
/// 112,119,120,125,126,127].
/// in `builtins-test`. For example, Self = u128 produces [0,1,2,7,8,15,16,31,32,63,64,95,96,
/// 111,112,119,120,125,126,127].
const FUZZ_LENGTHS: [u8; 20] = make_fuzz_lengths(<Self as MinInt>::BITS);
/// The number of entries of `FUZZ_LENGTHS` actually used. The maximum is 20 for u128.