Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the fuzz bug #11

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions ci/run_task.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash
#
# Script used to run CI jobs, can also be used from the command line.
#
# Shellcheck can't search dynamic paths
# shellcheck source=/dev/null

set -euox pipefail

Expand Down Expand Up @@ -109,26 +112,23 @@ build_and_test() {
for crate in "${CRATES[@]}"; do
local test_vars_script="$REPO_DIR/$crate/contrib/test_vars.sh"

# Building the fuzz crate is more-or-less just a sanity check.
if [ "$crate" = "fuzz" ]; then
pushd "$REPO_DIR/$crate" > /dev/null
cargo --locked build
popd > /dev/null
break
fi
# Clean variables and also make sure they are defined.
FEATURES_WITH_STD=""
FEATURES_WITH_NO_STD=""
FEATURES_WITHOUT_STD=""
EXAMPLES=""

verbose_say "Sourcing $test_vars_script"
if [ -e "$test_vars_script" ]; then
# Set crate specific variables.
. "$test_vars_script"
else
err "Missing $test_vars_script"
fi
verbose_say "Got vars"
verbose_say "FEATURES_WITH_STD: ${FEATURES_WITH_STD:-}"
verbose_say "FEATURES_WITHOUT_STD: ${FEATURES_WITHOUT_STD:-}"
verbose_say "EXAMPLES: ${EXAMPLES:-}"

verbose_say "Got test vars:"
verbose_say "FEATURES_WITH_STD: ${FEATURES_WITH_STD}"
verbose_say "FEATURES_WITH_NO_STD: ${FEATURES_WITH_NO_STD}"
verbose_say "FEATURES_WITHOUT_STD: ${FEATURES_WITHOUT_STD}"
verbose_say "EXAMPLES: ${EXAMPLES:-}"
fi
pushd "$REPO_DIR/$crate" > /dev/null

do_test
Expand All @@ -143,7 +143,7 @@ do_test() {
$cargo build
$cargo test

if [ -n "${EXAMPLES+x}" ]; then
if [ -n "${EXAMPLES}" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 6646692:

What were these +xs supposed to mean? AFAIK they just ensure that the -n check will always pass and the -z checks never will.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and also I was annoyed at myself for writing syntax that I had to look up when I tried to read it. Hence I added the more brain-dead set the vars to "" in the loop.

for example in $EXAMPLES; do # EXAMPLES is set in contrib/test_vars.sh
name="$(echo "$example" | cut -d ':' -f 1)"
features="$(echo "$example" | cut -d ':' -f 2)"
Expand All @@ -161,21 +161,21 @@ do_test() {
# can be better controlled.
do_feature_matrix() {
# rust-miniscript only: https://github.com/rust-bitcoin/rust-miniscript/issues/681
if [ -n "${FEATURES_WITH_NO_STD+x}" ]; then
if [ -n "${FEATURES_WITH_NO_STD}" ]; then
$cargo build --no-default-features --features="no-std"
$cargo test --no-default-features --features="no-std"

loop_features "no-std" "${FEATURES_WITH_NO_STD:-}"
loop_features "no-std" "${FEATURES_WITH_NO_STD}"
else
$cargo build --no-default-features
$cargo test --no-default-features
fi

if [ -z "${FEATURES_WITH_STD+x}" ]; then
loop_features "std" "${FEATURES_WITH_STD:-}"
if [ -n "${FEATURES_WITH_STD}" ]; then
loop_features "std" "${FEATURES_WITH_STD}"
fi

if [ -z "${FEATURES_WITHOUT_STD+x}" ]; then
if [ -n "${FEATURES_WITHOUT_STD}" ]; then
loop_features "" "$FEATURES_WITHOUT_STD"
fi
}
Expand Down Expand Up @@ -256,9 +256,8 @@ do_dup_deps() {
duplicate_dependencies=$(eval "$tree_cmd")

if [ "$duplicate_dependencies" -ne 0 ]; then
echo "Dependency tree is broken, contains duplicates"
cargo tree --target=all --all-features --duplicates
exit 1
say_err "Dependency tree is broken, contains duplicates"
fi

set -o pipefail
Expand Down