xref: /aosp_15_r20/external/zstd/tests/cli-tests/compression/basic.sh (revision 01826a4963a0d8a59bc3812d29bdf0fb76416722)
1#!/bin/sh
2
3set -e
4
5# Uncomment the set -v line for debugging
6# set -v
7
8# Test compression flags and check that they work
9zstd file                 ; zstd -t file.zst
10zstd -f file              ; zstd -t file.zst
11zstd -f -z file           ; zstd -t file.zst
12zstd -f -k file           ; zstd -t file.zst
13zstd -f -C file           ; zstd -t file.zst
14zstd -f --check file      ; zstd -t file.zst
15zstd -f --no-check file   ; zstd -t file.zst
16zstd -f -- file           ; zstd -t file.zst
17
18# Test output file compression
19zstd -o file-out.zst ; zstd -t file-out.zst
20zstd -fo file-out.zst; zstd -t file-out.zst
21
22# Test compression to stdout
23zstd -c file       | zstd -t
24zstd --stdout file | zstd -t
25println bob | zstd | zstd -t
26
27# Test keeping input file when compressing to stdout in gzip mode
28if $(command -v $ZSTD_SYMLINK_DIR/gzip); then
29    $ZSTD_SYMLINK_DIR/gzip -c file       | zstd -t ; test -f file
30    $ZSTD_SYMLINK_DIR/gzip --stdout file | zstd -t ; test -f file
31fi
32
33# Test --rm
34cp file file-rm
35zstd --rm file-rm; zstd -t file-rm.zst
36test ! -f file-rm
37