FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
testSetEnv.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2011-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 
18 /* cunit includes */
19 #include <CUnit/CUnit.h>
20 #include "wget_agent.h"
21 #include "utility.h"
22 
28 static char Source[MAX_LENGTH];
29 static char TempFileDir[MAX_LENGTH];
30 
31 /* test functions */
32 
37 {
38  GlobalUploadKey = -1;
39  memset(GlobalTempFile, 0, STRMAX);
40  memset(GlobalURL, 0, URLMAX);
41  memset(GlobalParam, 0, STRMAX);
42  return 0;
43 }
44 
49 {
50  GlobalUploadKey = -1;
51  memset(GlobalTempFile, 0, STRMAX);
52  memset(GlobalURL, 0, URLMAX);
53  memset(GlobalParam, 0, STRMAX);
54  return 0;
55 }
64 {
65  strcpy(Source, "38 - https://mirrors.kernel.org/fossology/releases/3.0.0/ubuntu/ -l 1 -R *.deb");
66  strcpy(TempFileDir, "./test_result");
67  SetEnv(Source, TempFileDir);
68  CU_ASSERT_EQUAL(GlobalUploadKey, 38);
69  char *cptr = strstr(GlobalTempFile, "./test_result/wget."); /* is like ./test_result/wget.29923 */
70  CU_ASSERT_PTR_NOT_NULL(cptr);
71  CU_ASSERT_STRING_EQUAL(GlobalURL, "https://mirrors.kernel.org/fossology/releases/3.0.0/ubuntu/");
72  CU_ASSERT_STRING_EQUAL(GlobalParam, "-l 1 -R *.deb");
73 }
74 
78 CU_TestInfo testcases_SetEnv[] =
79 {
80 #if 0
81 #endif
82 {"SetEnv:Normal", testSetEnvNormal},
83  CU_TEST_INFO_NULL
84 };
85 
long GlobalUploadKey
Input for this system.
Definition: wget_agent.c:35
char GlobalParam[STRMAX]
Additional parameters.
Definition: wget_agent.c:39
CU_TestInfo testcases_SetEnv[]
testcases for function SetEnv
Definition: testSetEnv.c:78
int SetEnvInit()
initialize
Definition: testSetEnv.c:36
char GlobalURL[URLMAX]
URL to download.
Definition: wget_agent.c:37
void SetEnv(char *S, char *TempFileDir)
Convert input pairs into globals.
Definition: wget_agent.c:695
void testSetEnvNormal()
set the global variables
Definition: testSetEnv.c:63
char GlobalTempFile[STRMAX]
Temp file to be used.
Definition: wget_agent.c:36
int SetEnvClean()
clean the env
Definition: testSetEnv.c:48