Skip to content

Commit

Permalink
Use disk image for btrfs tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Oct 29, 2024
1 parent 7382104 commit d9d8e1e
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 43 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
cc: [gcc, clang]
include:
- name: btrfs-clone
os: ubuntu-latest
- name: epochalypse
os: ubuntu-latest
setup_options: -Db_sanitize=none
Expand Down Expand Up @@ -113,6 +115,16 @@ jobs:
apk update
apk upgrade
- if: ${{ matrix.name == 'btrfs-clone' }}
uses: actions/cache@v4
id: btrfs-img-cache
with:
path: test/rmw-btrfs-test.img
key: ${{ matrix.name }}-${{ hashFiles('test/rmw-btrfs-test.img.sha256sum') }}

- if: ${{ steps.btrfs-img-cache.outputs.cache-hit != 'true' && matrix.name == 'btrfs-clone' }}
run: curl -L -o test/rmw-btrfs-test.img 'https://www.dropbox.com/scl/fi/57g3ixd3w3tuz4qoc2zp1/rmw-btrfs-test.img?rlkey=yc7krtntswsa1bwz0sbugy4gi&st=hkgrht05&dl=0'

- name: Configure
run: meson setup builddir $SETUP_OPTIONS ${{ matrix.setup_options }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ subprojects/**
# wrap files required
!subprojects/**/*.wrap
/packaging/appimage/.env
/test/rmw-btrfs-test.img
107 changes: 67 additions & 40 deletions test/btrfs_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,82 @@ else
. "${MESON_SOURCE_ROOT}/test/COMMON"
fi

# This script is only designed to work on Andy's workstation.
if [ ! -d "/mnt/btrfs_part" ]; then
exit 0
fi
## This script is only designed to work on Andy's workstation.
#if [ ! -d "/mnt/btrfs_part" ]; then
#exit 0
#fi

## subvolume
#if [ ! -d "/mnt/btrfs_part/Waste" ]; then
#exit 0
#fi

#$RMW_TEST_CMD_STRING

#cd "$RMW_FAKE_HOME"
#for i in "/mnt/btrfs_part" "/mnt/btrfs_part/bar"; do
#touch "$i/foo"
#for j in 01 02 03 04; do
#echo "$j"
#$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs$j.rc" "$i/foo"
#test ! -f "$i/foo"
#$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs$j.rc" -u
#test -f "$i/foo"
#done
#done

#touch /mnt/btrfs_part/bar/foo
#$RMW_TEST_CMD_STRING /mnt/btrfs_part/bar/foo \
#-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc"
#test ! -f /mnt/btrfs_part/bar/foo
#cd /mnt/btrfs_part/wasteLink/files
#$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc" -z foo
#test -f /mnt/btrfs_part/bar/foo

#cd /mnt/btrfs_part/bar
#touch ../foo
#$RMW_TEST_CMD_STRING ../foo \
#-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc"
#test -f /mnt/btrfs_part/wasteLink/files/foo
#$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc" -u
#test -f ../foo

# subvolume
if [ ! -d "/mnt/btrfs_part/Waste" ]; then
#if [ ! -d "/mnt/loop" ]; then
#exit 0
#fi

IMAGE_MOUNTPOINT="/tmp/rmw-loop"

if [ ! -f "${MESON_SOURCE_ROOT}/test/rmw-btrfs-test.img" ]; then
exit 0
fi

$RMW_TEST_CMD_STRING

cd "$RMW_FAKE_HOME"
for i in "/mnt/btrfs_part" "/mnt/btrfs_part/bar"; do
touch "$i/foo"
for j in 01 02 03 04; do
echo "$j"
$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs$j.rc" "$i/foo"
test ! -f "$i/foo"
$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs$j.rc" -u
test -f "$i/foo"
done
done

touch /mnt/btrfs_part/bar/foo
$RMW_TEST_CMD_STRING /mnt/btrfs_part/bar/foo \
-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc"
test ! -f /mnt/btrfs_part/bar/foo
cd /mnt/btrfs_part/wasteLink/files
$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc" -z foo
test -f /mnt/btrfs_part/bar/foo

cd /mnt/btrfs_part/bar
touch ../foo
$RMW_TEST_CMD_STRING ../foo \
-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc"
test -f /mnt/btrfs_part/wasteLink/files/foo
$RMW_TEST_CMD_STRING -c "${MESON_SOURCE_ROOT}/test/rmw.btrfs04.rc" -u
test -f ../foo

# This script is only designed to work on Andy's workstation.
if [ ! -d "/mnt/usb_btrfs" ]; then
if [ -f "${MESON_SOURCE_ROOT}/test/rmw-btrfs-test.img" ]; then
if [ ! -d "$IMAGE_MOUNTPOINT" ]; then
sudo mkdir "$IMAGE_MOUNTPOINT"
fi
if [ -z "$(mount | grep rmw-btrfs)" ]; then
sudo mount -o loop "${MESON_SOURCE_ROOT}/test/rmw-btrfs-test.img" \
"$IMAGE_MOUNTPOINT"
sudo chown $(id -u) -R "$IMAGE_MOUNTPOINT"
fi
else
exit 0
fi

cd /mnt/usb_btrfs
cd "$IMAGE_MOUNTPOINT"
touch foo
$RMW_TEST_CMD_STRING foo \
-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs_usb.rc"
-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs_img.rc"
test ! -f foo
$RMW_TEST_CMD_STRING -u \
-c "${MESON_SOURCE_ROOT}/test/rmw.btrfs_img.rc"
test -f foo

cd

if [ -n "$(mount | grep rmw-btrfs)" ]; then
sudo umount "$IMAGE_MOUNTPOINT"
fi

exit 0
1 change: 1 addition & 0 deletions test/rmw-btrfs-test.img.sha256sum
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cae56d95af17163700dd3402235248fcf52a81ea86b8cbf34733056096dda445 rmw-btrfs-test.img
4 changes: 4 additions & 0 deletions test/rmw.btrfs_img.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#waste = /tmp/rmw-loop/.Trash-$UID
waste = /tmp/rmw-loop/three/Waste
waste = /tmp/rmw-loop/@two/Waste
waste = /tmp/rmw-loop/trashlink
3 changes: 0 additions & 3 deletions test/rmw.btrfs_usb.rc

This file was deleted.

0 comments on commit d9d8e1e

Please sign in to comment.