Skip to content

Fix 32-bit test failures and test workspace on a 32-bit target on CI #1687

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

Merged
merged 21 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8ea7501
Revert "Remove 32bit platform that seemingly fails due to libc updates"
EliahKagan Nov 12, 2024
a78e8f2
Try i686-unknown-linux-musl
EliahKagan Nov 12, 2024
811dc6d
Don't use `cross` for the i686 target
EliahKagan Nov 12, 2024
bb06629
See what happens with `-p gix` for the test command
EliahKagan Nov 12, 2024
6771838
Temporarily keep i686 job failure from canceling armv7 job
EliahKagan Nov 12, 2024
e94526e
Say why we test gix-hashtable instead of gix on armv7
EliahKagan Nov 13, 2024
094023a
Split i686 and armv7 jobs; run all tests on i686
EliahKagan Nov 13, 2024
0d54b5f
Change i686 job to i686-unknown-linux-gnu, run in container
EliahKagan Nov 13, 2024
967970b
Install `node` in container; try to help actions find it
EliahKagan Nov 13, 2024
bb430d7
Try to figure out what is going on
EliahKagan Nov 13, 2024
d221572
Install 64-bit Node in container, for its libraries
EliahKagan Nov 13, 2024
64f2198
Install libstdc++6:amd64 (and not Node) in the container
EliahKagan Nov 14, 2024
eaf2243
Reorganize `test-32bit` prerequisites to explain `libstdc++6:amd64`
EliahKagan Nov 14, 2024
47f3819
Take ownership of the repo in the container
EliahKagan Nov 14, 2024
d07c32d
Fix gix-url baseline script instead of taking ownership
EliahKagan Nov 14, 2024
178cf25
Make Git `system` scope nonempty in container
EliahKagan Nov 15, 2024
77c3c59
feat: Add `size_ok` for asserting size is not too big
EliahKagan Nov 18, 2024
fc13fc3
Use `<=` on 32-bit for some size assertions
EliahKagan Nov 18, 2024
2f77c9b
Work around new `gix-index` ambiguity for `cargo check`
EliahKagan Nov 18, 2024
daf9990
Add 32-bit expectations for remaining `==` size assertions
EliahKagan Nov 18, 2024
dc0a73a
Deduplicate some repeated tests
EliahKagan Nov 18, 2024
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
47 changes: 43 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,42 @@ jobs:
test-32bit:
runs-on: ubuntu-latest

container: i386/debian:stable-slim

steps:
- name: Prerequisites
run: |
prerequisites=(
build-essential
ca-certificates
cmake
curl
git
jq
libssl-dev
libstdc++6:amd64 # To support external 64-bit Node.js for actions.
pkgconf
)
dpkg --add-architecture amd64
apt-get update
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
shell: bash
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable-i686-unknown-linux-gnu # Otherwise it may misdetect based on the amd64 kernel.
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with:
tool: nextest
- name: Make `system` scope nonempty for "GitInstallation" tests
run: git config --system gitoxide.imaginary.arbitraryVariable arbitraryValue
- name: Test (nextest)
run: cargo nextest run --workspace --no-fail-fast

test-32bit-cross:
runs-on: ubuntu-latest

strategy:
matrix:
target: [ armv7-linux-androideabi ]
Expand All @@ -211,15 +247,17 @@ jobs:
with:
toolchain: stable
targets: ${{ matrix.target }}
- uses: taiki-e/install-action@v2
- name: Install cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: check
run: cross check -p gix --target ${{ matrix.target }}
- name: Test (unit)
# run high-level unit tests that exercise a lot of code while being pure Rust to ease building test binaries.
# TODO: figure out why `git` doesn't pick up environment configuration so build scripts fail when using `-p gix`.
run: cross test -p gix-hashtable --target ${{ matrix.target }}
run: |
# Run some high-level unit tests that exercise various pure Rust code to ease building test binaries.
# We would prefer `-p gix`. But with `cross`, fixture scripts try to run amd64 `git` as an armv7 binary.
cross test -p gix-hashtable --target ${{ matrix.target }}

lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -396,6 +434,7 @@ jobs:
- test-journey
- test-fast
- test-32bit
- test-32bit-cross
- lint
- cargo-deny
- check-packetline
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

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

