Skip to content
Snippets Groups Projects
Commit f11cebd5 authored by Per Lindgren's avatar Per Lindgren
Browse files

move to clap 4, wip

parent cef847e1
No related branches found
No related tags found
No related merge requests found
{ {
"cSpell.ignoreWords": [ "cSpell.ignoreWords": [
"Runtest", "Runtest",
"analyse",
"deps", "deps",
"is", "is",
"istats", "istats",
......
...@@ -8,12 +8,12 @@ In effect, a Rust program passing KLEE analysis is thus ensured to be panic free ...@@ -8,12 +8,12 @@ In effect, a Rust program passing KLEE analysis is thus ensured to be panic free
## Requirements ## Requirements
- LLVM KLEE installed, (version 2.3pre, currently based on LLVM-v12). - LLVM KLEE installed, (tested under arch linux 220929 with version 2.3 on LLVM-v14).
- LLVM llc and clang for building replay binaries (currently based on LLVM-v12). - LLVM llc and clang for building replay binaries (currently based on LLVM-v14).
- GNU gdb for executing replay binaries - GNU gdb for executing replay binaries.
- Rust tool-chain (edition-2018), tested with stable `rustc 1.56.1 (59eed8a2a 2021-11-01)`. - Rust tool-chain (edition-2018), tested with stable `rustc 1.64.0 (a55dd71d5 2022-09-19)`.
The `klee` tools (executables) needs to be installed and accessible in path, the KLEE libraries are assumed to be accessible under `/usr/lib`. The tool has been tested on the master branch of [KLEE](https://github.com/klee/klee) 2.3pre as of 2021-11-04, built under arch linux with the system LLVM (v12). You may use a custom install of KLEE, set the `LD_LIBRARY_PATH` to include the location of `kleeRuntest.so.1.0` (used by cargo-klee to dynamically link the library for replay of tests in gdb). The `klee` tools (executables) needs to be installed and accessible in path, the KLEE libraries are assumed to be accessible under `/usr/lib`. The tool has been tested on the master branch of [KLEE](https://github.com/klee/klee) 2.3 as of 2022-09-29, built under arch linux with the system LLVM (v14). You may use a custom install of KLEE, set the `LD_LIBRARY_PATH` to include the location of `kleeRuntest.so.1.0` (used by cargo-klee to dynamically link the library for replay of tests in gdb).
## Limitations ## Limitations
......
{
"cSpell.ignoreWords": [
"Luleå",
"rustc"
]
}
\ No newline at end of file
[package] [package]
authors = ["Lulea University of Technology (LTU)"] authors = ["Lulea University of Technology (LTU)"]
name = "cargo-klee" name = "cargo-klee"
version = "0.4.0" about = "KLEE analysis of Rust application"
edition = "2018" long_about = "Cargo sub-command to manage building a Rust application for KLEE analysis, running KLEE analysis and replaying generated tests using `gdb`"
version = "0.5.0"
edition = "2021"
[dependencies] [dependencies]
libc = "0.2.81" libc = "0.2.81"
failure = "0.1.8" # failure = "0.1.8"
cargo-project = "0.2.4" cargo-project = "0.3.0"
either = "1.6.1" either = "1.6.1"
clap = "2.33.3" clap = { version = "4.0.6", features = ["derive", "color"] }
rustc_version = "0.3.0" rustc_version = "0.4.0"
anyhow = "1.0.65"
// use anyhow::Error;
// use clap::{Arg, ArgGroup, Parser, Subcommand};
use clap::{ArgGroup, Parser};
#[derive(Parser, Debug, Clone)] // requires `derive` feature
#[command(author, version, about, long_about = None)]
#[command(group(ArgGroup::new("binary").multiple(false)))]
pub struct Cli {
// klee argument passed implicitly by Cargo
command: String,
/// Binary to build
#[arg(long, group = "binary")]
bin: Option<String>,
/// Example to build
#[arg(long, group = "binary")]
example: Option<String>,
/// Arguments to rustc as a string (e.g., "--release, --target", etc)
#[arg(long, allow_hyphen_values = true)]
rustc: Option<String>,
/// Verbose output from rustc
#[arg(long)]
verbose: bool,
/// Klee invocation
#[arg(long, short)]
klee: bool,
/// GDB Replay
#[arg(long, short)]
replay: bool,
// #[command(subcommand)]
// binary: Option<Commands>,
}
#[test]
fn cli_verify() {
use clap::CommandFactory;
Cli::command().debug_assert()
}
#[test]
fn cli_parse_simple() {
let args = Cli::try_parse_from(&["test"]).unwrap();
assert_eq!(args.bin, None);
}
#[test]
fn cli_parse_bin() {
let args = Cli::try_parse_from(&["test", "klee", "--bin", "a"]).unwrap();
println!("args {:?}", args);
assert_eq!(args.bin, Some("a".to_owned()));
}
#[test]
fn cli_parse_example() {
let args = Cli::try_parse_from(&["test", "klee", "--example", "b"]).unwrap();
println!("args {:?}", args);
assert_eq!(args.example, Some("b".to_owned()));
}
#[test]
fn cli_parse_bin_example() {
let args = Cli::try_parse_from(&["test", "klee", "--bin", "a", "--example", "b"]);
println!("args {:?}", args);
assert_eq!(args.is_err(), true);
}
pub mod cli;
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment