mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 08:34:19 +01:00
Make Miri easier to run
This commit is contained in:
31
simulator/run-miri.sh
Executable file
31
simulator/run-miri.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARGS=("$@")
|
||||
|
||||
# Intercept the seed if it's passed
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-s=*|--seed=*)
|
||||
seed="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
-s|--seed)
|
||||
seed="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# Otherwise make one up
|
||||
if [ -z "$seed" ]; then
|
||||
# Dump 8 bytes of /dev/random as decimal u64
|
||||
seed=$(od -An -N8 -tu8 /dev/random | tr -d ' ')
|
||||
ARGS+=("--seed" "${seed}")
|
||||
echo "Generated seed for Miri and simulator: ${seed}"
|
||||
else
|
||||
echo "Intercepted simulator seed to pass to Miri: ${seed}"
|
||||
fi
|
||||
|
||||
MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows -Zmiri-seed=${seed}" cargo +nightly miri run --bin limbo_sim -- "${ARGS[@]}"
|
||||
@@ -30,7 +30,7 @@ pub struct SimulatorCLI {
|
||||
short = 'n',
|
||||
long,
|
||||
help = "change the maximum size of the randomly generated sequence of interactions",
|
||||
default_value_t = 5000,
|
||||
default_value_t = normal_or_miri(5000, 50),
|
||||
value_parser = clap::value_parser!(u32).range(1..)
|
||||
)]
|
||||
pub maximum_tests: u32,
|
||||
@@ -38,7 +38,7 @@ pub struct SimulatorCLI {
|
||||
short = 'k',
|
||||
long,
|
||||
help = "change the minimum size of the randomly generated sequence of interactions",
|
||||
default_value_t = 1000,
|
||||
default_value_t = normal_or_miri(1000, 10),
|
||||
value_parser = clap::value_parser!(u32).range(1..)
|
||||
)]
|
||||
pub minimum_tests: u32,
|
||||
@@ -149,7 +149,8 @@ pub struct SimulatorCLI {
|
||||
pub keep_files: bool,
|
||||
#[clap(
|
||||
long,
|
||||
help = "Disable the SQLite integrity check at the end of a simulation"
|
||||
help = "Disable the SQLite integrity check at the end of a simulation",
|
||||
default_value_t = normal_or_miri(false, true)
|
||||
)]
|
||||
pub disable_integrity_check: bool,
|
||||
#[clap(
|
||||
@@ -279,3 +280,7 @@ impl ValueParserFactory for ProfileType {
|
||||
ProfileTypeParser
|
||||
}
|
||||
}
|
||||
|
||||
const fn normal_or_miri<T: Copy>(normal_val: T, miri_val: T) -> T {
|
||||
if cfg!(miri) { miri_val } else { normal_val }
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct Opts {
|
||||
short = 'i',
|
||||
long,
|
||||
help = "the number of iterations",
|
||||
default_value_t = 100000
|
||||
default_value_t = normal_or_miri(100_000, 1000)
|
||||
)]
|
||||
pub nr_iterations: usize,
|
||||
|
||||
@@ -75,3 +75,11 @@ pub struct Opts {
|
||||
)]
|
||||
pub busy_timeout: u64,
|
||||
}
|
||||
|
||||
const fn normal_or_miri<T: Copy>(normal_val: T, miri_val: T) -> T {
|
||||
if cfg!(miri) {
|
||||
miri_val
|
||||
} else {
|
||||
normal_val
|
||||
}
|
||||
}
|
||||
|
||||
4
stress/run-miri.sh
Executable file
4
stress/run-miri.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" cargo +nightly miri run -p turso_stress -- "$@"
|
||||
Reference in New Issue
Block a user