Skip to content

Commit

Permalink
rename to libbz2-rs-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Dec 4, 2024
1 parent 4609c0a commit d8bbf21
Show file tree
Hide file tree
Showing 30 changed files with 139 additions and 139 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ jobs:
- name: cargo build
run: cargo build --target ${{matrix.target}} ${{ matrix.features }}
- name: cargo build (no_std)
run: cargo rustc --target ${{matrix.target}} -p libbzip2-rs-sys --lib --no-default-features --crate-type rlib
run: cargo rustc --target ${{matrix.target}} -p libbz2-rs-sys --lib --no-default-features --crate-type rlib
env:
RUSTFLAGS: -Aunused_variables -Aunused_assignments
- name: cargo nextest # reports segfaults in a helpful way
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} --no-fail-fast --workspace
env:
RUST_BACKTRACE: 1
- name: cargo test with llvm-cov
run: cargo llvm-cov --target ${{matrix.target}} ${{ matrix.features }} --lcov --output-path lcov.info --ignore-filename-regex "test-libbzip2" --workspace
run: cargo llvm-cov --target ${{matrix.target}} ${{ matrix.features }} --lcov --output-path lcov.info --ignore-filename-regex "test-libbz2" --workspace
env:
RUST_BACKTRACE: 1
if: matrix.os != 'windows-2022'
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
run: |
export CC="$(pwd)/wasi-sdk-24.0-x86_64-linux/bin/clang"
export CFLAGS="-target wasm32-wasip1"
cargo nextest run -p libbzip2-rs-sys -p test-libbzip2-rs-sys --target wasm32-wasip1 \
cargo nextest run -p libbz2-rs-sys -p test-libbz2-rs-sys --target wasm32-wasip1 \
-- --skip high_level_write --skip open_and_close # These tests use temp_dir
env:
RUST_BACKTRACE: 1
Expand All @@ -283,9 +283,9 @@ jobs:
tool: cargo-nextest
- name: Test public C api with miri
run: |
cargo +nightly miri nextest run -j4 -p test-libbzip2-rs-sys miri_
cargo +nightly miri nextest run -j4 -p test-libbz2-rs-sys miri_
- name: Run unit tests with miri
run: "cargo +nightly miri nextest run -j4 -p libbzip2-rs-sys"
run: "cargo +nightly miri nextest run -j4 -p libbz2-rs-sys"

link-c-dynamic-library:
name: vanilla dynamic library
Expand All @@ -307,7 +307,7 @@ jobs:
toolchain: stable
targets: ${{matrix.target}}
- name: "cdylib: default settings"
working-directory: libbzip2-rs-sys-cdylib
working-directory: libbz2-rs-sys-cdylib
env:
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps"
run: |
Expand All @@ -318,7 +318,7 @@ jobs:
- name: "cdylib: no stdio"
env:
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps"
working-directory: libbzip2-rs-sys-cdylib
working-directory: libbz2-rs-sys-cdylib
run: |
cargo build --release --target ${{matrix.target}} --no-default-features
cc -DNO_STD -o bzpipe bzpipe.c target/${{matrix.target}}/release/deps/libbz2_rs.so -I ../
Expand All @@ -327,16 +327,16 @@ jobs:
- name: "staticlib: no stdio"
env:
LD_LIBRARY_PATH: "target/${{matrix.target}}/release/deps"
working-directory: libbzip2-rs-sys-cdylib
working-directory: libbz2-rs-sys-cdylib
run: |
cargo build --release --target ${{matrix.target}} --no-default-features
cc -o bzpipe bzpipe.c target/${{matrix.target}}/release/deps/libbz2_rs.so -I ../
./bzpipe < Cargo.toml | ./bzpipe -d > out.txt
cmp -s Cargo.toml out.txt
- name: "cdylib: custom-prefix"
working-directory: libbzip2-rs-sys-cdylib
working-directory: libbz2-rs-sys-cdylib
env:
LIBBZIP2_RS_SYS_PREFIX: "MY_CUSTOM_PREFIX_"
LIBBZ2_RS_SYS_PREFIX: "MY_CUSTOM_PREFIX_"
run: |
cargo build --release --target ${{matrix.target}} --features=custom-prefix
objdump -tT target/${{matrix.target}}/release/deps/libbz2_rs.so | grep -q "MY_CUSTOM_PREFIX_BZ2_bzCompressInit" || (echo "symbol not found!" && exit 1)
Expand Down Expand Up @@ -367,7 +367,7 @@ jobs:
curl -L "$LINK/cargo-c-x86_64-unknown-linux-musl.tar.gz" |
tar xz -C $HOME/.cargo/bin
- name: build with and test the result of cargo-c
working-directory: libbzip2-rs-sys-cdylib
working-directory: libbz2-rs-sys-cdylib
run: |
# build using cargo-c this time
cargo cinstall --release --destdir=/tmp/cargo-cbuild-libbzip2-rs # somehow --offline does not work here
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[workspace]
members = [
"libbzip2-rs-sys",
"test-libbzip2-rs-sys",
"libbz2-rs-sys",
"test-libbz2-rs-sys",
]
exclude = [
"libbzip2-rs-sys-cdylib",
"libbz2-rs-sys-cdylib",
]
package.edition = "2021"

