FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_FindCmd.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2010-2014 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"
18 
30 {
31  char *Filename = "../testdata/test.7z";
32  int result = 0;
33  result = FindCmd(Filename);
34  //FO_ASSERT_EQUAL(result, 15);
35  if (result == 16 || result == 17)
36  {
37  FO_PASS(result);
38 
39  }else
40  {
41  FO_FAIL(result);
42  }
43 }
44 
52 {
53  char *Filename = "../testdata/test_1-1.dsc";
54  int result = 0;
55  result = FindCmd(Filename);
56  FO_ASSERT_EQUAL(result, 28);
57 }
58 
66 {
67  char *Filename = "../testdata/test.cab";
68  int result = 0;
69  result = FindCmd(Filename);
70  FO_ASSERT_EQUAL(result, 17);
71 }
72 
80 {
81  char *Filename = "../testdata/test.msi";
82  int result = 0;
83  result = FindCmd(Filename);
84  FO_ASSERT_EQUAL(result, 17);
85 }
86 
94 {
95  char *Filename = "../testdata/test.rpm";
96  int result = 0;
97  result = FindCmd(Filename);
98  FO_ASSERT_EQUAL(result, 18);
99  Filename = "../testdata/test.rpm";
100  result = FindCmd(Filename);
101  FO_ASSERT_EQUAL(result, 18);
102 }
103 
111 {
112  char *Filename = "../testdata/test.iso";
113  int result = 0;
114  result = FindCmd(Filename);
115  FO_ASSERT_EQUAL(result, 21); // let isoinfo handle the isos
116 }
117 
125 {
126  char *Filename = "../testdata/test.zip";
127  int result = 0;
128  result = FindCmd(Filename);
129  FO_ASSERT_EQUAL(result, 10);
130 }
131 
139 {
140  char *Filename = "../testdata/test.rar";
141  int result = 0;
142  result = FindCmd(Filename);
143  FO_ASSERT_EQUAL(result, 14);
144 }
145 
153 {
154  char *Filename = "../testdata/test.cpio";
155  int result = 0;
156  result = FindCmd(Filename);
157  FO_ASSERT_EQUAL(result, 13);
158 }
159 
160 
168 {
169  char *Filename = "../testdata/test.deb";
170  int result = 0;
171  result = FindCmd(Filename);
172  FO_ASSERT_EQUAL(result, 20); /* let ar handle udeb */
173 }
174 
182 {
183  char *Filename = "../testdata/test.ar";
184  int result = 0;
185  result = FindCmd(Filename);
186  FO_ASSERT_EQUAL(result, 19);
187 }
188 
189 
197 {
198  char *Filename = "../testdata/emptydirs.tar";
199  int result = 0;
200  result = FindCmd(Filename);
201  FO_ASSERT_EQUAL(result, 11);
202 }
203 
204 
212 {
213  char *Filename = "../testdata/test.z";
214  int result = 0;
215  result = FindCmd(Filename);
216  FO_ASSERT_EQUAL(result, 3);
217 }
218 
226 {
227  char *Filename = "../testdata/test.exe";
228  int result = 0;
229  result = FindCmd(Filename);
230  FO_ASSERT_EQUAL(result, 31); /* this can be unpacked by 7z */
231 }
232 
240 {
241  char *Filename = "../testdata/fossI16L335U29.tar.bz2";
242  int result = 0;
243  result = FindCmd(Filename);
244  FO_ASSERT_EQUAL(result, 5);
245 }
246 
254 {
255  char *Filename = "../testdata/ext3test-image";
256  int result = 0;
257  result = FindCmd(Filename);
258  FO_ASSERT_EQUAL(result, 26);
259 }
260 
268 {
269  char *Filename = "../testdata/ext2file.fs";
270  int result = 0;
271  result = FindCmd(Filename);
272  FO_ASSERT_EQUAL(result, 25);
273 }
274 
282 {
283  char *Filename = "../testdata/fatfile.fs";
284  int result = 0;
285  result = FindCmd(Filename);
286  //FO_ASSERT_EQUAL(result, 22);
287  if (result == 17 || result == 23)
288  {
289  FO_PASS(result);
290  }else{
291  FO_FAIL(result);
292  }
293 
294 }
295 
303 {
304  char *Filename = "../testdata/ntfsfile.fs";
305  int result = 0;
306  result = FindCmd(Filename);
307  FO_ASSERT_EQUAL(result, 24);
308 }
309 
318 {
319  char *Filename = "../testdata/vmlinuz-2.6.26-2-686";
320  int result = 0;
321  result = FindCmd(Filename);
322  FO_ASSERT_EQUAL(result, 27);
323 }
324 
325 
326 /* ************************************************************************** */
327 /* **** cunit test cases **************************************************** */
328 /* ************************************************************************** */
329 
330 CU_TestInfo FindCmd_testcases[] =
331 {
332  {"FindCmd: normal:", testFindCmdNormal},
333  {"FindCmd: dsc", testFindCmd4DscFile},
334  {"FindCmd: cab", testFindCmd4CabFile},
335  {"FindCmd: msi", testFindCmd4MsiFile},
336  {"FindCmd: rpm", testFindCmd4RpmFile},
337  {"FindCmd: iso", testFindCmd4IsoFile},
338  {"FindCmd: zip", testFindCmd4ZipFile},
339  {"FindCmd: rar", testFindCmd4RarFile},
340  {"FindCmd: cpio", testFindCmd4CpioFile},
341  {"FindCmd: deb", testFindCmd4DebFile},
342  {"FindCmd: archive lib", testFindCmd4ArchiveLibFile},
343  {"FindCmd: tar", testFindCmd4TarFile},
344  {"FindCmd: Z", testFindCmd4ZFile},
345  {"FindCmd: exe", testFindCmd4ExeFile},
346  {"FindCmd: bz2", testFindCmd4Bz2File},
347  {"FindCmd: ext2 file system", testFindCmd4Ext2File},
348  {"FindCmd: ext3 file system", testFindCmd4Ext3File},
349  {"FindCmd: fat file system", testFindCmd4FatFile},
350  {"FindCmd: ntfs file system", testFindCmd4NtfsFile},
351  //{"FindCmd: partition", testFindCmd4PartitionFile},
352  CU_TEST_INFO_NULL
353 };
void testFindCmd4Ext3File()
find ext3 fs
Definition: test_FindCmd.c:253
CU_TestInfo FindCmd_testcases[]
FindCmd() test cases.
Definition: test_FindCmd.c:330
void testFindCmd4ZFile()
find xx.z
Definition: test_FindCmd.c:211
void testFindCmd4FatFile()
find fat fs
Definition: test_FindCmd.c:281
void testFindCmd4RpmFile()
find xx.rpm
Definition: test_FindCmd.c:93
void testFindCmdNormal()
find xx.7z
Definition: test_FindCmd.c:29
void testFindCmd4IsoFile()
find xx.iso
Definition: test_FindCmd.c:110
void testFindCmd4RarFile()
find xx.rar
Definition: test_FindCmd.c:138
int FindCmd(char *Filename)
Given a file name, determine the type of extraction command. This uses Magic.
Definition: utils.c:860
void testFindCmd4DscFile()
find xx.dsc
Definition: test_FindCmd.c:51
void testFindCmd4CpioFile()
find xx.cpio
Definition: test_FindCmd.c:152
void testFindCmd4NtfsFile()
find ntfs fs
Definition: test_FindCmd.c:302
void testFindCmd4DebFile()
find xx.deb
Definition: test_FindCmd.c:167
void testFindCmd4Bz2File()
find xx.bz2
Definition: test_FindCmd.c:239
void testFindCmd4Ext2File()
find ext2 fs
Definition: test_FindCmd.c:267
void testFindCmd4ArchiveLibFile()
find xx.ar
Definition: test_FindCmd.c:181
void testFindCmd4PartitionFile()
find partition file
Definition: test_FindCmd.c:317
char * Filename
Filename.
Definition: run_tests.c:28
void testFindCmd4MsiFile()
find xx.msi
Definition: test_FindCmd.c:79
void testFindCmd4CabFile()
find xx.cab
Definition: test_FindCmd.c:65
void testFindCmd4ZipFile()
find xx.zip
Definition: test_FindCmd.c:124
void testFindCmd4TarFile()
find xx.tar
Definition: test_FindCmd.c:196
void testFindCmd4ExeFile()
find xx.exe
Definition: test_FindCmd.c:225