xref: /aosp_15_r20/external/toybox/tests/xzcat.test (revision cf5a6c84e2b8763fc1a7db14496fd4742913b199)
1#!/bin/bash
2
3# Copyright 2014 Divya Kothari <[email protected]>
4# Copyright 2014 Naha Maggu <[email protected]>
5
6[ -f testing.sh ] && . testing.sh
7
8#testing "name" "command" "result" "infile" "stdin"
9echo "hello" > file
10tar -cJf file.xz file
11# Get system xzcat
12xzcatExe=`which xzcat`
13$xzcatExe file.xz > xzcatOut
14testcmd "- decompresses a single file" "file.xz > Tempfile && echo "yes"; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile" "yes\nyes\n" "" ""
15
16#testing "name" "command" "result" "infile" "stdin"
17echo "hello" > file1
18echo "hi" > file2
19echo "Hi, Good morning !! I am a xzcat tester" > file3
20tar -cJf file1.xz file1
21tar -cJf file2.xz file2
22tar -cJf file3.xz file3
23# Get system xzcat
24xzcatExe=`which xzcat`
25$xzcatExe file1.xz file2.xz file3.xz > xzcatOut
26testcmd "- decompresses multiple files" "file1.xz file2.xz file3.xz > Tempfile && echo "yes" ; diff Tempfile xzcatOut && echo "yes"; rm -rf file* xzcatOut Tempfile " "yes\nyes\n" "" ""
27echo "This is NOT a XZ file!!!" > file
28testcmd "bad file" "file 2>&1; rm file" "xzcat: Not a .xz file\n" "" ""
29echo "Surely nothing bad will happen to this compressed data!" > file
30tar -cJf file.xz file
31truncate -s 16 file.xz
32testcmd "corrupted file" "file.xz 2>&1" "xzcat: File is corrupt\n" "" ""
33