Make CI green again

- disable configure verify check
- update configure file and make clippy happy
- check autoconf version
- fix allow_failures
- i686-apple target are not supported now
- use latest travis syntax
- less verbose and allow non-master check fail
    Upstream doesn't guarantee configure file matches across platform and
    versions. Checking configure file can fail easily
- mute alloc_trait tests
- rich diff
- remove unsupported platform
    i686-apple-darwin is removed from nightly and beta.
- make clippy and rustfmt happy

Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
Jay Lee 2020-07-17 21:22:46 +08:00
parent c27a859e98
commit a09f18a739
No known key found for this signature in database
GPG Key ID: CF3437B6A06C22F9
9 changed files with 81 additions and 84 deletions

View File

@ -2,7 +2,7 @@ language: rust
rust: nightly rust: nightly
services: docker services: docker
matrix: jobs:
include: include:
# Linux # Linux
- name: "aarch64-unknown-linux-gnu" - name: "aarch64-unknown-linux-gnu"
@ -72,7 +72,8 @@ matrix:
install: true install: true
script: script:
- cargo test --bench roundtrip - cargo test --bench roundtrip
- cargo test --features=alloc_trait --bench roundtrip # FIXME: Re-enable this when allocator API is stable.
# - cargo test --features=alloc_trait --bench roundtrip
- name: "x86_64-unknown-linux-musl" - name: "x86_64-unknown-linux-musl"
env: TARGET=x86_64-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1 env: TARGET=x86_64-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1
@ -86,24 +87,10 @@ matrix:
# FIXME: cannot jemalloc tests fail due to: # FIXME: cannot jemalloc tests fail due to:
# https://github.com/jemalloc/jemalloc/issues/1320 # https://github.com/jemalloc/jemalloc/issues/1320
# https://github.com/gnzlbg/jemallocator/issues/85 # https://github.com/gnzlbg/jemallocator/issues/85
- name: "i686-apple-darwin (nightly)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
- name: "i686-apple-darwin (beta)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: beta
- name: "i686-apple-darwin (stable)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: stable
# FIXME: valgrind fails on OSX # FIXME: valgrind fails on OSX
# https://github.com/gnzlbg/jemallocator/issues/86 # https://github.com/gnzlbg/jemallocator/issues/86
- name: "x86_64-apple-darwin (nightly)" - name: "x86_64-apple-darwin (nightly)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 JEMALLOC_SYS_VERIFY_CONFIGURE=1 env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 # JEMALLOC_SYS_VERIFY_CONFIGURE=1
os: osx os: osx
osx_image: xcode10 osx_image: xcode10
install: rustup component add llvm-tools-preview install: rustup component add llvm-tools-preview
@ -132,7 +119,7 @@ matrix:
deploy: deploy:
provider: script provider: script
script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out) script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
skip_cleanup: true cleanup: true
on: on:
branch: master branch: master
- name: "rustfmt" - name: "rustfmt"
@ -148,10 +135,10 @@ matrix:
# allow(clippy::all) fails in the syscrate, so we can't use --all here: # allow(clippy::all) fails in the syscrate, so we can't use --all here:
script: | script: |
if rustup component add clippy-preview ; then if rustup component add clippy-preview ; then
cargo clippy -p jemalloc-sys -- -D clippy::pedantic cargo clippy -p jemalloc-sys -- -D clippy::all
cargo clippy -p jemallocator -- -D clippy::pedantic cargo clippy -p jemallocator -- -D clippy::all
cargo clippy -p jemallocator-global -- -D clippy::pedantic cargo clippy -p jemallocator-global -- -D clippy::all
cargo clippy -p jemalloc-ctl -- -D clippy::pedantic cargo clippy -p jemalloc-ctl -- -D clippy::all
fi fi
- name: "Shellcheck" - name: "Shellcheck"
install: true install: true

View File

