Commit 8f2d69a8 authored by Andrea Orlat's avatar Andrea Orlat
Browse files

added unit test for CIRATools::makeDirectory() method

parent 5bfc40ac
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
This file is here to differentiate between ACS style test directory and discos-style test. 

This is a discos test directory

DO NOT REMOVE THIS FILE
+62 −0
Original line number Diff line number Diff line
#include "IRATools.h"

#include <stdlib.h>

namespace IRALibraryTest {

class IRALibrary_IRATools : public ::testing::Test {
public:
	::testing::AssertionResult makeDirectory_createSimpleDirectory() {
		IRA::CString fullPath;
		fullPath=basePath+simpleDirPath;
		RecordProperty("description","check if a single level folder can be created");
		if (IRA::CIRATools::makeDirectory(fullPath)) {
			if (IRA::CIRATools::directoryExists(fullPath)) {
				return ::testing::AssertionSuccess();
			}
			else {
				return ::testing::AssertionFailure() << (const char *) fullPath << " does not exists";
			}
		}
		else {
			return ::testing::AssertionFailure() << (const char *) fullPath << " creation failed";
		}
	}

	::testing::AssertionResult makeDirectory_createComplexDirectory() {
		IRA::CString fullPath;
		fullPath=basePath+complexDirPath;
		::testing::Test::RecordProperty("description","check if a double level folder can be created");
		if (IRA::CIRATools::makeDirectory(fullPath)) {
			if (IRA::CIRATools::directoryExists(fullPath)) {
				return ::testing::AssertionSuccess();
			}
			else {
				return ::testing::AssertionFailure() << (const char *) fullPath << " does not exists";
			}
		}
		else {
			return ::testing::AssertionFailure() << (const char *) fullPath << " creation failed";
		}
	}

protected:
	static IRA::CString simpleDirPath;
	static IRA::CString complexDirPath;
	IRA::CString basePath;
	virtual void SetUp() {
		char buff[256];
		getcwd(buff,256);
		basePath=buff;
	}
	virtual void TearDown() {
		IRA::CString cleanCommand;
		int i;
		cleanCommand="rm -rf "+basePath+simpleDirPath;
		i=system((const char *)cleanCommand);
	}
};

IRA::CString IRALibrary_IRATools::simpleDirPath = IRA::CString("/firstLevelDirectory");
IRA::CString IRALibrary_IRATools::complexDirPath = simpleDirPath+IRA::CString("/secondLevelDirectory");
}
+90 −0
Original line number Diff line number Diff line
# CPP UNIT TESTING SETUP
#--------------
GTEST_HOME=/usr/local/include/gtest
GMOCK_HOME=/usr/local/include/gmock
GTEST_LIBS=gtest gtest_main

USER_INC=-I$(GTEST_HOME) -I$(GMOCK_HOME)
# END OF CPP UNIT TESTING SETUP
#---------------------

# DEFINE YOUR CPP UNIT TEST EXECUTABLES HERE as:
#
# EXECTUABLES_L = unittest
# unittest_OBJECTS = unittest
# unittest_LIBS = $(GTEST_LIBS) <ComponentNameImpl>

EXECUTABLES_L = unittest
unittest_OBJECTS = unittest
unittest_LIBS = $(GTEST_LIBS) IRALibrary
unittest_LDFLAGS = -lstdc++ -lpthread

# END OF CUSTOMIZATION
# do not edit below this line
#----------------------------

CSOURCENAMES = \
	$(foreach exe, $(EXECUTABLES) $(EXECUTABLES_L), $($(exe)_OBJECTS)) \
	$(foreach rtos, $(RTAI_MODULES) , $($(rtos)_OBJECTS)) \
	$(foreach lib, $(LIBRARIES) $(LIBRARIES_L), $($(lib)_OBJECTS))

MAKEDIRTMP := $(shell searchFile include/acsMakefile)
ifneq ($(MAKEDIRTMP),\#error\#)
   MAKEDIR := $(MAKEDIRTMP)/include
   include $(MAKEDIR)/acsMakefile
endif

# TEST TARGETS
#TODO: unittest(2) discover pyunit

do_unit: all
	@echo "running cpp unit tests"
	../bin/unittest --gtest_output=xml:results/cppunittest.xml

do_pyunit:
	@echo "running python unit tests"
	python -m unittest pyunit

do_functional:
	@echo "running python functional tests"
	python -m unittest functional

do_external:
	@echo "running python external tests"
	python -m unittest external

clean_test:
	rm -f results/*.xml
	rm -f functional/*.pyc
	rm -f pyunit/*.pyc
	rm -f external/*.pyc

unit: do_unit
	@echo " . . . 'unit' done"

pyunit: do_pyunit
	@echo " . . . 'pyunit' done"

functional: do_functional
	@echo " . . . 'functional' done"

external: do_external
	@echo " . . . 'external' done"

# TARGETS
# -------
all:	do_all
	@echo " . . . 'all' done" 

clean : clean_all clean_test
	@echo " . . . clean done"

clean_dist : clean_all clean_dist_all clean_test
	@echo " . . . clean_dist done"

man   : do_man 
	@echo " . . . man page(s) done"

install : install_all
	@echo " . . . installation done"
+0 −0

Empty file added.

+0 −0

Empty file added.

Loading