Expand All @@ -27,12 +27,12 @@ path = "bzip2recover.rs"

[workspace.dependencies]
libc = "0.2"
libbzip2-rs-sys = { path = "libbzip2-rs-sys/", default-features = false }
libbz2-rs-sys = { path = "libbz2-rs-sys/", default-features = false }


[dependencies]
libc = "0.2"
libbzip2-rs-sys = { path = "libbzip2-rs-sys/" }
libbz2-rs-sys = { path = "libbz2-rs-sys/" }

[dev-dependencies]
tempfile = "3.13.0"
Expand Down
56 changes: 28 additions & 28 deletions bzip2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::process::exit;
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering};
use std::sync::{Arc, RwLock};

use libbzip2_rs_sys::{
use libbz2_rs_sys::{
BZ2_bzRead, BZ2_bzReadClose, BZ2_bzReadGetUnused, BZ2_bzReadOpen, BZ2_bzWrite,
BZ2_bzWriteClose64, BZ2_bzWriteOpen, BZ2_bzlibVersion, BZFILE,
};
Expand Down Expand Up @@ -294,7 +294,7 @@ fn compressStream(
};

'errhandler: {
if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
break 'errhandler;
}

Expand All @@ -318,7 +318,7 @@ fn compressStream(
);
}

if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
break 'errhandler;
}
}
Expand All @@ -335,7 +335,7 @@ fn compressStream(
);
}

if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
break 'errhandler;
}

Expand Down Expand Up @@ -397,9 +397,9 @@ fn compressStream(
}

