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

Add option to override --crate-name from kani #3054

Merged
merged 9 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename and add comments to script
  • Loading branch information
adpaco-aws committed Mar 8, 2024
commit b2e765f3a0f909fe29b5ac06a13c00b0fc38a53c
39 changes: 0 additions & 39 deletions tests/script-based-pre/crate-name-default/crate-name-default.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
script: crate-name-default.sh
script: crate-name.sh
expected: crate-name.expected
1 change: 1 addition & 0 deletions tests/script-based-pre/crate-name/crate-name.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
No proof harnesses (functions with #[kani::proof]) were found to verify.
54 changes: 54 additions & 0 deletions tests/script-based-pre/crate-name/crate-name.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT

# This test performs multiple checks focused on crate names. The first steps
# check expected results with the default naming scheme. The remaining ones
# check expected results with the `--crate-name=<name>` feature which allows
# users to specify the crate name used for compilation with standalone `kani`.
set -eu

check_file_exists() {
local file=$1
if ! [ -e "${file}" ]
then
echo "error: expected \`${file}\` to have been generated"
exit 1
fi
}

# 1. Check expected results with the default naming scheme.
# Note: The assumed crate name is `lib`, so we generate `liblib.rlib`.
kani --only-codegen --keep-temps a/src/lib.rs
check_file_exists a/src/liblib.rlib
check_file_exists a/src/lib.kani-metadata.json
rm a/src/liblib.rlib
rm a/src/lib.kani-metadata.json

# 2. Check expected results with the default naming scheme, which replaces
# some characters.
# Note: The assumed crate name is `my-code`, so we generate `libmy_code.rlib`.
kani --only-codegen --keep-temps my-code.rs
check_file_exists libmy_code.rlib
check_file_exists my_code.kani-metadata.json

# 3. Check expected results with the `--crate-name=<name>` feature. This feature
# allows users to specify the crate name used for compilation with standalone
# `kani`, enabling the compilation of multiple dependencies with similar
# names.
# Note: In the example below, compiling without `--crate-name=<name>` would
# result in files named `liblib.rlib` for each dependency.
kani --only-codegen --keep-temps a/src/lib.rs --crate-name="a"
check_file_exists a/src/liba.rlib
check_file_exists a/src/a.kani-metadata.json

RUSTFLAGS="--extern a=a/src/liba.rlib" kani --only-codegen --keep-temps b/src/lib.rs --crate-name="b"
check_file_exists b/src/libb.rlib
check_file_exists b/src/b.kani-metadata.json

RUSTFLAGS="--extern b=b/src/libb.rlib --extern a=a/src/liba.rlib" kani c/src/lib.rs

rm a/src/liba.rlib
rm a/src/a.kani-metadata.json
rm b/src/libb.rlib
rm b/src/b.kani-metadata.json
Loading