Skip to content

Commit

Permalink
WIP - minimal bats setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hoexter committed Jul 24, 2024
1 parent 26e2afd commit 0f0d725
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- exfat-next
- bats-tests
pull_request:
branches:
- master
Expand All @@ -19,8 +20,7 @@ jobs:
- uses: actions/checkout@v3
- name: before test
run: |
sudo apt-get install linux-headers-$(uname -r)
sudo apt-get install xz-utils
sudo apt-get install linux-headers-$(uname -r) xz-utils bats
git clone https://github.com/namjaejeon/linux-exfat-oot
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/lib:$PATH
Expand All @@ -30,6 +30,9 @@ jobs:
./configure > /dev/null
make -j$((`nproc`+1)) > /dev/null
sudo make install > /dev/null
- name: run cli test cases with bats
run: |
bats tests/cli/tests.bats
- name: run fsck repair testcases
run: |
cd tests
Expand Down
27 changes: 27 additions & 0 deletions tests/cli/tests.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
setup() {
# get the containing directory of this file
# use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0,
# as those will point to the bats executable's location or the preprocessed file respectively
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
LOOP_DEV="/dev/loop22"
for PROG_DIR in dump exfat2img fsck label mkfs tune; do
PATH="$DIR/../../${PROG_DIR}:$PATH"
done
truncate -s 100M test.img
sudo mkdir -p /mnt/test
sudo losetup ${LOOP_DEV} test.img
sudo mkfs.exfat ${LOOP_DEV}
#sudo mount -t exfat ${LOOP_DEV} /mnt/test/

}

teardown() {
#sudo umount ${LOOP_DEV}
sudo losetup -d ${LOOP_DEV}
sudo rmdir /mnt/test
rm test.img
}

@test "can run our script" {
sudo exfatlabel -i /dev/loop22
}

0 comments on commit 0f0d725

Please sign in to comment.