FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_ununpack-zstd.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2023 Siemens AG
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 #include "run_tests.h"
11 /* locals */
12 static int Result = 0;
13 
14 
22 {
23  deleteTmpFiles("./test-result/");
24  exists = file_dir_exists("./test-result/");
25  FO_ASSERT_EQUAL(exists, 0); // not existing
26  MkDirs("./test-result/test.zst.dir/");
27  Filename = "../testdata/test.zst";
28  Result = ExtractAR(Filename, "./test-result/test.ar.zst");
29  exists = file_dir_exists("./test-result/test.zst.dir/test.tar");
30  FO_ASSERT_EQUAL(exists, 1); // existing
31  FO_ASSERT_EQUAL(Result, 0); // Extract ZST file successfully
32 }
33 
41 {
42  deleteTmpFiles("./test-result/");
43  exists = file_dir_exists("./test-result/");
44  FO_ASSERT_EQUAL(exists, 0); // not existing
45  MkDirs("./test-result/test.lz4.dir/");
46  Filename = "../testdata/test.lz4";
47  Result = ExtractAR(Filename, "./test-result/test.lz4.dir");
48  exists = file_dir_exists("./test-result/test.lz4.dir/data.tar");
49  FO_ASSERT_EQUAL(exists, 1); // existing
50  FO_ASSERT_EQUAL(Result, 0); // Extract lz4 successfully
51 }
52 
60 {
61  deleteTmpFiles("./test-result/");
62  exists = file_dir_exists("./test-result/");
63  FO_ASSERT_EQUAL(exists, 0); // not existing
64  MkDirs("./test-result/test.lzma.dir/");
65  Filename = "../testdata/test.lzma";
66  Result = ExtractAR(Filename, "./test-result/test.lzma.dir");
67  exists = file_dir_exists("./test-result/test.lzma.dir/data.tar");
68  FO_ASSERT_EQUAL(exists, 1); // existing
69  FO_ASSERT_EQUAL(Result, 0); // Extract lzma successfully
70 }
71 
79 {
80  deleteTmpFiles("./test-result/");
81  exists = file_dir_exists("./test-result/");
82  FO_ASSERT_EQUAL(exists, 0); // not existing
83  Result = ExtractAR("", ""); // empty parameters
84  FO_ASSERT_EQUAL(Result, 1); // fail to extract
85 }
86 
94 {
95  deleteTmpFiles("./test-result/");
96  exists = file_dir_exists("./test-result/");
97  FO_ASSERT_EQUAL(exists, 0); // not existing
98  MkDirs("./test-result/null_file.dir/");
99  Filename = "../testdata/null_file";
100  Result = ExtractAR(Filename, "./test-result/null_file.dir");
101  FO_ASSERT_EQUAL(Result, 1); // fail to extract
102 }
103 
104 /* ************************************************************************** */
105 /* **** cunit test cases **************************************************** */
106 /* ************************************************************************** */
107 
108 CU_TestInfo ExtractZstd_testcases[] =
109 {
110  {"Testing function testExtractZst for archive file:", testExtractZstdFile},
111  {"Testing function testExtractZst for lz4 file:", testExtractZstlz4File},
112  {"Testing function testExtractZst for lzma file:", testExtractZstlzmaFile},
113  {"Testing function testExtractZst for abnormal parameters:", testExtractZst4EmptyParameters},
114  {"Testing function testExtractZst for error parameters:", testExtractZst4ErrorParameters},
115  CU_TEST_INFO_NULL
116 };
static int Result
Result of calls.
Definition: test_CopyFile.c:17
void testExtractZstdFile()
unpack ZSTd file
CU_TestInfo ExtractZstd_testcases[]
Zstd test cases.
void testExtractZst4EmptyParameters()
abnormal parameters
void testExtractZstlzmaFile()
unpack lzma file
void testExtractZst4ErrorParameters()
abnormal parameters
void testExtractZstlz4File()
unpack lz4 file
int ExtractAR(char *Source, char *Destination)
Given an AR file, extract the contents to the directory. This uses the command ar.
Definition: ununpack-ar.c:26
int MkDirs(char *Fname)
Same as command-line "mkdir -p".
Definition: utils.c:248
int file_dir_exists(char *path_name)
test if a file or directory exists
Definition: run_tests.c:90
int exists
Default not exists.
Definition: run_tests.c:20
char * Filename
Filename.
Definition: run_tests.c:17