FOSSology  4.6.0
Open Source License Compliance by Open Source Software
test_ununpack-lzip.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2025 Siemens Healthineers AG
3  SPDX-FileContributor: Sushant Kumar <sushant.kumar@siemens-healthineers.com>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 #include "run_tests.h"
9 
15 /* locals */
16 static int Result = 0;
17 
25 {
26  deleteTmpFiles("./test-result/");
27  exists = file_dir_exists("./test-result/");
28  FO_ASSERT_EQUAL(exists, 0); // not existing
29 
30  MkDirs("./test-result/test.lz.dir/");
31  Filename = "../testdata/test.lz";
32  /* Ensure test.lz contains a file named 'data.tar' for this assertion */
33  Result = ExtractLzip(Filename, "test.lz", "./test-result/test.lz.dir");
34 
35  exists = file_dir_exists("./test-result/test.lz.dir/test");
36  FO_ASSERT_EQUAL(exists, 1); // existing
37  FO_ASSERT_EQUAL(Result, 0); // Extract lzip successfully
38 }
39 
47 {
48  deleteTmpFiles("./test-result/");
49  exists = file_dir_exists("./test-result/");
50  FO_ASSERT_EQUAL(exists, 0);
51 
52  MkDirs("./test-result/test.tlz.dir/");
53  Filename = "../testdata/test.tlz";
54  Result = ExtractLzip(Filename, "test.tlz", "./test-result/test.tlz.dir");
55 
56  exists = file_dir_exists("./test-result/test.tlz.dir/test.tar");
57  FO_ASSERT_EQUAL(exists, 1);
58  FO_ASSERT_EQUAL(Result, 0);
59 }
60 
68 {
69  deleteTmpFiles("./test-result/");
70  exists = file_dir_exists("./test-result/");
71  FO_ASSERT_EQUAL(exists, 0);
72 
73  MkDirs("./test-result/test.tar.lz.dir/");
74  Filename = "../testdata/test.tar.lz";
75  Result = ExtractLzip(Filename, "test.tar.lz", "./test-result/test.tar.lz.dir");
76 
77  exists = file_dir_exists("./test-result/test.tar.lz.dir/test.tar");
78  FO_ASSERT_EQUAL(exists, 1);
79  FO_ASSERT_EQUAL(Result, 0);
80 }
81 
89 {
90  deleteTmpFiles("./test-result/");
91  exists = file_dir_exists("./test-result/");
92  FO_ASSERT_EQUAL(exists, 0);
93 
94  Result = ExtractLzip("", "", "");
95  FO_ASSERT_EQUAL(Result, 1);
96 }
97 
105 {
106  deleteTmpFiles("./test-result/");
107  exists = file_dir_exists("./test-result/");
108  FO_ASSERT_EQUAL(exists, 0);
109 
110  MkDirs("./test-result/no_file.dir/");
111  Filename = "../testdata/non_existent_file.lz";
112  Result = ExtractLzip(Filename, "non_existent_file.lz", "./test-result/no_file.dir");
113  FO_ASSERT_EQUAL(Result, 1);
114 }
115 
116 /* ************************************************************************** */
117 /* **** cunit test cases **************************************************** */
118 /* ************************************************************************** */
119 
120 CU_TestInfo ExtractLzip_testcases[] =
121 {
122  {"Testing function ExtractLzip for .lz file:", testExtractLzipFile},
123  {"Testing function ExtractLzip for .tlz file:", testExtractTlzFile},
124  {"Testing function ExtractLzip for .tar.lz file:", testExtractTarLzFile},
125  {"Testing function ExtractLzip for empty parameters:", testExtractLzipEmptyParameters},
126  {"Testing function ExtractLzip for error parameters:", testExtractLzipErrorParameters},
127  CU_TEST_INFO_NULL
128 };
static int Result
Result of calls.
Definition: test_CopyFile.c:17
CU_TestInfo ExtractLzip_testcases[]
Lzip test cases.
void testExtractTarLzFile()
unpack tar.lz file
void testExtractLzipErrorParameters()
abnormal parameters
void testExtractTlzFile()
unpack tlz (tar.lz) file
void testExtractLzipEmptyParameters()
abnormal parameters
void testExtractLzipFile()
unpack lzip file
int ExtractLzip(char *Source, const char *OrigName, char *Destination)
Given an lzip file, extract the contents to the directory.
Definition: ununpack-lzip.c:23
int MkDirs(char *Fname)
Same as command-line "mkdir -p".
Definition: utils.c:249
int file_dir_exists(char *path_name)
test if a file or directory exists
Definition: run_tests.c:94
int exists
Default not exists.
Definition: run_tests.c:20
char * Filename
Filename.
Definition: run_tests.c:17