-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(
c2rust-analyze/tests
) Add tests for string literals and casts (#838)
Add tests for string literals and casts. They are currently unsupported: - #833 - #837 so for now the tests are skipped over with `#[cfg(any())]`. Once those issues are fixed, these tests will be turned back on, but it's easier to start with the tests existing. These tests just check if `c2rust-analyze` doesn't crash on them, similar to the existing `lighttpd-minimal` test. For the `FileCheck` tests, `FileCheck` requires at least one `CHECK:` command, which we don't want. Thus, I've renamed `lighttpd.rs` to `analyze.rs` and it'll be for `c2rust-analyze`-only tests, as opposed to `filecheck.rs` for `c2rust-analyze` + `FileCheck` tests. Furthermore, running `cargo` concurrently (due to multiple tests) for `c2rust-analyze` crashes in macOS CI, so now the `c2rust-analyze` binary is found to run directly, rather than going through `cargo` again. Skipping going through `cargo` makes the tests run much faster, but more importantly, prevents them from competing for the `target/` lock, which caused issues in CI on macOS sometimes. It's also a bit simpler now, not needing to go through `cargo`.
- Loading branch information
Showing
6 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use common::Analyze; | ||
|
||
pub mod common; | ||
|
||
#[test] | ||
fn string_literals() { | ||
Analyze::resolve().run("tests/analyze/string_literals.rs"); | ||
} | ||
|
||
#[test] | ||
fn string_casts() { | ||
Analyze::resolve().run("tests/analyze/string_casts.rs"); | ||
} | ||
|
||
#[test] | ||
fn lighttpd_minimal() { | ||
Analyze::resolve().run("../analysis/tests/lighttpd-minimal/src/main.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[cfg(any())] | ||
fn cast_only(s: *const u8) { | ||
s as *const core::ffi::c_char; | ||
} | ||
|
||
#[cfg(any())] | ||
fn cast_from_literal() { | ||
b"" as *const u8 as *const core::ffi::c_char; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#[cfg(any())] | ||
fn str() { | ||
""; | ||
} | ||
|
||
#[cfg(any())] | ||
fn bstr() { | ||
b""; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.