Sync with 5.4.0
[deliverable/titan.core.git] / function_test / Config_Parser / extfunc.cc
CommitLineData
970ed795 1///////////////////////////////////////////////////////////////////////////////
3abe9331 2// Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
3// All rights reserved. This program and the accompanying materials
4// are made available under the terms of the Eclipse Public License v1.0
5// which accompanies this distribution, and is available at
6// http://www.eclipse.org/legal/epl-v10.html
7///////////////////////////////////////////////////////////////////////////////
8#include <stdio.h>
9#include <errno.h>
10#include <sys/types.h>
11#include <sys/stat.h>
12#include "Temp.hh"
13
14namespace Temp {
15
16BOOLEAN checkFile(const CHARSTRING& filename, const INTEGER& fileSizeInByte)
17{
18 FILE *fp;
19 //checking if the file is exist
20 fp = fopen(filename,"r");
21 if (!fp) return false;
22
23 //checking the file size if grater than expected
24 //if the filesize is set to 0 means filesize is not matter
25 //no check for that
26 struct stat buf;
27 fstat(fileno(fp), &buf);
28
29 if(fileSizeInByte != 0)
30 {
31 if(buf.st_size > (int)fileSizeInByte) return false;
32 }
33
34
35 fclose(fp);
36 return true;
37
38}
39
40BOOLEAN check__script__out(const INTEGER& phase, const CHARSTRING& to_match)
41{
42 FILE *fp = fopen(phase > 0 ? "end_script.out" /* EndTestCase */ : "begin_script.out" /* BeginTestCase */, "rt");
43 if (!fp) return false;
44 char line[512];
45 memset(line, 0, sizeof line);
46 if (!fgets(line, sizeof line, fp)) return false;
47 if (strcmp(line, (const char *)to_match) != 0) return false;
48 fclose(fp);
49 return true;
50}
51
52}
This page took 0.025727 seconds and 5 git commands to generate.