FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_FindCmd.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2010-2014 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 #include "run_tests.h"
7 
19 {
20  char *Filename = "../testdata/test.7z";
21  int result = 0;
22  result = FindCmd(Filename);
23  //FO_ASSERT_EQUAL(result, 15);
24  if (result == 16 || result == 17)
25  {
26  FO_PASS(result);
27 
28  }else
29  {
30  FO_FAIL(result);
31  }
32 }
33 
41 {
42  char *Filename = "../testdata/test_1-1.dsc";
43  int result = 0;
44  result = FindCmd(Filename);
45  FO_ASSERT_EQUAL(result, 28);
46 }
47 
55 {
56  char *Filename = "../testdata/test.cab";
57  int result = 0;
58  result = FindCmd(Filename);
59  FO_ASSERT_EQUAL(result, 17);
60 }
61 
69 {
70  char *Filename = "../testdata/test.msi";
71  int result = 0;
72  result = FindCmd(Filename);
73  FO_ASSERT_EQUAL(result, 17);
74 }
75 
83 {
84  char *Filename = "../testdata/test.rpm";
85  int result = 0;
86  result = FindCmd(Filename);
87  FO_ASSERT_EQUAL(result, 18);
88  Filename = "../testdata/test.rpm";
89  result = FindCmd(Filename);
90  FO_ASSERT_EQUAL(result, 18);
91 }
92 
100 {
101  char *Filename = "../testdata/test.iso";
102  int result = 0;
103  result = FindCmd(Filename);
104  FO_ASSERT_EQUAL(result, 21); // let isoinfo handle the isos
105 }
106 
114 {
115  char *Filename = "../testdata/test.zip";
116  int result = 0;
117  result = FindCmd(Filename);
118  FO_ASSERT_EQUAL(result, 10);
119 }
120 
128 {
129  char *Filename = "../testdata/test.rar";
130  int result = 0;
131  result = FindCmd(Filename);
132  FO_ASSERT_EQUAL(result, 14);
133 }
134 
142 {
143  char *Filename = "../testdata/test.cpio";
144  int result = 0;
145  result = FindCmd(Filename);
146  FO_ASSERT_EQUAL(result, 13);
147 }
148 
149 
157 {
158  char *Filename = "../testdata/test.deb";
159  int result = 0;
160  result = FindCmd(Filename);
161  FO_ASSERT_EQUAL(result, 20); /* let ar handle udeb */
162 }
163 
171 {
172  char *Filename = "../testdata/test.ar";
173  int result = 0;
174  result = FindCmd(Filename);
175  FO_ASSERT_EQUAL(result, 19);
176 }
177 
178 
186 {
187  char *Filename = "../testdata/emptydirs.tar";
188  int result = 0;
189  result = FindCmd(Filename);
190  FO_ASSERT_EQUAL(result, 11);
191 }
192 
193 
201 {
202  char *Filename = "../testdata/test.z";
203  int result = 0;
204  result = FindCmd(Filename);
205  FO_ASSERT_EQUAL(result, 3);
206 }
207 
215 {
216  char *Filename = "../testdata/test.exe";
217  int result = 0;
218  result = FindCmd(Filename);
219  FO_ASSERT_EQUAL(result, 31); /* this can be unpacked by 7z */
220 }
221 
229 {
230  char *Filename = "../testdata/fossI16L335U29.tar.bz2";
231  int result = 0;
232  result = FindCmd(Filename);
233  FO_ASSERT_EQUAL(result, 5);
234 }
235 
243 {
244  char *Filename = "../testdata/ext3test-image";
245  int result = 0;
246  result = FindCmd(Filename);
247  FO_ASSERT_EQUAL(result, 26);
248 }
249 
257 {
258  char *Filename = "../testdata/ext2file.fs";
259  int result = 0;
260  result = FindCmd(Filename);
261  FO_ASSERT_EQUAL(result, 25);
262 }
263 
271 {
272  char *Filename = "../testdata/fatfile.fs";
273  int result = 0;
274  result = FindCmd(Filename);
275  //FO_ASSERT_EQUAL(result, 22);
276  if (result == 17 || result == 23)
277  {
278  FO_PASS(result);
279  }else{
280  FO_FAIL(result);
281  }
282 
283 }
284 
292 {
293  char *Filename = "../testdata/ntfsfile.fs";
294  int result = 0;
295  result = FindCmd(Filename);
296  FO_ASSERT_EQUAL(result, 24);
297 }
298 
307 {
308  char *Filename = "../testdata/vmlinuz-2.6.26-2-686";
309  int result = 0;
310  result = FindCmd(Filename);
311  FO_ASSERT_EQUAL(result, 27);
312 }
313 
314 
315 /* ************************************************************************** */
316 /* **** cunit test cases **************************************************** */
317 /* ************************************************************************** */
318 
319 CU_TestInfo FindCmd_testcases[] =
320 {
321  {"FindCmd: normal:", testFindCmdNormal},
322  {"FindCmd: dsc", testFindCmd4DscFile},
323  {"FindCmd: cab", testFindCmd4CabFile},
324  {"FindCmd: msi", testFindCmd4MsiFile},
325  {"FindCmd: rpm", testFindCmd4RpmFile},
326  {"FindCmd: iso", testFindCmd4IsoFile},
327  {"FindCmd: zip", testFindCmd4ZipFile},
328  {"FindCmd: rar", testFindCmd4RarFile},
329  {"FindCmd: cpio", testFindCmd4CpioFile},
330  {"FindCmd: deb", testFindCmd4DebFile},
331  {"FindCmd: archive lib", testFindCmd4ArchiveLibFile},
332  {"FindCmd: tar", testFindCmd4TarFile},
333  {"FindCmd: Z", testFindCmd4ZFile},
334  {"FindCmd: exe", testFindCmd4ExeFile},
335  {"FindCmd: bz2", testFindCmd4Bz2File},
336  {"FindCmd: ext2 file system", testFindCmd4Ext2File},
337  {"FindCmd: ext3 file system", testFindCmd4Ext3File},
338  {"FindCmd: fat file system", testFindCmd4FatFile},
339  {"FindCmd: ntfs file system", testFindCmd4NtfsFile},
340  //{"FindCmd: partition", testFindCmd4PartitionFile},
341  CU_TEST_INFO_NULL
342 };
void testFindCmd4ZipFile()
find xx.zip
Definition: test_FindCmd.c:113
void testFindCmd4FatFile()
find fat fs
Definition: test_FindCmd.c:270
void testFindCmd4ExeFile()
find xx.exe
Definition: test_FindCmd.c:214
void testFindCmd4MsiFile()
find xx.msi
Definition: test_FindCmd.c:68
CU_TestInfo FindCmd_testcases[]
FindCmd() test cases.
Definition: test_FindCmd.c:319
void testFindCmdNormal()
find xx.7z
Definition: test_FindCmd.c:18
void testFindCmd4Ext3File()
find ext3 fs
Definition: test_FindCmd.c:242
void testFindCmd4NtfsFile()
find ntfs fs
Definition: test_FindCmd.c:291
void testFindCmd4Bz2File()
find xx.bz2
Definition: test_FindCmd.c:228
void testFindCmd4DscFile()
find xx.dsc
Definition: test_FindCmd.c:40
void testFindCmd4RpmFile()
find xx.rpm
Definition: test_FindCmd.c:82
void testFindCmd4IsoFile()
find xx.iso
Definition: test_FindCmd.c:99
void testFindCmd4PartitionFile()
find partition file
Definition: test_FindCmd.c:306
void testFindCmd4Ext2File()
find ext2 fs
Definition: test_FindCmd.c:256
void testFindCmd4ArchiveLibFile()
find xx.ar
Definition: test_FindCmd.c:170
void testFindCmd4DebFile()
find xx.deb
Definition: test_FindCmd.c:156
void testFindCmd4RarFile()
find xx.rar
Definition: test_FindCmd.c:127
void testFindCmd4CabFile()
find xx.cab
Definition: test_FindCmd.c:54
void testFindCmd4CpioFile()
find xx.cpio
Definition: test_FindCmd.c:141
void testFindCmd4ZFile()
find xx.z
Definition: test_FindCmd.c:200
void testFindCmd4TarFile()
find xx.tar
Definition: test_FindCmd.c:185
int FindCmd(char *Filename)
Given a file name, determine the type of extraction command. This uses Magic.
Definition: utils.c:850
char * Filename
Filename.
Definition: run_tests.c:17