7 changes: 6 additions & 1 deletion gix-archive/tests/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@ mod from_tree {

use crate::hex_to_id;

#[cfg(target_pointer_width = "64")]
const EXPECTED_BUFFER_LENGTH: usize = 551;
#[cfg(target_pointer_width = "32")]
const EXPECTED_BUFFER_LENGTH: usize = 479;

#[test]
fn basic_usage_internal() -> gix_testtools::Result {
basic_usage(gix_archive::Format::InternalTransientNonPersistable, |buf| {
assert_eq!(buf.len(), 551);
assert_eq!(buf.len(), EXPECTED_BUFFER_LENGTH);

let mut stream = gix_worktree_stream::Stream::from_read(std::io::Cursor::new(buf));
let mut paths_and_modes = Vec::new();
Expand Down
10 changes: 6 additions & 4 deletions gix-attributes/tests/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use gix_attributes::{
AssignmentRef, NameRef, StateRef,
};
use gix_glob::pattern::Case;
use gix_testtools::size_ok;

mod specials {
use std::path::Path;
Expand Down Expand Up @@ -268,10 +269,11 @@ fn given_attributes_are_made_available_in_given_order() -> crate::Result {

#[test]
fn size_of_outcome() {
assert_eq!(
std::mem::size_of::<Outcome>(),
840,
"it's quite big, shouldn't change without us noticing"
let actual = std::mem::size_of::<Outcome>();
let expected = 840;
assert!(
size_ok(actual, expected),
"it's quite big, shouldn't change without us noticing: {actual} <~ {expected}"
);
}

Expand Down
3 changes: 3 additions & 0 deletions gix-index/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ rustix = { version = "0.38.20", default-features = false, features = [
] }
libc = { version = "0.2.149" }

[dev-dependencies]
gix-testtools = { path = "../tests/tools" }

[package.metadata.docs.rs]
features = ["document-features", "serde"]
8 changes: 7 additions & 1 deletion gix-index/src/extension/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ mod write;

#[cfg(test)]
mod tests {
use gix_testtools::size_ok;

#[test]
fn size_of_tree() {
assert_eq!(std::mem::size_of::<crate::extension::Tree>(), 88);
let actual = std::mem::size_of::<crate::extension::Tree>();
let expected = 88;
assert!(
size_ok(actual, expected),
"the size of this structure should not change unexpectedly: {actual} <~ {expected}"
);
}
}
9 changes: 0 additions & 9 deletions gix-index/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,3 @@ pub(crate) mod util {
data.split_at(pos).into()
}
}

#[test]
fn size_of_entry() {
assert_eq!(std::mem::size_of::<crate::Entry>(), 80);

// the reason we have our own time is half the size.
assert_eq!(std::mem::size_of::<crate::entry::stat::Time>(), 8);
assert_eq!(std::mem::size_of::<filetime::FileTime>(), 16);
}
35 changes: 27 additions & 8 deletions gix-index/tests/index/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::path::{Path, PathBuf};

use gix_hash::ObjectId;

mod access;
mod entry;
mod file;
mod fs;
mod init;

use std::path::{Path, PathBuf};

use gix_hash::ObjectId;
use gix_testtools::size_ok;

pub fn hex_to_id(hex: &str) -> ObjectId {
ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex")
}
Expand All @@ -25,11 +26,29 @@ pub fn loose_file_path(name: &str) -> PathBuf {

#[test]
fn size_of_entry() {
assert_eq!(std::mem::size_of::<gix_index::Entry>(), 80);
let actual = std::mem::size_of::<gix_index::Entry>();
let expected = 80;
assert!(
size_ok(actual, expected),
"the size of this structure should not change unexpectedly: {actual} <~ {expected}"
);
}

// the reason we have our own time is half the size.
assert_eq!(std::mem::size_of::<gix_index::entry::stat::Time>(), 8);
assert_eq!(std::mem::size_of::<filetime::FileTime>(), 16);
#[test]
fn size_of_entry_time() {
// The reason we have our own time is that it is half the size.
let ent_actual = std::mem::size_of::<gix_index::entry::stat::Time>();
let ent_expected = 8;
assert!(
size_ok(ent_actual, ent_expected),
"the size of this structure should not change unexpectedly: {ent_actual} <~ {ent_expected}"
);
let ft_actual = std::mem::size_of::<filetime::FileTime>();
let ft_expected = 16;
assert!(
size_ok(ft_actual, ft_expected),
"we will want to know if the size of this structure changes: {ft_actual} <~ {ft_expected}"
);
}

enum Fixture {
Expand Down
11 changes: 6 additions & 5 deletions gix-negotiate/tests/negotiate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use gix_testtools::Result;
use gix_testtools::{size_ok, Result};

mod window_size {
use gix_negotiate::window_size;
Expand Down Expand Up @@ -38,9 +38,10 @@ mod baseline;

#[test]
fn size_of_entry() {
assert_eq!(
std::mem::size_of::<gix_revwalk::graph::Commit<gix_negotiate::Metadata>>(),
56,
"we may keep a lot of these, so let's not let them grow unnoticed"
let actual = std::mem::size_of::<gix_revwalk::graph::Commit<gix_negotiate::Metadata>>();
let expected = 56;
assert!(
size_ok(actual, expected),
"we may keep a lot of these, so let's not let them grow unnoticed: {actual} <~ {expected}"
);
}
26 changes: 0 additions & 26 deletions gix-pack/src/cache/delta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,3 @@ pub mod from_offsets;
mod tree;

pub use tree::{Item, Tree};

#[cfg(test)]
mod tests {

#[test]
fn size_of_pack_tree_item() {
use super::Item;
assert_eq!(std::mem::size_of::<[Item<()>; 7_500_000]>(), 300_000_000);
}

#[test]
fn size_of_pack_verify_data_structure() {
use super::Item;
pub struct EntryWithDefault {
_index_entry: crate::index::Entry,
_kind: gix_object::Kind,
_object_size: u64,
_decompressed_size: u64,
_compressed_size: u64,
_header_size: u16,
_level: u16,
}

assert_eq!(std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>(), 840_000_000);
}
}
47 changes: 30 additions & 17 deletions gix-pack/src/cache/delta/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,38 @@ mod tests {
}
}

#[test]
fn size_of_pack_tree_item() {
use super::Item;
assert_eq!(std::mem::size_of::<[Item<()>; 7_500_000]>(), 300_000_000);
}
mod size {
use super::super::Item;
use gix_testtools::size_ok;

#[test]
fn size_of_pack_verify_data_structure() {
use super::Item;
pub struct EntryWithDefault {
_index_entry: crate::index::Entry,
_kind: gix_object::Kind,
_object_size: u64,
_decompressed_size: u64,
_compressed_size: u64,
_header_size: u16,
_level: u16,
#[test]
fn size_of_pack_tree_item() {
let actual = std::mem::size_of::<[Item<()>; 7_500_000]>();
let expected = 300_000_000;
assert!(
size_ok(actual, expected),
"we don't want these to grow unnoticed: {actual} <~ {expected}"
);
}

assert_eq!(std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>(), 840_000_000);
#[test]
fn size_of_pack_verify_data_structure() {
pub struct EntryWithDefault {
_index_entry: crate::index::Entry,
_kind: gix_object::Kind,
_object_size: u64,
_decompressed_size: u64,
_compressed_size: u64,
_header_size: u16,
_level: u16,
}

let actual = std::mem::size_of::<[Item<EntryWithDefault>; 7_500_000]>();
let expected = 840_000_000;
assert!(
size_ok(actual, expected),
"we don't want these to grow unnoticed: {actual} <~ {expected}"
);
}
}
}
10 changes: 6 additions & 4 deletions gix-pack/src/data/file/decode/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,15 @@ impl File {
#[cfg(test)]
mod tests {
use super::*;
use gix_testtools::size_ok;

#[test]
fn size_of_decode_entry_outcome() {
assert_eq!(
std::mem::size_of::<Outcome>(),
32,
"this shouldn't change without use noticing as it's returned a lot"
let actual = std::mem::size_of::<Outcome>();
let expected = 32;
assert!(
size_ok(actual, expected),
"this shouldn't change without use noticing as it's returned a lot: {actual} <~ {expected}"
);
}
}
19 changes: 11 additions & 8 deletions gix-pack/tests/pack/data/output/mod.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
use std::{path::PathBuf, sync::Arc};

use gix_pack::data::output;
use gix_testtools::size_ok;

#[test]
fn size_of_entry() {
assert_eq!(
std::mem::size_of::<output::Entry>(),
80,
"The size of the structure shouldn't change unexpectedly"
let actual = std::mem::size_of::<output::Entry>();
let expected = 80;
assert!(
size_ok(actual, expected),
"The size of the structure shouldn't change unexpectedly: {actual} <~ {expected}"
);
}

#[test]
fn size_of_count() {
assert_eq!(
std::mem::size_of::<output::Count>(),
56,
"The size of the structure shouldn't change unexpectedly"
let actual = std::mem::size_of::<output::Count>();
let expected = 56;
assert!(
size_ok(actual, expected),
"The size of the structure shouldn't change unexpectedly: {actual} <~ {expected}"
);
}

Expand Down
Loading
Loading