|
| 1 | +#!/usr/bin/env bash |
| 2 | +# requires stage1 rustc built from https://github.com/victor-prokhorov/rust/commit/a9d5767288d132bc3688799ad45c4647b7043f7d |
| 3 | +# which is a clone of https://github.com/rust-lang/rust/pull/78515 |
| 4 | +set -euo pipefail |
| 5 | + |
| 6 | +COREUTILS_DIR=/home/victorprokhorov/coreutils |
| 7 | +RUST_DIR=/home/victorprokhorov/rust-lang/rust |
| 8 | +GNU_DIR=/home/victorprokhorov/gnu |
| 9 | +STAGE1_SYSROOT_LIB="$RUST_DIR/build/aarch64-unknown-linux-gnu/stage1/lib/rustlib/aarch64-unknown-linux-gnu/lib" |
| 10 | +STAGE1_RUSTC="$RUST_DIR/build/aarch64-unknown-linux-gnu/stage1/bin/rustc" |
| 11 | + |
| 12 | +ok() { echo " OK $*"; } |
| 13 | +fail() { echo "FAIL $*"; exit 1; } |
| 14 | +step() { echo; echo "$*"; } |
| 15 | + |
| 16 | +step "build stdlib" |
| 17 | +cd "$RUST_DIR" |
| 18 | +python3 x.py build library |
| 19 | +ok "stdlib built" |
| 20 | + |
| 21 | +step "toolchain check" |
| 22 | +rustup run stage1 rustc --version | grep -q 'rustc' \ |
| 23 | + || fail "stage1 toolchain not found" |
| 24 | +ok "$(rustup run stage1 rustc --version)" |
| 25 | +rustup run stage1 rustc --edition 2021 -C prefer-dynamic \ |
| 26 | + -o /tmp/poc_api_check - <<'RUST' \ |
| 27 | + || fail "stdout_switchable_buffering or set_buffer_mode not found in stage1 stdlib" |
| 28 | +#![feature(stdout_switchable_buffering)] |
| 29 | +use std::io::{self, BufferMode}; |
| 30 | +fn main() { io::stdout().lock().set_buffer_mode(BufferMode::Line); } |
| 31 | +RUST |
| 32 | +ok "stage1 stdlib has stdout_switchable_buffering and set_buffer_mode" |
| 33 | + |
| 34 | +step "cargo +stage1 build" |
| 35 | +cd "$COREUTILS_DIR" |
| 36 | +RUSTC="$STAGE1_RUSTC" cargo build -p uu_stdbuf_libstdbuf -p uu_stdbuf -p uu_uniq |
| 37 | + |
| 38 | +step "block buffering test all lines must appear together at the end" |
| 39 | +rustup run stage1 rustc --edition 2021 -C prefer-dynamic \ |
| 40 | + -o /tmp/poc_block_test - <<'RUST' || fail "compile poc_block_test" |
| 41 | +#![feature(stdout_switchable_buffering)] |
| 42 | +use std::io::{self, BufferMode}; |
| 43 | +fn main() { |
| 44 | + io::stdout().lock().set_buffer_mode(BufferMode::Block); |
| 45 | + for line in ["1", "2", "3", "soleil"] { |
| 46 | + println!("{line}"); |
| 47 | + std::thread::sleep(std::time::Duration::from_secs(1)); |
| 48 | + } |
| 49 | +} |
| 50 | +RUST |
| 51 | +LD_LIBRARY_PATH="$STAGE1_SYSROOT_LIB" /tmp/poc_block_test |
| 52 | + |
| 53 | +step "GNU compliance tests/misc/stdbuf.sh" |
| 54 | +cd "$COREUTILS_DIR" |
| 55 | +path_UUTILS="$COREUTILS_DIR" path_GNU="$GNU_DIR" PROFILE=debug \ |
| 56 | + util/run-gnu-test.sh tests/misc/stdbuf.sh |
0 commit comments