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