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 e5e8ac2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
8 changes: 6 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,10 @@ jobs:
./configure > /dev/null
make -j$((`nproc`+1)) > /dev/null
sudo make install > /dev/null
- name: run cli test cases with bats
run: |
# --show-output-of-passing-tests --verbose-run should be in here on recent bats versions
bats tests/cli/tests.bats
- name: run fsck repair testcases
run: |
cd tests
Expand Down
42 changes: 42 additions & 0 deletions tests/cli/tests.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#setup() {
# load '/usr/lib/bats/bats-assert/load.bash'
#}

setup_file() {
# 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
#EXFAT_PROGS_VERSION="$(grep EXFAT_PROGS_VERSION ../../include/version.h | cut -d'"' -f 2)"
EXFAT_PROGS_VERSION="1.2.0"
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_file() {
#sudo umount ${LOOP_DEV}
sudo losetup -d ${LOOP_DEV}
sudo rmdir /mnt/test
rm test.img
}

@test "exfatlabel get mkfs set volume serial" {
run sudo exfatlabel -i ${LOOP_DEV}
#assert_output -e 'volume serial : 0x[0-9a-f]+'
}

@test "exfatlabel set volume serial" {
run sudo exfatlabel -i ${LOOP_DEV} 0xc0ffee
}

@test "exfatlabel get new volume serial" {
run sudo exfatlabel -i ${LOOP_DEV}
#assert_output -p 'volume serial : 0xc0ffee'
}

0 comments on commit e5e8ac2

Please sign in to comment.