Skip to content

Commit

Permalink
run tests, update some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Oct 7, 2023
1 parent 213fadb commit 8da5a0d
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
popd
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: katsudon-arm
path: tests/ng/katsu-work/image/*.raw.xz
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:

jobs:
unit-test:
integration-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/terrapkg/builder:f38
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
popd
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: katsudon
path: tests/ng/katsu-work/image/*.raw.xz
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build test

on:
push:

jobs:
integration-test:
runs-on: ubuntu-latest
container:
image: ghcr.io/terrapkg/builder:f38
# Pass /dev from host to container
# Very hacky, but it works
# Microsoft/Github, if you're reading this,
# I'm sorry.
options: --privileged -v /dev:/dev

steps:
- uses: actions/checkout@v4
- name: Cache DNF packages
uses: actions/cache@v2
with:
path: /var/cache/dnf
key: dnf-${{ runner.os }}
restore-keys: |
dnf-${{ runner.os }}-
dnf-
- name: Install dependencies
run: |
dnf install -y \
xorriso \
rpm \
limine \
systemd \
btrfs-progs \
e2fsprogs \
xfsprogs \
dosfstools \
grub2 \
parted \
util-linux-core \
systemd-container \
grub2-efi \
uboot-images-armv8 \
uboot-tools \
rustc \
qemu-user-static-aarch64 \
qemu-user-binfmt \
qemu-kvm \
qemu-img \
cargo \
systemd-devel \
mkpasswd \
clang-devel \
moby-engine
- uses: Swatinem/rust-cache@v2

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
56 changes: 52 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,19 +444,21 @@ fn test_partlay() {
});

partlay.add_partition(Partition {
label: Some("ROOT".to_string()),
label: Some("boot".to_string()),
size: Some(ByteSize::gib(100)),
filesystem: "ext4".to_string(),
mountpoint: "/".to_string(),
mountpoint: "/boot".to_string(),
});

partlay.add_partition(Partition {
label: Some("HOME".to_string()),
label: Some("ROOT".to_string()),
size: Some(ByteSize::gib(100)),
filesystem: "ext4".to_string(),
mountpoint: "/home".to_string(),
mountpoint: "/".to_string(),
});



for (i, part) in partlay.partitions.iter().enumerate() {
println!("Partition {i}:");
println!("{part:#?}");
Expand All @@ -470,6 +472,52 @@ fn test_partlay() {
println!("====================");
}


let lay = partlay.sort_partitions();

println!("{:#?}", partlay);
println!("sorted: {:#?}", lay);


// Assert that:

// 1. The partitions are sorted by mountpoint
// / will come first
// /boot will come second
// /boot/efi will come last

let assertion = vec![
(
3,
Partition {
label: Some("ROOT".to_string()),
size: Some(ByteSize::gib(100)),
filesystem: "ext4".to_string(),
mountpoint: "/".to_string(),
}
),
(
2,
Partition {
label: Some("boot".to_string()),
size: Some(ByteSize::gib(100)),
filesystem: "ext4".to_string(),
mountpoint: "/boot".to_string(),
}
),
(
1,
Partition {
label: Some("EFI".to_string()),
size: Some(ByteSize::mib(100)),
filesystem: "efi".to_string(),
mountpoint: "/boot/efi".to_string(),
}
),
];

assert_eq!(lay, assertion)

// partlay.apply(&mock_disk).unwrap();
// check if parts would be applied correctly
}
Expand Down

0 comments on commit 8da5a0d

Please sign in to comment.