match bzerr {
libbzip2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbzip2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbzip2_rs_sys::BZ_IO_ERROR => ioError(config),
libbz2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbz2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbz2_rs_sys::BZ_IO_ERROR => ioError(config),
_ => panic_str(config, "compress:unexpected error"),
}
}
Expand Down Expand Up @@ -464,11 +464,11 @@ fn uncompressStream(
5000,
)
};
if bzerr == libbzip2_rs_sys::BZ_DATA_ERROR_MAGIC {
if bzerr == libbz2_rs_sys::BZ_DATA_ERROR_MAGIC {
state = State::TryCat;
continue 'outer;
}
if (bzerr == libbzip2_rs_sys::BZ_OK || bzerr == libbzip2_rs_sys::BZ_STREAM_END)
if (bzerr == libbz2_rs_sys::BZ_OK || bzerr == libbz2_rs_sys::BZ_STREAM_END)
&& nread > 0
{
if let Err(e) = stream.write_all(&obuf[..nread as usize]) {
Expand All @@ -477,15 +477,15 @@ fn uncompressStream(
}
}

if bzerr != libbzip2_rs_sys::BZ_STREAM_END {
if bzerr != libbz2_rs_sys::BZ_STREAM_END {
state = State::ErrHandler;
continue 'outer;
}

unsafe {
BZ2_bzReadGetUnused(&mut bzerr, bzf, &mut unusedTmpV, &mut nUnused);
}
if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
// diverges
panic_str(config, "decompress:bzReadGetUnused")
}
Expand All @@ -498,7 +498,7 @@ fn uncompressStream(
unsafe {
BZ2_bzReadClose(&mut bzerr, bzf);
}
if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
// diverges
panic_str(config, "decompress:bzReadGetUnused")
}
Expand Down Expand Up @@ -569,12 +569,12 @@ fn uncompressStream(
}

match bzerr {
libbzip2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbzip2_rs_sys::BZ_IO_ERROR => ioError(config),
libbzip2_rs_sys::BZ_DATA_ERROR => crcError(config),
libbzip2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbzip2_rs_sys::BZ_UNEXPECTED_EOF => compressedStreamEOF(config),
libbzip2_rs_sys::BZ_DATA_ERROR_MAGIC => {
libbz2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbz2_rs_sys::BZ_IO_ERROR => ioError(config),
libbz2_rs_sys::BZ_DATA_ERROR => crcError(config),
libbz2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbz2_rs_sys::BZ_UNEXPECTED_EOF => compressedStreamEOF(config),
libbz2_rs_sys::BZ_DATA_ERROR_MAGIC => {
zStream.close();

if streamNo == 1 {
Expand Down Expand Up @@ -636,20 +636,20 @@ fn testStream(config: &Config, zStream: CFile) -> bool {
5000,
);
}
if bzerr == libbzip2_rs_sys::BZ_DATA_ERROR_MAGIC {
if bzerr == libbz2_rs_sys::BZ_DATA_ERROR_MAGIC {
break 'errhandler;
}
}

if bzerr != libbzip2_rs_sys::BZ_STREAM_END {
if bzerr != libbz2_rs_sys::BZ_STREAM_END {
break 'errhandler;
}

let mut unusedTmpV = std::ptr::null_mut();
unsafe {
BZ2_bzReadGetUnused(&mut bzerr, bzf, &mut unusedTmpV, &mut nUnused);
}
if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
panic_str(config, "test:bzReadGetUnused");
}

Expand All @@ -663,7 +663,7 @@ fn testStream(config: &Config, zStream: CFile) -> bool {
unsafe {
BZ2_bzReadClose(&mut bzerr, bzf);
}
if bzerr != libbzip2_rs_sys::BZ_OK {
if bzerr != libbz2_rs_sys::BZ_OK {
panic_str(config, "test:bzReadClose");
}
if nUnused == 0 && zStream.is_eof() {
Expand Down Expand Up @@ -698,18 +698,18 @@ fn testStream(config: &Config, zStream: CFile) -> bool {
);
}
match bzerr {
libbzip2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbzip2_rs_sys::BZ_IO_ERROR => ioError(config),
libbzip2_rs_sys::BZ_DATA_ERROR => {
libbz2_rs_sys::BZ_CONFIG_ERROR => configError(),
libbz2_rs_sys::BZ_IO_ERROR => ioError(config),
libbz2_rs_sys::BZ_DATA_ERROR => {
eprintln!("data integrity (CRC) error in data");
false
}
libbzip2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbzip2_rs_sys::BZ_UNEXPECTED_EOF => {
libbz2_rs_sys::BZ_MEM_ERROR => outOfMemory(config),
libbz2_rs_sys::BZ_UNEXPECTED_EOF => {
eprintln!("file ends unexpectedly");
false
}
libbzip2_rs_sys::BZ_DATA_ERROR_MAGIC => {
libbz2_rs_sys::BZ_DATA_ERROR_MAGIC => {
zStream.close();
if streamNo == 1 {
eprintln!("bad magic number (file not created by bzip2)");
Expand Down
22 changes: 11 additions & 11 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ debug = true

[features]
default = ["rust-allocator"]
c-allocator = ["libbzip2-rs-sys/c-allocator"]
rust-allocator = ["libbzip2-rs-sys/rust-allocator"]
disable-checksum = ["libbzip2-rs-sys/__internal-fuzz-disable-checksum"]
c-allocator = ["libbz2-rs-sys/c-allocator"]
rust-allocator = ["libbz2-rs-sys/rust-allocator"]
disable-checksum = ["libbz2-rs-sys/__internal-fuzz-disable-checksum"]

[dependencies.libfuzzer-sys]
version = "0.4"
Expand All @@ -28,13 +28,13 @@ libloading = "0.8.1"
crc32fast = "1.3.2"
rstest = "0.23.0"

[dependencies.libbzip2-rs-sys]
path = "../libbzip2-rs-sys"
[dependencies.libbz2-rs-sys]
path = "../libbz2-rs-sys"
default-features = false
features = ["testing-prefix"]

[dependencies.test-libbzip2-rs-sys]
path = "../test-libbzip2-rs-sys"
[dependencies.test-libbz2-rs-sys]
path = "../test-libbz2-rs-sys"
default-features = false

# Prevent this from interfering with workspaces
Expand Down
Loading

0 comments on commit d8bbf21

Please sign in to comment.