Skip to content

Commit

Permalink
tests: Extract test-helper into its own repository
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Oct 4, 2024
1 parent 892063e commit 51d5755
Show file tree
Hide file tree
Showing 265 changed files with 273 additions and 32,128 deletions.
28 changes: 0 additions & 28 deletions .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ adde
aghi
alcgr
algr
allnoconfig
amocas
aosp
aqrl
armasm
armreg
Auxinfo
auxv
auxvec
bitops
bminor
callthru
casp
cbnz
Expand All @@ -34,30 +31,25 @@ cpsie
CPSR
cpuid
cpus
cputable
csel
cset
csrrci
csrsi
cxchg
cxchgweak
DESTDIR
dlfcn
dlsym
DWCAS
ecall
EINVAL
elems
ENOENT
espup
evbmips
exynos
fild
fistp
getauxval
getisax
getpid
gettext
gimli
Halfword
HWCAP
Expand Down Expand Up @@ -87,30 +79,23 @@ libatomic's
libcalls
libelf
libfdio
libpthread
libstd
libtcl
libtest
linaro
linkall
locgr
locgre
loongson
lqarx
lrcpc
lwsync
mabi
machdep
macppc
MAXNAME
maxu
mbig
mfcr
mfence
mgba
midr
minu
mipsn
miscompiles
mmfr
movlps
Expand All @@ -124,10 +109,7 @@ newrepo
newtype
nngrk
nostartfiles
nostdinc
octeon
opensbi
osfmk
osxsave
phdr
picolibc
Expand All @@ -136,17 +118,12 @@ prctl
prefetcher
PRIMASK
quadword
quic
RAII
rcpc
reentrancy
revidr
richlowe
rsbegin
rsend
rseq
rsil
RTLD
sbcs
selgr
seqlock
Expand All @@ -164,8 +141,6 @@ sreg
srlw
sstatus
stdarch
stdbool
stddef
stilp
stlxp
stpq
Expand All @@ -183,13 +158,10 @@ sysctlbyname
sysctlnode
systemsim
tagme
uapi
uart
umax
umin
unclonable
unistd
unparse
usart
uscat
uwrite
Expand Down
3 changes: 0 additions & 3 deletions .github/.cspell/rust-dependencies.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -714,24 +714,6 @@ jobs:
steps:
- uses: taiki-e/checkout-action@v1
- uses: taiki-e/github-actions/install-rust@nightly
- run: |
retry() {
for i in {1..10}; do
if "$@"; then
return 0
else
sleep "${i}"
fi
done
"$@"
}
retry sudo apt-get -o Acquire::Retries=10 -qq update
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends \
gcc-aarch64-linux-gnu \
gcc-powerpc64-linux-gnu \
gcc-powerpc64le-linux-gnu \
gcc-riscv64-linux-gnu \
gettext
- run: tools/no_atomic.sh
- run: tools/gen.sh
- id: diff
Expand Down
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ serde = { version = "1.0.60", optional = true, default-features = false }
critical-section = { version = "1", optional = true }

[dev-dependencies]
test-helper = { path = "tests/helper", features = ["std", "critical-section"] }
test-helper = { git = "https://github.com/taiki-e/test-helper.git", branch = "main", features = ["std", "sys", "cpuinfo", "critical-section"] }

