FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_TraverseStart.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2010-2011 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 static char *Label = "";
23 
28 {
29  MagicCookie = magic_open(MAGIC_PRESERVE_ATIME|MAGIC_MIME);
30  if (MagicCookie == NULL)
31  {
32  fprintf(stderr,"FATAL: Failed to initialize magic cookie\n");
33  return -1;
34  }
35 
36  magic_load(MagicCookie,NULL);
37  return 0;
38 }
39 
44 {
45  magic_close(MagicCookie);
46  return 0;
47 }
48 
56 {
57  Filename = "../testdata/testthree.zip";
58  deleteTmpFiles("./test-result/");
59  exists = file_dir_exists("./test-result/testthree.zip.dir/testtwo.zip.dir/test.zip.dir/ununpack");
60  FO_ASSERT_EQUAL(exists, 0); // ./test-result/ is not existing
62  exists = file_dir_exists("./test-result/testthree.zip.dir/testtwo.zip.dir/test.zip.dir/ununpack");
63  FO_ASSERT_EQUAL(exists, 1); // ./test-result/ is existing
64 }
65 
73 {
74  Filename = "../testdata/";
75  deleteTmpFiles("./test-result/");
76  exists = file_dir_exists("./test-result/test.jar.dir/ununpack");
77  FO_ASSERT_EQUAL(exists, 0); // ./test-result/ is not existing
79  exists = file_dir_exists("./test-result/test.jar.dir/ununpack");
80  FO_ASSERT_EQUAL(exists, 1); // ./test-result/ is existing
81 }
82 
83 
84 /* ************************************************************************** */
85 /* **** cunit test cases **************************************************** */
86 /* ************************************************************************** */
87 
88 CU_TestInfo TraverseStart_testcases[] =
89 {
90  {"TraverseStart normal:", testTraverseStartNormal},
91  {"TraverseStart dir:", testTraverseStartDir},
92  CU_TEST_INFO_NULL
93 };
int file_dir_exists(char *path_name)
test if a file or directory exists
Definition: run_tests.c:136
int TraverseStartInit()
initialize
void testTraverseStartNormal()
Test TraverseStart() for normal file.
int TraverseStartClean()
clean env and others
CU_TestInfo TraverseStart_testcases[]
TraverseStart() test cases.
char * NewDir
Test result directory.
Definition: run_tests.c:29
magic_t MagicCookie
for Magic
Definition: finder.c:34
char * Filename
Filename.
Definition: run_tests.c:28
int exists
Default not exists.
Definition: run_tests.c:31
void TraverseStart(char *Filename, char *Label, char *NewDir, int Recurse)
Find all files (assuming a directory) and process (unpack) all of them.
Definition: traverse.c:34
int Recurse
Level of unpack recursion. Default to infinite.
Definition: run_tests.c:30
void testTraverseStartDir()
test TraverseStart() for directory