~dricottone/my-utils

ref: 581955c8fa8a187f983dc223c947f12e9f9ad474 my-utils/archives/test_untar.sh -rwxr-xr-x 987 bytes
581955c8Dominic Ricottone Fix mktar 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/sh
# tests untar

# move to temp directory
cd test

test_decompression() {

  #set internal variables based on selected compression
  case "$1" in
    NONE)
      fn_compressed="decompression_target.tar"
      ;;
    GZIP)
      fn_compressed="decompression_target.tar.gz"
      ;;
    XZ)
      fn_compressed="decompression_target.tar.xz"
      ;;
    ZSTD)
      fn_compressed="decompression_target.tar.zst"
      ;;
    BZIP2)
      fn_compressed="decompression_target.tar.bz2"
      ;;
    *)
      printf "Failure in compression tests: not a valid scheme: '%s'\n" "$1"
      exit 1
      ;;
  esac

  # try decompression
  ../untar "$fn_compressed"
  if ! cmp decompression_result.txt decompression_target.txt >/dev/null 2>&1; then
    printf "Failure in decompression tests: '%s'\n" "$1"
    exit 1
  fi

  # clean up
  rm -f decompression_result.txt
}

test_decompression NONE
test_decompression GZIP
test_decompression XZ
test_decompression ZSTD
test_decompression BZIP2