File: ensure_deterministic_build.sh

package info (click to toggle)
rust-wasmtime 27.0.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 53,064 kB
  • sloc: ansic: 4,020; sh: 562; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (45 lines) | stat: -rwxr-xr-x 1,577 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

# This script makes sure that the meta crate deterministically generate files
# with a high probability.
# The current directory must be set to the repository's root.
#
# We set SKIP_ISLE=1 to skip ISLE generation, because it depends on files
# in-tree (cranelift/codegen/.../*.isle) but these are not available when we
# switch to different working directories during this test.

set -e

BUILD_SCRIPT=$(find -wholename "./target/debug/build/cranelift-codegen-*/build-script-build")

# First, run the script to generate a reference comparison.
rm -rf /tmp/reference
mkdir /tmp/reference
SKIP_ISLE=1 OUT_DIR=/tmp/reference TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp $BUILD_SCRIPT

# To make sure the build script doesn't depend on the current directory, we'll
# change the current working directory on every iteration. Make this easy to
# reproduce this locally by first copying the target/ directory into an initial
# temporary directory (and not move and lose the local clone's content).
rm -rf /tmp/src0
mkdir /tmp/src0

echo Copying target directory...
cp -r ./target /tmp/src0/target
cd /tmp/src0
echo "Done, starting loop."

# Then, repeatedly make sure that the output is the same.
for i in {1..20}
do
    # Move to a different directory, as explained above.
    rm -rf /tmp/src$i
    mkdir /tmp/src$i
    mv ./* /tmp/src$i
    cd /tmp/src$i

    rm -rf /tmp/try
    mkdir /tmp/try
    SKIP_ISLE=1 OUT_DIR=/tmp/try TARGET=x86_64 CARGO_PKG_VERSION=0.1.0 CARGO_MANIFEST_DIR=/tmp/src$i $BUILD_SCRIPT
    diff -qr /tmp/reference /tmp/try
done