FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_TraverseStart.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2010-2011 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
6 #include "run_tests.h"
11 static char *Label = "";
12 
17 {
18  MagicCookie = magic_open(MAGIC_PRESERVE_ATIME|MAGIC_MIME);
19  if (MagicCookie == NULL)
20  {
21  fprintf(stderr,"FATAL: Failed to initialize magic cookie\n");
22  return -1;
23  }
24 
25  magic_load(MagicCookie,NULL);
26  return 0;
27 }
28 
33 {
34  magic_close(MagicCookie);
35  return 0;
36 }
37 
45 {
46  Filename = "../testdata/testthree.zip";
47  deleteTmpFiles("./test-result/");
48  exists = file_dir_exists("./test-result/testthree.zip.dir/testtwo.zip.dir/test.zip.dir/ununpack");
49  FO_ASSERT_EQUAL(exists, 0); // ./test-result/ is not existing
51  exists = file_dir_exists("./test-result/testthree.zip.dir/testtwo.zip.dir/test.zip.dir/ununpack");
52  FO_ASSERT_EQUAL(exists, 1); // ./test-result/ is existing
53 }
54 
62 {
63  Filename = "../testdata/";
64  deleteTmpFiles("./test-result/");
65  exists = file_dir_exists("./test-result/test.jar.dir/ununpack");
66  FO_ASSERT_EQUAL(exists, 0); // ./test-result/ is not existing
68  exists = file_dir_exists("./test-result/test.jar.dir/ununpack");
69  FO_ASSERT_EQUAL(exists, 1); // ./test-result/ is existing
70 }
71 
72 
73 /* ************************************************************************** */
74 /* **** cunit test cases **************************************************** */
75 /* ************************************************************************** */
76 
77 CU_TestInfo TraverseStart_testcases[] =
78 {
79  {"TraverseStart normal:", testTraverseStartNormal},
80  {"TraverseStart dir:", testTraverseStartDir},
81  CU_TEST_INFO_NULL
82 };
magic_t MagicCookie
for Magic
Definition: finder.c:23
void testTraverseStartDir()
test TraverseStart() for directory
int TraverseStartInit()
initialize
int TraverseStartClean()
clean env and others
void testTraverseStartNormal()
Test TraverseStart() for normal file.
CU_TestInfo TraverseStart_testcases[]
TraverseStart() test cases.
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:23
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
int Recurse
Level of unpack recursion. Default to infinite.
Definition: run_tests.c:19
char * NewDir
Test result directory.
Definition: run_tests.c:18
char * Filename
Filename.
Definition: run_tests.c:17