FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_ununpack-ar.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2010-2012 Hewlett-Packard Development Company, L.P.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *********************************************************************/
17 #include "run_tests.h"
22 /* locals */
23 static int Result = 0;
24 
25 
33 {
34  deleteTmpFiles("./test-result/");
35  exists = file_dir_exists("./test-result/");
36  FO_ASSERT_EQUAL(exists, 0); // not existing
37  MkDirs("./test-result/test.ar.dir/");
38  Filename = "../testdata/test.ar";
39  Result = ExtractAR(Filename, "./test-result/test.ar.dir");
40  exists = file_dir_exists("./test-result/test.ar.dir/test.tar");
41  FO_ASSERT_EQUAL(exists, 1); // existing
42  FO_ASSERT_EQUAL(Result, 0); // Extract archieve library successfully
43 }
44 
52 {
53  deleteTmpFiles("./test-result/");
54  exists = file_dir_exists("./test-result/");
55  FO_ASSERT_EQUAL(exists, 0); // not existing
56  MkDirs("./test-result/test.deb.dir/");
57  Filename = "../testdata/test.deb";
58  Result = ExtractAR(Filename, "./test-result/test.deb.dir");
59  exists = file_dir_exists("./test-result/test.deb.dir/data.tar.xz");
60  FO_ASSERT_EQUAL(exists, 1); // existing
61  FO_ASSERT_EQUAL(Result, 0); // Extract archieve library successfully
62 }
63 
71 {
72  deleteTmpFiles("./test-result/");
73  exists = file_dir_exists("./test-result/");
74  FO_ASSERT_EQUAL(exists, 0); // not existing
75  Result = ExtractAR("", ""); // empty parameters
76  FO_ASSERT_EQUAL(Result, 1); // fail to Extract archieve library
77 }
78 
86 {
87  deleteTmpFiles("./test-result/");
88  exists = file_dir_exists("./test-result/");
89  FO_ASSERT_EQUAL(exists, 0); // not existing
90  MkDirs("./test-result/test.rpm.dir/");
91  Filename = "../testdata/test.rpm";
92  Result = ExtractAR(Filename, "./test-result/test.dir");
93  FO_ASSERT_EQUAL(Result, 1); // fail to Extract archieve library
94 }
95 
96 /* ************************************************************************** */
97 /* **** cunit test cases **************************************************** */
98 /* ************************************************************************** */
99 
100 CU_TestInfo ExtractAR_testcases[] =
101 {
102  {"Testing function testExtractAR for archive library file:", testExtractAR4ArchiveLibraryFile},
103  {"Testing function testExtractAR for deb file:", testExtractAR4DebFile},
104  {"Testing function testExtractAR for abnormal parameters:", testExtractAR4EmptyParameters},
105  {"Testing function testExtractAR for error parameters:", testExtractAR4ErrorParameters},
106  CU_TEST_INFO_NULL
107 };
static int Result
Result of calls.
Definition: test_CopyFile.c:28
int file_dir_exists(char *path_name)
test if a file or directory exists
Definition: run_tests.c:136
void testExtractAR4EmptyParameters()
abnormal parameters
CU_TestInfo ExtractAR_testcases[]
AR test cases.
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:37
void testExtractAR4DebFile()
unpack deb file
void testExtractAR4ArchiveLibraryFile()
unpack archive library file
void testExtractAR4ErrorParameters()
abnormal parameters
char * Filename
Filename.
Definition: run_tests.c:28
int exists
Default not exists.
Definition: run_tests.c:31
int MkDirs(char *Fname)
Same as command-line "mkdir -p".
Definition: utils.c:259