# Copyright (C) 2024 Umorpha Systems # SPDX-License-Identifier: AGPL-3.0-or-later bats_require_minimum_version 1.7.0 bats_load_library bats-support bats_load_library bats-assert bats_load_library bats-file teardown() { if [ -n "${tmpdir:-}" ]; then if [[ -d "$tmpdir/tmp-dis" ]]; then sudo fusermount -u "$tmpdir/tmp-dis" || true fi temp_del "$tmpdir" fi } @test "osi-mk needs arguments" { LC_ALL=C run --separate-stderr osi-mk assert_failure 2 assert_equal "$output" '' assert [ ${#stderr_lines[@]} -gt 1 ] assert_regex "${stderr_lines[-1]}" "^Try .*osi-mk --help' for more information\$" } @test "osi-mk shows help" { LC_ALL=C run --separate-stderr osi-mk --help assert_success assert_equal "$stderr" '' assert_regex "${lines[0]}" '^Usage: osi-mk ' LC_ALL=C run --separate-stderr osi-mk -h assert_success assert_equal "$stderr" '' assert_regex "${lines[0]}" '^Usage: osi-mk' } @test "osi-mk shows version" { LC_ALL=C run --separate-stderr osi-mk --version assert_success assert_equal "$stderr" '' assert_regex "${lines[0]}" '^osi-mk \(osi-tools\) ' LC_ALL=C run --separate-stderr osi-mk -V assert_success assert_equal "$stderr" '' assert_regex "${lines[0]}" '^osi-mk \(osi-tools\) ' } @test "osi-mk builds base" { tmpdir="$(temp_make)" echo 'Building image...' osi-mk --conf=format=raw_btrfs --conf=size=2G --package=base --package=linux-libre "$tmpdir/tst.img" echo 'Checking that mkinitcpio ran correctly...' mkdir "$tmpdir/mnt" sudo osi-mount --user "$tmpdir/tst.img" "$tmpdir/mnt" -- test -f "$tmpdir/mnt/boot/initramfs-linux-libre.img" } @test "osi-mk builds base x86_64" { tmpdir="$(temp_make)" osi-mk --conf=arch=x86_64 --conf=format=raw_btrfs --conf=size=2G --package=base --package=linux-libre "$tmpdir/tst.img" } @test "osi-mk builds base armv7h" { tmpdir="$(temp_make)" osi-mk --conf=arch=armv7h --conf=format=raw_btrfs --conf=size=2G --package=base --package=linux-libre "$tmpdir/tst.img" } @test "osi-mk is reproducible" { tmpdir="$(temp_make)" mkdir "$tmpdir/tmp-raw" "$tmpdir/tmp-dis" sudo disorderfs --multi-user=yes --shuffle-dirents=yes "$tmpdir/tmp-raw" "$tmpdir/tmp-dis" flags=( --disorderfs --conf=format=erofs --conf=bootloader=none --conf=fsuuid="$(uuidgen)" --conf=machine-id="$(uuidgen|tr -d -)" --conf=SOURCE_DATE_EPOCH=auto --package=base # TODO: We simply delete the known non-reproducible # files, to verify that we don't get *less* # reproducible; but we aren't actually reproducible # yet. --module="$PWD/mod-reproducible.sh" ) TMPDIR="$tmpdir/tmp-dis" osi-mk "${flags[@]}" "$tmpdir/tst1.img" TMPDIR="$tmpdir/tmp-dis" osi-mk "${flags[@]}" "$tmpdir/tst2.img" cmp "$tmpdir/tst1.img" "$tmpdir/tst2.img" }