FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_ununpack-ar.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2010-2012 Hewlett-Packard Development Company, L.P.
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.ar.dir/");
27  Filename = "../testdata/test.ar";
28  Result = ExtractAR(Filename, "./test-result/test.ar.dir");
29  exists = file_dir_exists("./test-result/test.ar.dir/test.tar");
30  FO_ASSERT_EQUAL(exists, 1); // existing
31  FO_ASSERT_EQUAL(Result, 0); // Extract archieve library 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.deb.dir/");
46  Filename = "../testdata/test.deb";
47  Result = ExtractAR(Filename, "./test-result/test.deb.dir");
48  exists = file_dir_exists("./test-result/test.deb.dir/data.tar.xz");
49  FO_ASSERT_EQUAL(exists, 1); // existing
50  FO_ASSERT_EQUAL(Result, 0); // Extract archieve library successfully
51 }
52 
60 {
61  deleteTmpFiles("./test-result/");
62  exists = file_dir_exists("./test-result/");
63  FO_ASSERT_EQUAL(exists, 0); // not existing
64  Result = ExtractAR("", ""); // empty parameters
65  FO_ASSERT_EQUAL(Result, 1); // fail to Extract archieve library
66 }
67 
75 {
76  deleteTmpFiles("./test-result/");
77  exists = file_dir_exists("./test-result/");
78  FO_ASSERT_EQUAL(exists, 0); // not existing
79  MkDirs("./test-result/test.rpm.dir/");
80  Filename = "../testdata/test.rpm";
81  Result = ExtractAR(Filename, "./test-result/test.dir");
82  FO_ASSERT_EQUAL(Result, 1); // fail to Extract archieve library
83 }
84 
85 /* ************************************************************************** */
86 /* **** cunit test cases **************************************************** */
87 /* ************************************************************************** */
88 
89 CU_TestInfo ExtractAR_testcases[] =
90 {
91  {"Testing function testExtractAR for archive library file:", testExtractAR4ArchiveLibraryFile},
92  {"Testing function testExtractAR for deb file:", testExtractAR4DebFile},
93  {"Testing function testExtractAR for abnormal parameters:", testExtractAR4EmptyParameters},
94  {"Testing function testExtractAR for error parameters:", testExtractAR4ErrorParameters},
95  CU_TEST_INFO_NULL
96 };
static int Result
Result of calls.
Definition: test_CopyFile.c:17
CU_TestInfo ExtractAR_testcases[]
AR test cases.
void testExtractAR4DebFile()
unpack deb file
void testExtractAR4EmptyParameters()
abnormal parameters
void testExtractAR4ArchiveLibraryFile()
unpack archive library file
void testExtractAR4ErrorParameters()
abnormal parameters
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