build-context = "0.1"
crossbeam-utils = "=0.8.16" # The latest crossbeam-utils requires Rust 1.60
Expand All @@ -93,6 +93,15 @@ serde_test = { git = "https://github.com/taiki-e/serde_test.git", branch = "dev"
sptr = "0.3"
static_assertions = "1"

[target.'cfg(unix)'.dev-dependencies]
libc = "0.2.140"

[target.'cfg(windows)'.dev-dependencies]
windows-sys = { version = "0.59", features = [
"Win32_Foundation",
"Win32_System_Threading",
] }

[lints]
workspace = true

Expand All @@ -101,8 +110,6 @@ members = [
"bench",
"portable-atomic-util",
"tests/api-test",
"tests/helper",
"tools/codegen",
]

# This table is shared by projects under github.com/taiki-e.
Expand Down
11 changes: 10 additions & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fallback = []
std = []

[dev-dependencies]
test-helper = { path = "../tests/helper", features = ["std"] }
test-helper = { git = "https://github.com/taiki-e/test-helper.git", branch = "main", features = ["std", "sys", "cpuinfo", "critical-section"] }

# atomic = "0.6"
build-context = "0.1"
Expand All @@ -22,6 +22,15 @@ paste = "1"
quickcheck = { default-features = false, git = "https://github.com/taiki-e/quickcheck.git", branch = "dev" } # https://github.com/BurntSushi/quickcheck/pull/304 + https://github.com/BurntSushi/quickcheck/pull/282 + https://github.com/BurntSushi/quickcheck/pull/296 + lower MSRV
static_assertions = "1"

[target.'cfg(unix)'.dev-dependencies]
libc = "0.2.140"

[target.'cfg(windows)'.dev-dependencies]
windows-sys = { version = "0.59", features = [
"Win32_Foundation",
"Win32_System_Threading",
] }

[[bench]]
name = "bench"
harness = false
Expand Down
4 changes: 2 additions & 2 deletions src/imp/detect/aarch64_aa64reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ mod tests {
const _: fn() = || {
use imp::ffi;
use std::mem;
use test_helper::{libc, sys};
use test_helper::sys;
// libc doesn't have this
// static_assert!(
// mem::size_of::<ffi::aarch64_sysctl_cpu_id>()
Expand Down Expand Up @@ -563,7 +563,7 @@ mod tests {
)]
const _: fn() = || {
use imp::ffi;
use test_helper::{libc, sys};
use test_helper::sys;
static_assert!(ffi::CTL_MACHDEP == libc::CTL_MACHDEP);
static_assert!(ffi::CTL_MACHDEP == sys::CTL_MACHDEP as ffi::c_int);
// static_assert!(ffi::CPU_ID_AA64ISAR0 == libc::CPU_ID_AA64ISAR0); // libc doesn't have this
Expand Down
4 changes: 2 additions & 2 deletions src/imp/detect/aarch64_apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ mod tests {
#[cfg(not(portable_atomic_no_asm))]
use std::arch::asm;
use std::mem;
use test_helper::{libc, sys};
use test_helper::sys;
// Call syscall using asm instead of libc.
// Note that macOS does not guarantee the stability of raw syscall.
// (And they actually changed it: https://go-review.googlesource.com/c/go/+/25495)
Expand Down Expand Up @@ -274,7 +274,7 @@ mod tests {
clippy::no_effect_underscore_binding
)]
const _: fn() = || {
use test_helper::{libc, sys};
use test_helper::sys;
let mut _sysctlbyname: unsafe extern "C" fn(
*const ffi::c_char,
*mut ffi::c_void,
Expand Down
1 change: 0 additions & 1 deletion src/imp/detect/aarch64_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ mod tests {
clippy::no_effect_underscore_binding
)]
const _: fn() = || {
use test_helper::windows_sys;
let _: ffi::DWORD = 0 as windows_sys::Win32::System::Threading::PROCESSOR_FEATURE_ID;
let _: ffi::BOOL = 0 as windows_sys::Win32::Foundation::BOOL;
let mut _is_processor_feature_present: unsafe extern "system" fn(ffi::DWORD) -> ffi::BOOL =
Expand Down
6 changes: 2 additions & 4 deletions src/imp/detect/auxv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ mod tests {
#[cfg(not(portable_atomic_no_asm))]
use std::arch::asm;
use std::{mem, vec};
use test_helper::{libc, sys};
use test_helper::sys;

// Linux kernel 6.4 has added a way to read auxv without depending on either libc or mrs trap.
// https://github.com/torvalds/linux/commit/ddc65971bb677aa9f6a4c21f76d3133e106f88eb
Expand Down Expand Up @@ -560,7 +560,7 @@ mod tests {
#[cfg(not(portable_atomic_no_asm))]
use std::arch::asm;
use std::{mem, ptr};
use test_helper::{libc, sys};
use test_helper::sys;

// This is almost equivalent to what elf_aux_info does.
// https://man.freebsd.org/elf_aux_info(3)
Expand Down Expand Up @@ -824,8 +824,6 @@ mod tests {
clippy::no_effect_underscore_binding
)]
const _: fn() = || {
#[cfg(not(target_os = "openbsd"))]
use test_helper::libc;
use test_helper::sys;
#[cfg(not(any(target_os = "freebsd", target_os = "openbsd")))]
type AtType = ffi::c_ulong;
Expand Down
2 changes: 1 addition & 1 deletion src/imp/detect/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ mod c_types {
// Static assertions for C type definitions.
#[cfg(test)]
const _: fn() = || {
use test_helper::{libc, sys};
use test_helper::sys;
let _: c_int = 0 as std::os::raw::c_int;
let _: c_uint = 0 as std::os::raw::c_uint;
let _: c_long = 0 as std::os::raw::c_long;
Expand Down
2 changes: 0 additions & 2 deletions src/imp/detect/riscv_linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ mod tests {
// This test tests that our ones and libc::syscall returns the same result.
#[test]
fn test_alternative() {
use test_helper::libc;
unsafe fn __riscv_hwprobe_libc(
pairs: *mut ffi::riscv_hwprobe,
pair_count: ffi::c_size_t,
Expand Down Expand Up @@ -189,7 +188,6 @@ mod tests {
),
)))]
{
use test_helper::libc;
let mut _syscall: unsafe extern "C" fn(num: ffi::c_long, ...) -> ffi::c_long =
ffi::syscall;
_syscall = libc::syscall;
Expand Down
Loading

0 comments on commit 51d5755

Please sign in to comment.