@ -233,7 +233,6 @@ mod pow2 {
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072,
4194304 4194304
]); ]);
} }
mod even { mod even {

View File

@ -55,7 +55,11 @@ fi
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${TARGET}" = "x86_64-apple-darwin" ] if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]
then then
${CARGO_CMD} build -vv --target "${TARGET}" 2>&1 | tee build_no_std.txt # Not using tee to avoid too much logs that exceeds travis' limit.
if ! ${CARGO_CMD} build -vv --target "${TARGET}" > build_no_std.txt 2>&1; then
tail -n 1024 build_no_std.txt
exit 1
fi
# Check that the no-std builds are not linked against a libc with default # Check that the no-std builds are not linked against a libc with default
# features or the `use_std` feature enabled: # features or the `use_std` feature enabled:
@ -71,42 +75,42 @@ then
done done
fi fi
${CARGO_CMD} test -vv --target "${TARGET}" ${CARGO_CMD} test --target "${TARGET}"
if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then
# FIXME: profiling tests broken on dev-branch # FIXME: profiling tests broken on dev-branch
# https://github.com/jemalloc/jemalloc/issues/1477 # https://github.com/jemalloc/jemalloc/issues/1477
: :
else else
${CARGO_CMD} test -vv --target "${TARGET}" --features profiling ${CARGO_CMD} test --target "${TARGET}" --features profiling
fi fi
${CARGO_CMD} test -vv --target "${TARGET}" --features debug ${CARGO_CMD} test --target "${TARGET}" --features debug
${CARGO_CMD} test -vv --target "${TARGET}" --features stats ${CARGO_CMD} test --target "${TARGET}" --features stats
if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then if [ "${JEMALLOC_SYS_GIT_DEV_BRANCH}" = "1" ]; then
# FIXME: profiling tests broken on dev-branch # FIXME: profiling tests broken on dev-branch
# https://github.com/jemalloc/jemalloc/issues/1477 # https://github.com/jemalloc/jemalloc/issues/1477
: :
else else
${CARGO_CMD} test -vv --target "${TARGET}" --features 'debug profiling' ${CARGO_CMD} test --target "${TARGET}" --features 'debug profiling'
fi fi
${CARGO_CMD} test -vv --target "${TARGET}" \ ${CARGO_CMD} test --target "${TARGET}" \
--features unprefixed_malloc_on_supported_platforms --features unprefixed_malloc_on_supported_platforms
${CARGO_CMD} test -vv --target "${TARGET}" --no-default-features ${CARGO_CMD} test --target "${TARGET}" --no-default-features
${CARGO_CMD} test -vv --target "${TARGET}" --no-default-features \ ${CARGO_CMD} test --target "${TARGET}" --no-default-features \
--features background_threads_runtime_support --features background_threads_runtime_support
if [ "${NOBGT}" = "1" ] if [ "${NOBGT}" = "1" ]
then then
echo "enabling background threads by default at run-time is not tested" echo "enabling background threads by default at run-time is not tested"
else else
${CARGO_CMD} test -vv --target "${TARGET}" --features background_threads ${CARGO_CMD} test --target "${TARGET}" --features background_threads
fi fi
${CARGO_CMD} test -vv --target "${TARGET}" --release ${CARGO_CMD} test --target "${TARGET}" --release
${CARGO_CMD} test -vv --target "${TARGET}" --manifest-path jemalloc-sys/Cargo.toml ${CARGO_CMD} test --target "${TARGET}" --manifest-path jemalloc-sys/Cargo.toml
${CARGO_CMD} test -vv --target "${TARGET}" \ ${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemalloc-sys/Cargo.toml \ --manifest-path jemalloc-sys/Cargo.toml \
--features unprefixed_malloc_on_supported_platforms --features unprefixed_malloc_on_supported_platforms
@ -116,25 +120,26 @@ case "${TARGET}" in
"x86_64-unknown-linux-musl") ;; "x86_64-unknown-linux-musl") ;;
*) *)
${CARGO_CMD} test -vv --target "${TARGET}" \ ${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemalloc-ctl/Cargo.toml \ --manifest-path jemalloc-ctl/Cargo.toml \
--no-default-features --no-default-features
# FIXME: cross fails to pass features to jemalloc-ctl # FIXME: cross fails to pass features to jemalloc-ctl
# ${CARGO_CMD} test -vv --target "${TARGET}" \ # ${CARGO_CMD} test --target "${TARGET}" \
# --manifest-path jemalloc-ctl \ # --manifest-path jemalloc-ctl \
# --no-default-features --features use_std # --no-default-features --features use_std
;; ;;
esac esac
${CARGO_CMD} test -vv --target "${TARGET}" -p systest ${CARGO_CMD} test --target "${TARGET}" -p systest
${CARGO_CMD} test -vv --target "${TARGET}" \ ${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml --manifest-path jemallocator-global/Cargo.toml
${CARGO_CMD} test -vv --target "${TARGET}" \ ${CARGO_CMD} test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml \ --manifest-path jemallocator-global/Cargo.toml \
--features force_global_jemalloc --features force_global_jemalloc
if [ "${TRAVIS_RUST_VERSION}" = "nightly" ] # FIXME: Re-enable following test when allocator API is stable again.
then # if [ "${TRAVIS_RUST_VERSION}" = "nightly" ]
# The Alloc trait is unstable: # then
${CARGO_CMD} test -vv --target "${TARGET}" --features alloc_trait # # The Alloc trait is unstable:
fi # ${CARGO_CMD} test --target "${TARGET}" --features alloc_trait
# fi

View File

@ -46,7 +46,6 @@ pub trait AsName {
impl AsName for [u8] { impl AsName for [u8] {
fn name(&self) -> &Name { fn name(&self) -> &Name {
use str;
assert!( assert!(
!self.is_empty(), !self.is_empty(),
"cannot create Name from empty byte-string" "cannot create Name from empty byte-string"
@ -125,14 +124,12 @@ impl Name {
impl fmt::Debug for Name { impl fmt::Debug for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use str;
write!(f, "{}", str::from_utf8(&self.0).unwrap()) write!(f, "{}", str::from_utf8(&self.0).unwrap())
} }
} }
impl fmt::Display for Name { impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use str;
write!(f, "{}", str::from_utf8(&self.0).unwrap()) write!(f, "{}", str::from_utf8(&self.0).unwrap())
} }
} }

View File

@ -13,7 +13,6 @@ extern crate fs_extra;
use std::env; use std::env;
use std::fs; use std::fs;
use std::fs::File;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command; use std::process::Command;
@ -54,6 +53,8 @@ macro_rules! warning {
} }
} }
// TODO: split main functions and remove following allow.
#[allow(clippy::cognitive_complexity)]
fn main() { fn main() {
let target = env::var("TARGET").expect("TARGET was not set"); let target = env::var("TARGET").expect("TARGET was not set");
let host = env::var("HOST").expect("HOST was not set"); let host = env::var("HOST").expect("HOST was not set");
@ -61,9 +62,9 @@ fn main() {
let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR was not set")); let out_dir = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR was not set"));
let src_dir = env::current_dir().expect("failed to get current directory"); let src_dir = env::current_dir().expect("failed to get current directory");
info!("TARGET={}", target.clone()); info!("TARGET={}", target);
info!("HOST={}", host.clone()); info!("HOST={}", host);
info!("NUM_JOBS={}", num_jobs.clone()); info!("NUM_JOBS={}", num_jobs);
info!("OUT_DIR={:?}", out_dir); info!("OUT_DIR={:?}", out_dir);
let build_dir = out_dir.join("build"); let build_dir = out_dir.join("build");
info!("BUILD_DIR={:?}", build_dir); info!("BUILD_DIR={:?}", build_dir);
@ -185,28 +186,11 @@ fn main() {
run(&mut cmd); run(&mut cmd);
for f in &config_files { for f in &config_files {
use std::io::Read;
fn read_content(file_path: &Path) -> String {
assert!(
file_path.exists(),
"config file path `{}` does not exist",
file_path.display()
);
let mut file = File::open(file_path).expect("file not found");
let mut content = String::new();
file.read_to_string(&mut content)
.expect("failed to read file");
content
}
if verify_configure { if verify_configure {
let current = read_content(&jemalloc_src_dir.join(f)); let mut cmd = Command::new("diff");
let reference = read_content(&Path::new("configure").join(f)); run(cmd
assert_eq!( .arg(&jemalloc_src_dir.join(f))
current, reference, .arg(&Path::new("configure").join(f)));
"the current and reference configuration files \"{}\" differ",
f
);
} }
} }
} else { } else {
@ -231,7 +215,7 @@ fn main() {
.env("CC", compiler.path()) .env("CC", compiler.path())
.env("CFLAGS", cflags.clone()) .env("CFLAGS", cflags.clone())
.env("LDFLAGS", cflags.clone()) .env("LDFLAGS", cflags.clone())
.env("CPPFLAGS", cflags.clone()) .env("CPPFLAGS", cflags)
.arg("--disable-cxx"); .arg("--disable-cxx");
if target.contains("ios") { if target.contains("ios") {
@ -361,7 +345,7 @@ fn main() {
.arg("install_lib_static") .arg("install_lib_static")
.arg("install_include") .arg("install_include")
.arg("-j") .arg("-j")
.arg(num_jobs.clone())); .arg(num_jobs));
println!("cargo:root={}", out_dir.display()); println!("cargo:root={}", out_dir.display());

View File

@ -744,6 +744,7 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -849,6 +850,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE}' docdir='${datarootdir}/doc/${PACKAGE}'
@ -1101,6 +1103,15 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1238,7 +1249,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir libdir localedir mandir runstatedir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1391,6 +1402,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]

View File

@ -49,7 +49,7 @@ use libc::{c_int, c_void};
target_arch = "mipsel", target_arch = "mipsel",
target_arch = "powerpc" target_arch = "powerpc"
)))] )))]
const alignof_max_align_t: usize = 8; const ALIGNOF_MAX_ALIGN_T: usize = 8;
#[cfg(all(any( #[cfg(all(any(
target_arch = "x86", target_arch = "x86",
target_arch = "x86_64", target_arch = "x86_64",
@ -60,7 +60,7 @@ const alignof_max_align_t: usize = 8;
target_arch = "s390x", target_arch = "s390x",
target_arch = "sparc64" target_arch = "sparc64"
)))] )))]
const alignof_max_align_t: usize = 16; const ALIGNOF_MAX_ALIGN_T: usize = 16;
/// If `align` is less than `_Alignof(max_align_t)`, and if the requested /// If `align` is less than `_Alignof(max_align_t)`, and if the requested
/// allocation `size` is larger than the alignment, we are guaranteed to get a /// allocation `size` is larger than the alignment, we are guaranteed to get a
@ -69,7 +69,7 @@ const alignof_max_align_t: usize = 16;
/// ///
/// Otherwise, it returns the alignment flag to pass to the jemalloc APIs. /// Otherwise, it returns the alignment flag to pass to the jemalloc APIs.
fn layout_to_flags(align: usize, size: usize) -> c_int { fn layout_to_flags(align: usize, size: usize) -> c_int {
if align <= alignof_max_align_t && align <= size { if align <= ALIGNOF_MAX_ALIGN_T && align <= size {
0 0
} else { } else {
ffi::MALLOCX_ALIGN(align) ffi::MALLOCX_ALIGN(align)
@ -83,7 +83,7 @@ macro_rules! assume {
if !($e) { if !($e) {
core::hint::unreachable_unchecked(); core::hint::unreachable_unchecked();
} }
} };
} }
/// Handle to the jemalloc allocator /// Handle to the jemalloc allocator
@ -122,7 +122,7 @@ unsafe impl GlobalAlloc for Jemalloc {
#[inline] #[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
assume!(!ptr.is_null()) assume!(!ptr.is_null());
assume!(layout.size() != 0); assume!(layout.size() != 0);
let flags = layout_to_flags(layout.align(), layout.size()); let flags = layout_to_flags(layout.align(), layout.size());
ffi::sdallocx(ptr as *mut c_void, layout.size(), flags) ffi::sdallocx(ptr as *mut c_void, layout.size(), flags)

View File

@ -9,4 +9,4 @@ jemalloc-sys = { path = "../jemalloc-sys" }
libc = "0.2" libc = "0.2"
[build-dependencies] [build-dependencies]
ctest = "^0.2.6" ctest = "0.2.22"

View File

@ -3,6 +3,17 @@ extern crate ctest;
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
const FUNCTION_POINTER: &[&str] = &[
"extent_alloc_t",
"extent_dalloc_t",
"extent_destroy_t",
"extent_commit_t",
"extent_decommit_t",
"extent_purge_t",
"extent_split_t",
"extent_merge_t",
];
fn main() { fn main() {
let root = PathBuf::from(env::var_os("DEP_JEMALLOC_ROOT").unwrap()); let root = PathBuf::from(env::var_os("DEP_JEMALLOC_ROOT").unwrap());
@ -11,7 +22,9 @@ fn main() {
.include(root.join("include")) .include(root.join("include"))
.cfg("prefixed", None) .cfg("prefixed", None)
.fn_cname(|rust, link_name| link_name.unwrap_or(rust).to_string()) .fn_cname(|rust, link_name| link_name.unwrap_or(rust).to_string())
.skip_signededness(|c| c.ends_with("_t")); .skip_signededness(|c| c.ends_with("_t"))
// No need to test pure C function pointer.
.skip_type(|name| FUNCTION_POINTER.contains(&name));
if cfg!(target_os = "linux") { if cfg!(target_os = "linux") {
cfg.skip_fn(|f| f == "malloc_usable_size"); cfg.skip_fn(|f| f == "malloc_usable_size");