Skip to content

test

test #28

Workflow file for this run

name: CI test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build cat-once
run: |
cargo build --release
sudo mv target/release/cat-once /usr/bin/cat-once
- name: Prepare test file
run: |
cat-once --file test.file --test-create-ascii-file-size=1000000000
sha1sum test.file > test-in.file.sha1
tar -cf - test.file | zstd -c > test.tar.zstd
- name: Mount tmpfs
run: |
mkdir tmp
sudo mount -t tmpfs -o size=1100M tmpfs tmp
cp test.tar.zstd tmp
cd tmp
cat-once --file test.tar.zstd > test2.tar.zstd
cat-once --file test2.tar.zstd | tar -I zstd -xf - -C .
sha1sum test.file > ../test-out.file.sha1
- name: Compare checksums
run: |
cat test-in.file.sha1
cat test-out.file.sha1
diff test-in.file.sha1 test-out.file.sha1
- name: Random tests
run: |
for i in {1..100}; do
file_size=$(( ( RANDOM % 10000000 ) + 1 ))
chunk_size=$(( ( RANDOM % 1000000 ) + 20000 ))
cat-once --file test.file --test-create-ascii-file-size=$file_size
sha1sum test.file > test-in.file.sha1
cargo run --release -- --file test.file --chunk-size $chunk_size > test-out.file
if [ ! -e "test.file" ]; then
echo "File does not exist."
exit 1
fi
mv test-out.file test.file
sha1sum test.file > test-out.file.sha1
diff test-in.file.sha1 test-out.file.sha1
done